మాడ్యూల్:Citation/CS1: కూర్పుల మధ్య తేడాలు

Content deleted Content added
చి Arjunaraoc (చర్చ) చేసిన మార్పులను Chaduvari చివరి కూర్పు వరకు తిప్పికొట్టారు.
ట్యాగు: రోల్‌బ్యాక్
sync from sandbox;
పంక్తి 22:
--[[--------------------------< P A G E S C O P E V A R I A B L E S >--------------------------------------
 
delaredeclare variables here that have page-wide scope that are not brought in from other modules; thatarethat are created here and used here
and used here
 
]]
Line 695 ⟶ 694:
]]
 
local function format_chapter_title (scriptchapterscript_chapter, script_chapter_source, chapter, transchapterchapter_source, chapterurltrans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
local chapter_error = '';
 
Line 713 ⟶ 712:
end
 
chapter = script_concatenate (chapter, scriptchapterscript_chapter, script_chapter_source); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
 
if is_set (chapterurlchapter_url) then
chapter = external_link (chapterurlchapter_url, chapter, chapter_url_source, access); -- adds bare_url_missing_title error if appropriate
elseif ws_url then
chapter = external_link (ws_url, chapter .. '&nbsp;', 'ws link in chapter'); -- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
Line 722 ⟶ 721:
end
 
if is_set (transchaptertrans_chapter) then
transchaptertrans_chapter = wrap_style ('trans-quoted-title', transchaptertrans_chapter);
if is_set (chapter) then
chapter = chapter .. ' ' .. transchaptertrans_chapter;
else -- here when transchaptertrans_chapter without chapter or script-chapter
chapter = transchaptertrans_chapter;
chapter_source = trans_chapter_source:match ('trans%-?(.+)'); -- when no chapter, get matching name from trans-<param>
chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
chapter_error = ' ' .. set_error ('trans_missing_title', {chapter_source});
end
end
పంక్తి 882:
 
local function set_titletype (cite_class, title_type)
if is_set (title_type) then
if 'none' == cfg.keywords_xlate[title_type] then
 
title_type = ''; -- if |type=none then type parameter not displayed
if cfg.keywords_xlate[title_type] == 'none' then
title_type = ""; -- if |type=none then type parameter not displayed
end
return title_type; -- if |type= has been set to any other value use that value
Line 1,074 ⟶ 1,073:
]]
 
local function is_good_vanc_name (last, first, suffix)
if not suffix then
local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first; -- if first has something that looks like a generational suffix, get it
if first:find ('[,%s]') then -- when there is a space or comma, might be first name/initials + generational suffix
 
first = first:match ('(.-)[,%s]+'); -- get name/initials
suffix = first:match ('[,%s]+(.+)$'); -- get generational suffix
end
end
if is_set (suffix) then
if not is_suffix (suffix) then
Line 1,085 ⟶ 1,088:
if nil == mw.ustring.find (last, "^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$") or
nil == mw.ustring.find (first, "^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$") then
add_vanc_error (cfg.err_msg_supl['non-Latin characterchar']);
return false; -- not a string of latin characters; Vancouver requires Romanization
end;
Line 1,118 ⟶ 1,121:
return first; -- one or two initials and a valid suffix so nothing to do
else
add_vanc_error (cfg.err_msg_supl.suffix); -- one or two initials with invalid suffix so error message
return first; -- and return first unmolested
end
Line 1,549 ⟶ 1,552:
add_prop_cat ('foreign_lang_source' .. code, {name, code}); -- categorize it; code appended to allow for multiple language categorization
else -- or is a recognized language (but has a three-character code)
add_prop_cat ('foreign_lang_source_2' .. code, {code}); -- categorize it differently TODO: support mutliplemultiple three-character code categories per cs1|2 template
end
elseif cfg.local_lang_cat_enable then -- when the language and this wiki's language are the same and categorization is enabled
Line 1,835 ⟶ 1,838:
 
