"ମଡ୍ୟୁଲ:Citation/CS1" ପୃଷ୍ଠାର ସଂସ୍କରଣ‌ଗୁଡ଼ିକ ମଧ୍ୟରେ ତଫାତ

Content deleted Content added
don't evaluate positional parameters for invisible chars;
No edit summary
୨୨ କ ଧାଡ଼ି:
--[[--------------------------< P A G E S C O P E V A R I A B L E S >--------------------------------------
 
declaredelare variables here that have page-wide scope that are not brought in from other modules; that arethatare created here
and used here
 
]]
Line ୬୯୪ ⟶ ୬୯୫:
]]
 
local function format_chapter_title (script_chapterscriptchapter, script_chapter_source, chapter, chapter_sourcetranschapter, trans_chapter, trans_chapter_source, chapter_urlchapterurl, chapter_url_source, no_quotes, access)
local chapter_error = '';
 
Line ୭୧୨ ⟶ ୭୧୩:
end
 
chapter = script_concatenate (chapter, script_chapterscriptchapter, script_chapter_source); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
 
if is_set (chapter_urlchapterurl) then
chapter = external_link (chapter_urlchapterurl, 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 ୭୨୧ ⟶ ୭୨୨:
end
 
if is_set (trans_chaptertranschapter) then
trans_chaptertranschapter = wrap_style ('trans-quoted-title', trans_chaptertranschapter);
if is_set (chapter) then
chapter = chapter .. ' ' .. trans_chaptertranschapter;
else -- here when trans_chaptertranschapter without chapter or script-chapter
chapter = trans_chaptertranschapter;
chapter_error = ' ' .. set_error ('trans_missing_title', {'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_source});
end
end
୮୮୨ କ ଧାଡ଼ି:
 
local function set_titletype (cite_class, title_type)
if is_set (title_type) then
 
if 'none' == cfg.keywords_xlate[title_type] then
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 ୧,୦୭୩ ⟶ ୧,୦୭୪:
]]
 
local function is_good_vanc_name (last, first, suffix)
local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first; -- if first has something that looks like a generational suffix, get it
if not suffix then
 
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 ୧,୦୮୮ ⟶ ୧,୦୮୫:
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 charcharacter']);
return false; -- not a string of latin characters; Vancouver requires Romanization
end;
Line ୧,୧୨୧ ⟶ ୧,୧୧୮:
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 ୧,୫୫୨ ⟶ ୧,୫୪୯:
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 multiplemutliple 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 ୧,୮୩୮ ⟶ ୧,୮୩୫:
 
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 ୧,୮୪୭ ⟶ ୧,୮୪୪:
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
 
suffix = first -- save it as a suffix and
if not mw.ustring.match (first, '^%u+$') then -- mw.ustring here so that later we will catch non-latin characters
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 -- no suffix error message here because letter combination may be result of Romanization; check for digits?
end
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 ୧,୮୭୨ ⟶ ୧,୮୬୪:
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 ୨,୩୦୮ ⟶ ୨,୩୦୦:
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 ୨,୩୫୩ ⟶ ୨,୩୩୮:
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 SectionChapter = A['Chapter']; -- {{citeTODO: map}}insert only;test, presetassignment, toand emptythen unset Chapter when |section= in cite map; stringtest foris concatnationat ifc. notline used3220
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 ScriptChapter_originScriptChapterOrigin = 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 ୨,୩୮୩ ⟶ ୨,୩୬୧:
 
local URL = A['URL']
local URL_originURLorigin = A:ORIGIN('URL'); -- get name of parameter that holds URL
local ChapterURL = A['ChapterURL'];
local ChapterURL_originChapterURLorigin = A:ORIGIN('ChapterURL'); -- get name of parameter that holds ChapterURL
local ConferenceFormat = A['ConferenceFormat'];
local ConferenceURL = A['ConferenceURL'];
local ConferenceURL_originConferenceURLorigin = A:ORIGIN('ConferenceURL'); -- get name of parameter that holds ConferenceURL
 
-- TODO: mailinglist should be removed from Periodical alias list; Periodical should be assigned value from |mailinglist= here wh
local Periodical = A['Periodical'];
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 ୨,୪୦୦ ⟶ ୨,୩୭୯:
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 ୨,୪୨୬ ⟶ ୨,୩୯୩:
 
local TransPeriodical = A['TransPeriodical'];
local TransPeriodical_origin = A:ORIGIN ('TransPeriodical');
 
local Series = A['Series'];
Line ୨,୫୪୫ ⟶ ୨,୫୧୧:
local TranscriptFormat = A['TranscriptFormat'];
local TranscriptURL = A['TranscriptURL']
local TranscriptURL_originTranscriptURLorigin = 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 ୨,୬୧୯ ⟶ ୨,୫୮୫:
]]
 
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 ୨,୬୪୩ ⟶ ୨,୫୯୩:
Chapter = Title; -- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
ScriptChapter = ScriptTitle;
ScriptChapter_originScriptChapterOrigin = A:ORIGIN('ScriptTitle')
TransChapter = TransTitle;
ChapterURL = URL;
ChapterURL_originChapterURLorigin = A:ORIGIN('URL')
 
