"ମଡ୍ୟୁଲ: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 >--------------------------------------
and used here ]]
Line ୬୯୪ ⟶ ୬୯୫:
]]
local function format_chapter_title (
local chapter_error = '';
Line ୭୧୨ ⟶ ୭୧୩:
end
chapter = script_concatenate (chapter,
if is_set (
chapter = external_link (
elseif ws_url then
chapter = external_link (ws_url, chapter .. ' ', '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 (
if is_set (chapter) then
chapter = chapter .. ' ' ..
else -- here when
chapter =
chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
end
end
୮୮୨ କ ଧାଡ଼ି:
local function set_titletype (cite_class, title_type)
if is_set
if cfg.keywords_xlate[title_type] == 'none' then
title_type = 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
local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first; -- if first has something that looks like a generational suffix, get it
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
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
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
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
if is_suffix (first) then -- if a valid suffix
suffix = first -- save it as a suffix and
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?
last = table.concat(lastfirstTable,
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
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
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 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
local ScriptChapter = A['ScriptChapter'];
local
local ChapterLink -- = A['ChapterLink']; -- deprecated as a parameter but still used internally by cite episode
local TransChapter = A['TransChapter'];
local TitleType = A['TitleType'];
local Degree = A['Degree'];
Line ୨,୩୮୩ ⟶ ୨,୩୬୧:
local URL = A['URL']
local
local ChapterURL = A['ChapterURL'];
local
local ConferenceFormat = A['ConferenceFormat'];
local ConferenceURL = A['ConferenceURL'];
local
-- 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 ୨,୪୦୦ ⟶ ୨,୩୭୯:
end
end
-- TODO: mailinglist assignment here? iff Periodical not set; err msg else; see TODO c. line 2607
local ScriptPeriodical = A['ScriptPeriodical'];
local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
Line ୨,୪୨୬ ⟶ ୨,୩୯୩:
local TransPeriodical = A['TransPeriodical'];
local Series = A['Series'];
Line ୨,୫୪୫ ⟶ ୨,୫୧୧:
local TranscriptFormat = A['TranscriptFormat'];
local TranscriptURL = A['TranscriptURL']
local
local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);
Line ୨,୬୧୯ ⟶ ୨,୫୮୫:
]]
local Encyclopedia = A['Encyclopedia'];
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;
TransChapter = TransTitle;
ChapterURL = 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;
-- ChapterLink = TitleLink; -- |chapterlink= is deprecated
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
ChapterFormat = Format;
TransChapter = TransTitle;
Title = BookTitle;
Format = '';
Line ୨,୭୦୯ ⟶ ୨,୬୬୪:
local Sheets = A['Sheets'] or '';
if config.CitationClass == "map" then
Chapter = A['Map'];
ChapterURL = A['MapURL'];
TransChapter = A['TransMap'];
ScriptChapter = A['ScriptMap']
ChapterUrlAccess = MapUrlAccess;
Line ୨,୭୬୩ ⟶ ୨,୭୧୪:
Chapter = Title; -- promote title parameters to chapter
ScriptChapter = ScriptTitle;
ChapterLink = TitleLink; -- alias episodelink
TransChapter = TransTitle;
ChapterURL = URL;
ChapterUrlAccess = UrlAccess;
Title = Series; -- promote series to title
Line ୨,୯୦୮ ⟶ ୨,୮୫୯:
end -- end of do
--
-- 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
if
URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC']; -- set url to be the same as the PMC external link if not embargoed
if is_set(AccessDate) then -- access date requires |url=; pmc created url is not |url=
table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
AccessDate = ''; -- unset
end
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 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),
['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,
['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,
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
OriginalFormat = ChapterFormat; -- and original |chapter-format=
if 'live' ~= UrlStatus then
ChapterURL = ArchiveURL -- swap-in the archive's url
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
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
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 =
else is_set (ChapterFormat)
chap_param = A:ORIGIN ('ChapterFormat')
Line ୩,୧୫୦ ⟶ ୩,୧୦୪:
end
Chapter = format_chapter_title (ScriptChapter,
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
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 not is_set (TitleLink) and is_set (URL) then
Title = external_link (URL, Title,
URL = ''; -- unset these because no longer needed
Format = "";
Line ୩,୨୪୭ ⟶ ୩,୧୯୬:
if is_set (Conference) then
if is_set (ConferenceURL) then
Conference = external_link( ConferenceURL, Conference,
end
Conference = sepc .. " " .. Conference .. ConferenceFormat;
elseif is_set(ConferenceURL) then
Conference = sepc .. " " .. external_link( ConferenceURL, 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
local Sections = A['Sections'];
local Inset = A['Inset'];
Line ୩,୩୫୭ ⟶ ୩,୩୦୭:
if is_set(URL) then
URL = " " .. external_link( URL, nil,
end
Line ୩,୩୯୬ ⟶ ୩,୩୪୬:
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ external_link( OriginalURL, cfg.messages['original'],
end
else -- OriginalUrl not set
Line ୩,୪୨୯ ⟶ ୩,୩୭୯:
if is_set(Transcript) then
if is_set(TranscriptURL) then
Transcript = external_link( TranscriptURL, Transcript,
end
Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
elseif is_set(TranscriptURL) then
Transcript = external_link( TranscriptURL, 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
else
Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical
end
end
Line ୩,୬୦୪ ⟶ ୩,୫୫୪:
if is_set(config.CitationClass) and config.CitationClass ~= "citation" then
options.class =
options.class = "citation " .. config.CitationClass; -- class=citation required for blue highlight when used with |ref=
else
options.class =
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
{{cite ... |title=Title access-date=2016-03-17}}
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
table.insert( z.message_tail, {set_error ('missing_pipe',
end
end
Line ୩,୭୮୦ ⟶ ୩,୭୩୧:
local function has_extraneous_punc (param, value)
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
config[k] = v;
end
local capture; -- the single supported capture when matching unknown parameters using patterns
for k, v in pairs( pframe.args ) do
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;
elseif args[k] ~= nil or (k == 'postscript') then -- here when v is empty string
end
end
for k, v in pairs( args ) do
if 'string' == type (k) then -- don't evaluate positional parameters
has_invisible_chars (k, v);
has_extraneous_punc (k, v); -- look for extraneous terminal punctuation in parameter values
end
end
return table.concat ({
end
|