for i, v_name in ipairs(v_name_table) do
first = ''; -- set to empty string for concatenation and because it may have been set for previous author/editor
if v_name:match ('^%(%(.+%)%)$') then -- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
first = ''; -- set to empty string for concatenation and because it may have been set for previous author/editor
last = v_name:match ('^%(%((.+)%)%)$') -- remove doubled parntheses
corporate = true; -- flag used in list_people()
Line 1,844 ⟶ 1,847:
end
local lastfirstTable = {}
lastfirstTable = mw.text.split(v_name, "%s+")
first = table.remove(lastfirstTable); -- removes and returns value of last element in table which should be author intials or generational suffix
 
if is_suffix (first) then -- if a valid suffix
if not mw.ustring.match (first, '^%u+$') then -- mw.ustring here so that later we will catch non-latin characters
suffix = first -- save it as a suffix and
suffix = first; -- not initials so assume that whatever we got is a generational suffix
first = table.remove(lastfirstTable); -- get what should be the initials from the table
end
end -- no suffix error message here because letter combination may be result of Romanization; check for digits?
last = table.concat(lastfirstTable, "' "') -- returns a string that is the concatenation of all other names that are not initials and generational suffix
if not is_set (last) then
first = ''; -- unset
last = v_name; -- last empty because something wrong with first
add_vanc_error (cfg.err_msg_supl.name);
end
if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
add_vanc_error (cfg.err_msg_supl['missing comma']); -- matches last II last; the case when a comma is missing
end
if mw.ustring.match (v_name, ' %u %u$') then -- this test is in the wrong place TODO: move or replace with a more appropriate test
add_vanc_error (cfg.err_msg_supl.name); -- matches a space between two intiials
end
else
first = ''; -- set to empty string for concatenation and because it may have been set for previous author/editor
last = v_name; -- last name or single corporate name? Doesn't support multiword corporate names? do we need this?
end
Line 1,864 ⟶ 1,872:
if is_set (first) then
if not mw.ustring.match (first, "^%u?%u$") then -- first shall contain one or two upper-case letters, nothing else
add_vanc_error (cfg.err_msg_supl.initials); -- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
end
is_good_vanc_name (last, first, suffix); -- check first and last before restoring the suffix which may have a non-Latin digit
if is_set (suffix) then
first = first .. ' ' .. suffix; -- if there was a suffix concatenate with the initials
Line 2,300 ⟶ 2,308:
local c = {}; -- contributors list from |contributor-lastn= / contributor-firstn= pairs
local Contributors; -- assembled contributors name list
 
local Contribution = A['Contribution']; -- TODO: move to after chapter use if A:ORIGIN ('Chapter') ... to set Contribution; this to remove duplicate in aliases list
local Chapter = A['Chapter']; -- done here so that we have access to |contribution= from |chapter= aliases
local Chapter_origin = A:ORIGIN ('Chapter');
local Contribution; -- because contribution is required for contributor(s)
if 'contribution' == A:ORIGIN ('Chapter') then
Contribution = A['Chapter']; -- get the name of the contribution
end
 
if in_array(config.CitationClass, {"book","citation"}) and not is_set(A['Periodical']) then -- |contributor= and |contribution= only supported in book cites
c = extract_names (args, 'ContributorList'); -- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
Line 2,338 ⟶ 2,353:
local Conference = A['Conference'];
local TransTitle = A['TransTitle'];
local TransTitle_origin = A:ORIGIN ('TransTitle');
local TitleNote = A['TitleNote'];
local TitleLink = A['TitleLink'];
link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title'); -- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set
 
local ChapterSection = A['Chapter']; -- TODO:{{cite insertmap}} test,only; assignment,preset andto then unset Chapter when |section= in cite map;empty teststring isfor atconcatnation c.if linenot 3220used
if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
Section = A['Chapter']; -- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
Chapter = ''; -- unset for now; will be reset later from |map= if present
end
 
local ScriptChapter = A['ScriptChapter'];
local ScriptChapterOriginScriptChapter_origin = A:ORIGIN ('ScriptChapter');
local ChapterLink -- = A['ChapterLink']; -- deprecated as a parameter but still used internally by cite episode
local TransChapter = A['TransChapter'];
local TransChapter_origin = A:ORIGIN ('TransChapter');
local TitleType = A['TitleType'];
local Degree = A['Degree'];
Line 2,361 ⟶ 2,383:
 
local URL = A['URL']
local URLoriginURL_origin = A:ORIGIN('URL'); -- get name of parameter that holds URL
local ChapterURL = A['ChapterURL'];
local ChapterURLoriginChapterURL_origin = A:ORIGIN('ChapterURL'); -- get name of parameter that holds ChapterURL
local ConferenceFormat = A['ConferenceFormat'];
local ConferenceURL = A['ConferenceURL'];
local ConferenceURLoriginConferenceURL_origin = A:ORIGIN('ConferenceURL'); -- get name of parameter that holds ConferenceURL
 
local Periodical = A['Periodical'];
-- TODO: mailinglist should be removed from Periodical alias list; Periodical should be assigned value from |mailinglist= here wh
local Periodical = A['Periodical']; -- cite mailinglist or citation and |mailinglist=; error check for duplicate work params (Periodical already set)
local Periodical_origin = '';
if is_set (Periodical) then
Line 2,379 ⟶ 2,400:
end
end
 
-- TODO: mailinglist assignment here? iff Periodical not set; err msg else; see TODO c. line 2607
if 'mailinglist' == config.CitationClass then -- special case for {{cite mailing list}}
if is_set (Periodical) and is_set (A ['MailingList']) then -- both set emit an error
table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', Periodical_origin) .. ' and ' .. wrap_style ('parameter', 'mailinglist')}, true )});
end
 
Periodical = A ['MailingList']; -- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
Periodical_origin = A:ORIGIN('MailingList');
end
 
 
 
local ScriptPeriodical = A['ScriptPeriodical'];
local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
Line 2,393 ⟶ 2,426:
 
local TransPeriodical = A['TransPeriodical'];
local TransPeriodical_origin = A:ORIGIN ('TransPeriodical');
 
local Series = A['Series'];
Line 2,511 ⟶ 2,545:
local TranscriptFormat = A['TranscriptFormat'];
local TranscriptURL = A['TranscriptURL']
local TranscriptURLoriginTranscriptURL_origin = A:ORIGIN('TranscriptURL'); -- get name of parameter that holds TranscriptURL
 
local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);
Line 2,585 ⟶ 2,619:
]]
 