ChapterUrlAccess = UrlAccess;
Line ୨,୬୭୮ ⟶ ୨,୬୨୮:
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 ୨,୬୮୪ ⟶ ୨,୬୪୧:
if is_set(BookTitle) then
Chapter = Title;
Chapter_origin = 'title';
-- ChapterLink = TitleLink; -- |chapterlink= is deprecated
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
ChapterURL_originChapterURLorigin = URL_originURLorigin;
URL_originURLorigin = '';
ChapterFormat = Format;
TransChapter = TransTitle;
TransChapter_origin = TransTitle_origin;
Title = BookTitle;
Format = '';
Line ୨,୭୦୯ ⟶ ୨,୬୬୪:
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'];
ChapterURL_originChapterURLorigin = A:ORIGIN('MapURL');
TransChapter = A['TransMap'];
ScriptChapter = A['ScriptMap']
ScriptChapter_originScriptChapterOrigin = A:ORIGIN('ScriptMap')
 
ChapterUrlAccess = MapUrlAccess;
Line ୨,୭୬୩ ⟶ ୨,୭୧୪:
Chapter = Title; -- promote title parameters to chapter
ScriptChapter = ScriptTitle;
ScriptChapter_originScriptChapterOrigin = A:ORIGIN('ScriptTitle');
ChapterLink = TitleLink; -- alias episodelink
TransChapter = TransTitle;
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
ChapterURL_originChapterURLorigin = A:ORIGIN('URL');
Title = Series; -- promote series to title
Line ୨,୯୦୮ ⟶ ୨,୮୫୯:
end -- end of do
 
-- LinkAccount for the titleoddity ofthat theis work{{cite ifjournal}} nowith |pmc= set and |url= wasnot provided,set. but weDo havethis aafter |pmc=date orcheck abut |doi=before with |doi-access=freeCOInS.
-- 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(TitleLinkID_list['PMC']) 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
URL_originURLorigin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_originURLorigin to parameter name for use in error message if citation is missing a |title=
if is_set(AccessDate) then -- access date requires |url=; pmc created url is not |url=
elseif is_set(ID_list['DOI']) and ID_access_levels['DOI'] == "free" then
table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
URL=cfg.id_handlers['DOI'].prefix .. ID_list['DOI'];
AccessDate = ''; -- unset
URL_origin = cfg.id_handlers['DOI'].parameters[1];
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 ୨,୯୨୮ ⟶ ୨,୮୭୭:
-- 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', if {'episode' == config.CitationClass andthen -- 'series'special orcase 'title'},for truecite )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 ୨,୯୬୮ ⟶ ୨,୯୨୩:
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 ୨,୯୭୫ ⟶ ୨,୯୩୦:
['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 ୩,୦୯୦ ⟶ ୩,୦୪୪:
end
 
local OriginalURL, OriginalURL_originOriginalURLorigin, 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
OriginalURL_originOriginalURLorigin = ChapterURL_originChapterURLorigin; -- 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
ChapterURL_originChapterURLorigin = 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 ୩,୧୦୬ ⟶ ୩,୦୬୦:
elseif is_set (URL) then
OriginalURL = URL; -- save copy of original source URL
OriginalURL_originOriginalURLorigin = URL_originURLorigin; -- name of url parameter for error messages
OriginalFormat = Format; -- and original |format=
OriginalAccess = UrlAccess;
Line ୩,୧୧୨ ⟶ ୩,୦୬୬:
if 'live' ~= UrlStatus then -- if URL set then archive-url applies to it
URL = ArchiveURL -- swap-in the archive's url
URL_originURLorigin = 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 ୩,୧୨୯ ⟶ ୩,୦୮୩:
chap_param = A:ORIGIN ('ChapterURL')
elseif is_set (ScriptChapter) then
chap_param = ScriptChapter_originScriptChapterOrigin;
else is_set (ChapterFormat)
chap_param = A:ORIGIN ('ChapterFormat')
Line ୩,୧୫୦ ⟶ ୩,୧୦୪:
end
 
Chapter = format_chapter_title (ScriptChapter, ScriptChapter_originScriptChapterOrigin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_originChapterURLorigin, no_quotes, ChapterUrlAccess); -- Contribution is also in Chapter
if is_set (Chapter) then
Chapter = Chapter .. ChapterFormat ;
Line ୩,୧୬୨ ⟶ ୩,୧୧୬:
end
 
-- Format main title. TODO: add support for non-English versions of 'Archived copy' when used on other-language wikis
-- Format main title
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 ୩,୨୦୬ ⟶ ୩,୧୬୦:
 
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, URL_originURLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
URL = ''; -- unset these because no longer needed
Format = "";
Line ୩,୨୪୭ ⟶ ୩,୧୯୬:
if is_set (Conference) then
if is_set (ConferenceURL) then
Conference = external_link( ConferenceURL, Conference, ConferenceURL_originConferenceURLorigin, nil );
end
Conference = sepc .. " " .. Conference .. ConferenceFormat;
elseif is_set(ConferenceURL) then
Conference = sepc .. " " .. external_link( ConferenceURL, nil, ConferenceURL_originConferenceURLorigin, nil );
end
 
Line ୩,୨୮୪ ⟶ ୩,୨୩୩:
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 SectionsSection = A['SectionsSection']; -- SectionTODO (singular)move isthis anline aliasto ofc. Chapterline 2337 so setthat earlierseparate Sections in aliases{} not required? then unset Chapter?
local Sections = A['Sections'];
local Inset = A['Inset'];
Line ୩,୩୫୭ ⟶ ୩,୩୦୭:
 
if is_set(URL) then
URL = " " .. external_link( URL, nil, URL_originURLorigin, UrlAccess );
end
 
Line ୩,୩୯୬ ⟶ ୩,୩୪୬:
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_originOriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } ); -- format already styled
end
else -- OriginalUrl not set
Line ୩,୪୨୯ ⟶ ୩,୩୭୯:
if is_set(Transcript) then
if is_set(TranscriptURL) then
Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_originTranscriptURLorigin, nil );
end
Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
elseif is_set(TranscriptURL) then
Transcript = external_link( TranscriptURL, nil, TranscriptURL_originTranscriptURLorigin, nil );
end
 
Line ୩,୪୫୫ ⟶ ୩,୪୦୫:
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 ୩,୬୦୪ ⟶ ୩,୫୫୪:
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 ୩,୭୫୨ ⟶ ୩,୭୦୩:
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 ୩,୭୬୭ ⟶ ୩,୭୧୮:
 
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 ୩,୭୮୦ ⟶ ୩,୭୩୧:
 
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 ୩,୮୬୬ ⟶ ୩,୮୧୨:
 
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 supporttool 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 ୩,୯୧୯ ⟶ ୩,୮୬୫:
end
end
missing_pipe_check (k, v); -- do we think that there is a parameter that is missing a pipe?
 
args[k] = v; -- saveTODO: is this parameterthe andbest itsplace for this valuetranslation?
args[k] = v;
 
elseif args[k] ~= nil or (k == 'postscript') then -- here when v is empty string
-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
-- elseif args[k] ~= nil or (k == 'postscript') thenv; -- whenwhy args[k]do haswe ado valuethis? from {{#invoke}} frame (we don't normallysupport do'empty' that)parameters
end
-- args[k] = v; -- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
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' == type (k) then -- don't evaluate positional parameters
has_invisible_chars (k, v); -- look for invisible characters
has_extraneous_punc (k, v); -- look for extraneous terminal punctuation in parameter values
end
has_extraneous_punc (k, v); -- look for extraneous terminal punctuation in parameter values
missing_pipe_check (k, v); -- do we think that there is a parameter that is missing a pipe?
end
 
return table.concat ({citation0citation( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end