local Encyclopedia = A['Encyclopedia']; -- used as a flag by this module and by ~/COinS
 
if is_set (Encyclopedia) then -- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
table.insert (z.message_tail, {set_error ('parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
Encyclopedia = nil; -- unset because not supported by this template
end
end
 
if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
if is_set (Periodical) and is_set (Encyclopedia) then -- when both set emit an error
table.insert (z.message_tail, {set_error('redundant_parameters', {wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. wrap_style ('parameter', Periodical_origin)}, true )});
end
 
if is_set (Encyclopedia) then
Periodical = Encyclopedia; -- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
Periodical_origin = A:ORIGIN ('Encyclopedia');
end
 
if ( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia)) then -- test code for citation
if is_set (Periodical) then -- Periodical is set when |encyclopedia is set
if is_set(Title) or is_set (ScriptTitle) then
Line 2,593 ⟶ 2,643:
Chapter = Title; -- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
ScriptChapter = ScriptTitle;
ScriptChapterOriginScriptChapter_origin = A:ORIGIN('ScriptTitle')
TransChapter = TransTitle;
ChapterURL = URL;
ChapterURLoriginChapterURL_origin = A:ORIGIN('URL')
 
ChapterUrlAccess = UrlAccess;
Line 2,628 ⟶ 2,678:
end
end
end
 
-- special case for cite mailing list
if (config.CitationClass == "mailinglist") then -- TODO: move this to Periodical assignment; see TODOs at c. line 2360
Periodical = A ['MailingList'];
elseif 'mailinglist' == Periodical_origin then
Periodical = ''; -- unset because mailing list is only used for cite mailing list
end
 
Line 2,641 ⟶ 2,684:
if is_set(BookTitle) then
Chapter = Title;
Chapter_origin = 'title';
-- ChapterLink = TitleLink; -- |chapterlink= is deprecated
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
ChapterURLoriginChapterURL_origin = URLoriginURL_origin;
URLoriginURL_origin = '';
ChapterFormat = Format;
TransChapter = TransTitle;
TransChapter_origin = TransTitle_origin;
Title = BookTitle;
Format = '';
Line 2,664 ⟶ 2,709:
local Sheets = A['Sheets'] or '';
if config.CitationClass == "map" then
if is_set (Chapter) then
table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'map') .. ' and ' .. wrap_style ('parameter', Chapter_origin)}, true ) } ); -- add error message
end
Chapter = A['Map'];
Chapter_origin = A:ORIGIN('Map');
ChapterURL = A['MapURL'];
ChapterURLoriginChapterURL_origin = A:ORIGIN('MapURL');
TransChapter = A['TransMap'];
ScriptChapter = A['ScriptMap']
ScriptChapterOriginScriptChapter_origin = A:ORIGIN('ScriptMap')
 
ChapterUrlAccess = MapUrlAccess;
Line 2,714 ⟶ 2,763:
Chapter = Title; -- promote title parameters to chapter
ScriptChapter = ScriptTitle;
ScriptChapterOriginScriptChapter_origin = A:ORIGIN('ScriptTitle');
ChapterLink = TitleLink; -- alias episodelink
TransChapter = TransTitle;
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
ChapterURLoriginChapterURL_origin = A:ORIGIN('URL');
Title = Series; -- promote series to title
Line 2,859 ⟶ 2,908:
end -- end of do
 
-- Account forLink the odditytitle thatof isthe {{citework journal}}if with |pmc= set andno |url= notwas set.provided, but Dowe thishave aftera date|pmc= checkor buta before|doi= COInS.with |doi-access=free
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
Embargo = is_embargoed (Embargo);
 
if config.CitationClass == "journal" and not is_set(URL) and not is_set(ID_list['PMC']TitleLink) then
if is_set(ID_list['PMC']) and not is_set (Embargo) then -- if not embargoed or embargo has expired
URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC']; -- set url to be the same as the PMC external link if not embargoed
URLoriginURL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URLoriginURL_origin to parameter name for use in error message if citation is missing a |title=
elseif is_set(ID_list['DOI']) and ID_access_levels['DOI'] == "free" then
if is_set(AccessDate) then -- access date requires |url=; pmc created url is not |url=
URL=cfg.id_handlers['DOI'].prefix .. ID_list['DOI'];
table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
URL_origin = cfg.id_handlers['DOI'].parameters[1];
AccessDate = ''; -- unset
end
if is_set(URL) and is_set(AccessDate) then -- access date requires |url=; pmc or doi created url is not |url=
 
table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
AccessDate = ''; -- unset
end
end
Line 2,877 ⟶ 2,928:
-- At this point fields may be nil if they weren't specified in the template use. We can use that fact.
-- Test if citation has no title
if not is_set(Title) and not is_set(TransTitle) and not is_set(ScriptTitle) then -- has special case for cite episode
table.insert( z.message_tail, { set_error( 'citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
not is_set(TransTitle) and
not is_set(ScriptTitle) then
if 'episode' == config.CitationClass then -- special case for cite episode; TODO: is there a better way to do this?
table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
else
table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
end
end
 
Line 2,923 ⟶ 2,968:
local OCinSoutput = COinS({
['Periodical'] = strip_apostrophe_markup (Periodical), -- no markup in the metadata
['Encyclopedia'] = strip_apostrophe_markup (Encyclopedia), -- just a flag; content ignored by ~/COinS
['Chapter'] = make_coins_title (coins_chapter, ScriptChapter), -- Chapter and ScriptChapter stripped of bold / italic wikimarkup
['Degree'] = Degree; -- cite thesis only
Line 2,930 ⟶ 2,975:
['Date'] = COinS_date.rftdate, -- COinS_date has correctly formatted date if Date is valid;
['Season'] = COinS_date.rftssn,
['Quarter'] = COinS_date.rftquarter,
['Chron'] = COinS_date.rftchron or (not COinS_date.rftdate and Date) or '', -- chron but if not set and invalid date format use Date; keep this last bit?
['Series'] = Series,
Line 3,044 ⟶ 3,090:
end
 
local OriginalURL, OriginalURLoriginOriginalURL_origin, OriginalFormat, OriginalAccess;
UrlStatus = UrlStatus:lower(); -- used later when assembling archived text
if is_set( ArchiveURL ) then
if is_set (ChapterURL) then -- if chapter-url is set apply archive url to it
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
OriginalURLoriginOriginalURL_origin = ChapterURLoriginChapterURL_origin; -- name of chapter-url parameter for error messages
OriginalFormat = ChapterFormat; -- and original |chapter-format=
 
if 'live' ~= UrlStatus then
ChapterURL = ArchiveURL -- swap-in the archive's url
ChapterURLoriginChapterURL_origin = A:ORIGIN('ArchiveURL') -- name of archive-url parameter for error messages
ChapterFormat = ArchiveFormat or ''; -- swap in archive's format
ChapterUrlAccess = nil; -- restricted access levels do not make sense for archived urls
Line 3,060 ⟶ 3,106:
elseif is_set (URL) then
OriginalURL = URL; -- save copy of original source URL
OriginalURLoriginOriginalURL_origin = URLoriginURL_origin; -- name of url parameter for error messages
OriginalFormat = Format; -- and original |format=
OriginalAccess = UrlAccess;
Line 3,066 ⟶ 3,112:
if 'live' ~= UrlStatus then -- if URL set then archive-url applies to it
URL = ArchiveURL -- swap-in the archive's url
URLoriginURL_origin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
Format = ArchiveFormat or ''; -- swap in archive's format
UrlAccess = nil; -- restricted access levels do not make sense for archived urls
Line 3,083 ⟶ 3,129:
chap_param = A:ORIGIN ('ChapterURL')
elseif is_set (ScriptChapter) then
chap_param = ScriptChapterOriginScriptChapter_origin;
else is_set (ChapterFormat)
chap_param = A:ORIGIN ('ChapterFormat')
Line 3,104 ⟶ 3,150:
end
 
Chapter = format_chapter_title (ScriptChapter, ScriptChapterOriginScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURLoriginChapterURL_origin, no_quotes, ChapterUrlAccess); -- Contribution is also in Chapter
if is_set (Chapter) then
Chapter = Chapter .. ChapterFormat ;
Line 3,116 ⟶ 3,162:
end
 
-- Format main title
-- Format main title. TODO: add support for non-English versions of 'Archived copy' when used on other-language wikis
if is_set (ArchiveURL) and
(mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation.archived_copy.en) or -- if title is 'Archived copy' (place holder added by bots that can't find proper title)
Line 3,160 ⟶ 3,206:
 
if is_set (Title) then -- TODO: is this the right place to be making wikisource urls?
if is_set (TitleLink) and is_set (URL) then
table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } ); -- set an error message because we can't have both
TitleLink = ''; -- unset
end
if not is_set (TitleLink) and is_set (URL) then
Title = external_link (URL, Title, URLoriginURL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
URL = ''; -- unset these because no longer needed
Format = "";
Line 3,196 ⟶ 3,247:
if is_set (Conference) then
if is_set (ConferenceURL) then
Conference = external_link( ConferenceURL, Conference, ConferenceURLoriginConferenceURL_origin, nil );
end
Conference = sepc .. " " .. Conference .. ConferenceFormat;
elseif is_set(ConferenceURL) then
Conference = sepc .. " " .. external_link( ConferenceURL, nil, ConferenceURLoriginConferenceURL_origin, nil );
end
 
Line 3,233 ⟶ 3,284:
At = is_set(At) and (sepc .. " " .. At) or "";
Position = is_set(Position) and (sepc .. " " .. Position) or "";
if config.CitationClass == 'map' then -- TODO copy this line and
local SectionSections = A['SectionSections']; -- TODOSection move(singular) thisis linean toalias c.of line 2337Chapter so thatset separate Sections in aliases{} not required? then unset Chapter?earlier
local Sections = A['Sections'];
local Inset = A['Inset'];
Line 3,307 ⟶ 3,357:
 
if is_set(URL) then
URL = " " .. external_link( URL, nil, URLoriginURL_origin, UrlAccess );
end
 
Line 3,346 ⟶ 3,396:
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ external_link( OriginalURL, cfg.messages['original'], OriginalURLoriginOriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } ); -- format already styled
end
else -- OriginalUrl not set
Line 3,379 ⟶ 3,429:
if is_set(Transcript) then
if is_set(TranscriptURL) then
Transcript = external_link( TranscriptURL, Transcript, TranscriptURLoriginTranscriptURL_origin, nil );
end
Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
elseif is_set(TranscriptURL) then
Transcript = external_link( TranscriptURL, nil, TranscriptURLoriginTranscriptURL_origin, nil );
end
 
Line 3,405 ⟶ 3,455:
if (is_set (Periodical) or is_set (ScriptPeriodical) or is_set (TransPeriodical)) then
if is_set(Title) or is_set(TitleNote) then
Periodical = sepc .. " " .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
else
Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
end
end
Line 3,554 ⟶ 3,604:
if is_set(config.CitationClass) and config.CitationClass ~= "citation" then
options.class = string.format ('%s %s %s', 'citation', config.CitationClass, is_set (Mode) and Mode or 'cs1'); -- class=citation required for blue highlight when used with |ref=
options.class = "citation " .. config.CitationClass; -- class=citation required for blue highlight when used with |ref=
else
options.class = "string.format ('%s %s', 'citation"', is_set (Mode) and Mode or 'cs2');
end
Line 3,703 ⟶ 3,752:
Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters. If found, then the string is possibly a
parameter that is missing its pipe. There are two tests made:
{{cite ... |title=Title access-date=2016-03-17}} -- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
{{cite ... |title=access-date=2016-03-17}} -- the first parameter has no value (whitespace after the first = is trimmed by mediawiki)
 
cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc. To prevent false positives xml/html
tags are removed before the search.
Line 3,718 ⟶ 3,767:
 
capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*='); -- find and categorize parameters with possible missing pipes
if capture and validate (capture) then -- if the capture is a valid parameter name
table.insert( z.message_tail, {set_error ('missing_pipe', parameter)});
end
end
Line 3,731 ⟶ 3,780:
 
local function has_extraneous_punc (param, value)
if 'number' == type (param) then
return;
end
param = param:gsub ('%d+', '#'); -- enumerated name-list mask params allow terminal punct; normalize
if cfg.punct_skip[param] then
return; -- parameter name found in the skip table so done
Line 3,812 ⟶ 3,866:
 
local config = {}; -- table to store parameters from the module {{#invoke:}}
for k, v in pairs( frame.args ) do -- get parameters from the {{#invoke}} frame
config[k] = v;
-- args[k] = v; -- crude debug toolsupport that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
end
 
local capture; -- the single supported capture when matching unknown parameters using patterns
for k, v in pairs( pframe.args ) do -- get parameters from the parent (template) frame
if v ~= '' then
if ('string' == type (k)) then
Line 3,865 ⟶ 3,919:
end
end
 
missing_pipe_check (k, v); -- do we think that there is a parameter that is missing a pipe?
args[k] = v; -- TODO: issave this theparameter bestand place for thisits translation?value
 
args[k] = v;
-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
elseif args[k] ~= nil or (k == 'postscript') then -- here when v is empty string
-- elseif args[k] ~= v; nil or (k == 'postscript') then -- whywhen doargs[k] wehas doa this?value from {{#invoke}} frame (we don't supportnormally 'empty'do parametersthat)
-- args[k] = v; -- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
end
end -- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
end
 
for k, v in pairs( args ) do
if 'string' == typehas_invisible_chars (k, v) then; -- don'tlook evaluatefor positionalinvisible parameterscharacters
has_extraneous_punc (k, v); -- look for extraneous terminal punctuation in parameter values
has_invisible_chars (k, v);
has_extraneous_puncmissing_pipe_check (k, v); -- lookdo forwe extraneousthink terminalthat punctuationthere inis a parameter valuesthat is missing a pipe?
end
end
 
"https://te.wikipedia.org/wiki/మాడ్యూల్:Citation/CS1" నుండి వెలికితీశారు