Anonymous user
Module:Citation/CS1/sandbox: Difference between revisions
no edit summary
(make parentheses search less greedy) |
imported>Trappist the monk No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
--[[ | --[[ | ||
History of changes since last sync: | History of changes since last sync: 2023-01-14 | ||
2023-02-21: detect |archive-date= / |archive-url= timestamp mismatch; see Help_talk:Citation_Style_1#Error_or_Maint_message_if_archive_date_doesn't_match_url | |||
2023-03-14: cleanup archive error messaging; see Help_talk:Citation_Style_1#Possible_invalid_edits_to_live_CS1_module | |||
]] | ]] | ||
require(' | require('strict'); | ||
--[[--------------------------< F O R W A R D D E C L A R A T I O N S >-------------------------------------- | --[[--------------------------< F O R W A R D D E C L A R A T I O N S >-------------------------------------- | ||
each of these counts against the Lua upvalue limit | each of these counts against the Lua upvalue limit | ||
]] | ]] | ||
Line 27: | Line 18: | ||
local utilities; -- functions in Module:Citation/CS1/Utilities | local utilities; -- functions in Module:Citation/CS1/Utilities | ||
local z ={}; -- table of tables in Module:Citation/CS1/Utilities | local z = {}; -- table of tables in Module:Citation/CS1/Utilities | ||
local identifiers; -- functions and tables in Module:Citation/CS1/Identifiers | local identifiers; -- functions and tables in Module:Citation/CS1/Identifiers | ||
Line 33: | Line 24: | ||
local cfg = {}; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration | local cfg = {}; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration | ||
local whitelist = {}; -- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist | local whitelist = {}; -- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist | ||
--[[------------------< P A G E S C O P E V A R I A B L E S >--------------- | --[[------------------< P A G E S C O P E V A R I A B L E S >--------------- | ||
declare variables here that have page-wide scope that are not brought in from | declare variables here that have page-wide scope that are not brought in from | ||
other modules; that are created here and used here | other modules; that are created here and used here | ||
]] | ]] | ||
local added_deprecated_cat; -- Boolean flag so that the category is added only once | local added_deprecated_cat; -- Boolean flag so that the category is added only once | ||
local added_vanc_errs; -- Boolean flag so we only emit one Vancouver error / category | local added_vanc_errs; -- Boolean flag so we only emit one Vancouver error / category | ||
Line 44: | Line 39: | ||
local is_preview_mode; -- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module) | local is_preview_mode; -- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module) | ||
local is_sandbox; -- true when using sandbox modules to render citation | local is_sandbox; -- true when using sandbox modules to render citation | ||
--[[--------------------------< F I R S T _ S E T >------------------------------------------------------------ | --[[--------------------------< F I R S T _ S E T >------------------------------------------------------------ | ||
Line 166: | Line 162: | ||
end | end | ||
for _, d in ipairs ( | for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do -- look for single letter second level domain names for these top level domains | ||
if domain:match ('%f[%w][%w]%.' .. d) then | if domain:match ('%f[%w][%w]%.' .. d) then | ||
return true | return true | ||
Line 277: | Line 273: | ||
local function link_title_ok (link, lorig, title, torig) | local function link_title_ok (link, lorig, title, torig) | ||
local orig; | local orig; | ||
if utilities.is_set (link) then -- don't bother if <param>-link doesn't have a value | if utilities.is_set (link) then -- don't bother if <param>-link doesn't have a value | ||
if not link_param_ok (link) then -- check |<param>-link= markup | if not link_param_ok (link) then -- check |<param>-link= markup | ||
Line 413: | Line 409: | ||
utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)}); | utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)}); | ||
else | else | ||
error (cfg.messages["bare_url_no_origin"]); | error (cfg.messages["bare_url_no_origin"]); -- programmer error; valid parameter name does not have matching meta-parameter | ||
end | end | ||
end | end | ||
Line 473: | Line 469: | ||
local function kern_quotes (str) | local function kern_quotes (str) | ||
local cap = ''; | local cap = ''; | ||
local wl_type, label, link; | local wl_type, label, link; | ||
Line 480: | Line 475: | ||
if 1 == wl_type then -- [[D]] simple wikilink with or without quote marks | if 1 == wl_type then -- [[D]] simple wikilink with or without quote marks | ||
if mw.ustring.match (str, '%[%[[\"“”\'‘’].+[\"“”\'‘’]%]%]') then -- leading and trailing quote marks | if mw.ustring.match (str, '%[%[[\"“”\'‘’].+[\"“”\'‘’]%]%]') then -- leading and trailing quote marks | ||
str = utilities.substitute (cfg.presentation['kern- | str = utilities.substitute (cfg.presentation['kern-left'], str); | ||
str = utilities.substitute (cfg.presentation['kern-right'], str); | |||
elseif mw.ustring.match (str, '%[%[[\"“”\'‘’].+%]%]') then -- leading quote marks | elseif mw.ustring.match (str, '%[%[[\"“”\'‘’].+%]%]') then -- leading quote marks | ||
str = utilities.substitute (cfg.presentation['kern | str = utilities.substitute (cfg.presentation['kern-left'], str); | ||
elseif mw.ustring.match (str, '%[%[.+[\"“”\'‘’]%]%]') then -- trailing quote marks | elseif mw.ustring.match (str, '%[%[.+[\"“”\'‘’]%]%]') then -- trailing quote marks | ||
str = utilities.substitute (cfg.presentation['kern | str = utilities.substitute (cfg.presentation['kern-right'], str); | ||
end | end | ||
Line 491: | Line 487: | ||
label = mw.ustring.gsub (label, '[‘’]', '\''); -- replace ‘’ (U+2018 & U+2019) with ' (typewriter single quote mark) | label = mw.ustring.gsub (label, '[‘’]', '\''); -- replace ‘’ (U+2018 & U+2019) with ' (typewriter single quote mark) | ||
cap | cap = mw.ustring.match (label, "^([\"\'][^\'].+)"); -- match leading double or single quote but not doubled single quotes (italic markup) | ||
if utilities.is_set (cap) then | if utilities.is_set (cap) then | ||
label = utilities.substitute (cfg.presentation['kern-left'], | label = utilities.substitute (cfg.presentation['kern-left'], cap); | ||
end | end | ||
cap | cap = mw.ustring.match (label, "^(.+[^\'][\"\'])$") -- match trailing double or single quote but not doubled single quotes (italic markup) | ||
if utilities.is_set (cap) then | if utilities.is_set (cap) then | ||
label = utilities.substitute (cfg.presentation['kern-right'], | label = utilities.substitute (cfg.presentation['kern-right'], cap); | ||
end | end | ||
Line 541: | Line 537: | ||
lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*'); -- get the language prefix or nil if there is no script | lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*'); -- get the language prefix or nil if there is no script | ||
if not utilities.is_set (lang) then | if not utilities.is_set (lang) then | ||
utilities.set_message ('err_script_parameter', {script_param, 'missing title part'}); -- prefix without 'title'; add error message | utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']}); -- prefix without 'title'; add error message | ||
return ''; -- script_value was just the prefix so return empty string | return ''; -- script_value was just the prefix so return empty string | ||
end | end | ||
Line 552: | Line 548: | ||
utilities.add_prop_cat ('script', {name, lang}) | utilities.add_prop_cat ('script', {name, lang}) | ||
else | else | ||
utilities.set_message ('err_script_parameter', {script_param, 'unknown language code'}); -- unknown script-language; add error message | utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']}); -- unknown script-language; add error message | ||
end | end | ||
lang = ' lang="' .. lang .. '" '; -- convert prefix into a lang attribute | lang = ' lang="' .. lang .. '" '; -- convert prefix into a lang attribute | ||
else | else | ||
utilities.set_message ('err_script_parameter', {script_param, 'invalid language code'}); -- invalid language code; add error message | utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']}); -- invalid language code; add error message | ||
lang = ''; -- invalid so set lang to empty string | lang = ''; -- invalid so set lang to empty string | ||
end | end | ||
else | else | ||
utilities.set_message ('err_script_parameter', {script_param, 'missing prefix'}); -- no language code prefix; add error message | utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']}); -- no language code prefix; add error message | ||
end | end | ||
script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value}); -- isolate in case script is RTL | script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value}); -- isolate in case script is RTL | ||
Line 570: | Line 566: | ||
--[[--------------------------< S C R I P T _ C O N C A T E N A T E >------------------------------------------ | --[[--------------------------< S C R I P T _ C O N C A T E N A T E >------------------------------------------ | ||
Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been | Initially for |title= and |script-title=, this function concatenates those two parameter values after the script | ||
wrapped in <bdi> tags. | value has been wrapped in <bdi> tags. | ||
]] | ]] | ||
Line 775: | Line 772: | ||
if mw.ustring.find (v, cfg.indic_script) then -- it's ok if one of the Indic scripts | if mw.ustring.find (v, cfg.indic_script) then -- it's ok if one of the Indic scripts | ||
position = nil; -- unset position | position = nil; -- unset position | ||
elseif cfg. | elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then -- is zwj followed by a character listed in emoji{}? | ||
position = nil; -- unset position | position = nil; -- unset position | ||
end | end | ||
Line 897: | Line 894: | ||
return cfg.title_types [cite_class] or ''; -- set template's default title type; else empty string for concatenation | return cfg.title_types [cite_class] or ''; -- set template's default title type; else empty string for concatenation | ||
end | end | ||
Line 1,046: | Line 983: | ||
--[[--------------------------< I S _ S U F F I X >----------------------------- | --[[--------------------------< I S _ S U F F I X >----------------------------- | ||
returns true | returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9. | ||
Puncutation not allowed. | Puncutation not allowed. | ||
Line 1,179: | Line 1,116: | ||
--[[--------------------------< | --[[--------------------------< I N T E R W I K I _ P R E F I X E N _ G E T >---------------------------------- | ||
extract interwiki prefixen from <value>. Returns two one or two values: | |||
false – no prefixen | |||
nil – prefix exists but not recognized | |||
project prefix, language prefix – when value has either of: | |||
:<project>:<language>:<article> | |||
:<language>:<project>:<article> | |||
project prefix, nil – when <value> has only a known single-letter prefix | |||
nil, language prefix – when <value> has only a known language prefix | |||
accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this | |||
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and | |||
v (wikiversity)) are not supported. | |||
]] | ]] | ||
local function list_people (control, people, etal) | local function interwiki_prefixen_get (value, is_link) | ||
if not value:find (':%l+:') then -- if no prefix | |||
return false; -- abandon; boolean here to distinguish from nil fail returns later | |||
end | |||
local prefix_patterns_linked_t = { -- sequence of valid interwiki and inter project prefixen | |||
'^%[%[:([dsw]):(%l%l+):', -- wikilinked; project and language prefixes | |||
'^%[%[:(%l%l+):([dsw]):', -- wikilinked; language and project prefixes | |||
'^%[%[:([dsw]):', -- wikilinked; project prefix | |||
'^%[%[:(%l%l+):', -- wikilinked; language prefix | |||
} | |||
local prefix_patterns_unlinked_t = { -- sequence of valid interwiki and inter project prefixen | |||
'^:([dsw]):(%l%l+):', -- project and language prefixes | |||
'^:(%l%l+):([dsw]):', -- language and project prefixes | |||
'^:([dsw]):', -- project prefix | |||
'^:(%l%l+):', -- language prefix | |||
} | |||
local cap1, cap2; | |||
for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do | |||
cap1, cap2 = value:match (pattern); | |||
if cap1 then | |||
break; -- found a match so stop looking | |||
end | |||
end | |||
if cap1 and cap2 then -- when both then :project:language: or :language:project: (both forms allowed) | |||
if 1 == #cap1 then -- length == 1 then :project:language: | |||
if cfg.inter_wiki_map[cap2] then -- is language prefix in the interwiki map? | |||
return cap1, cap2; -- return interwiki project and interwiki language | |||
end | |||
else -- here when :language:project: | |||
if cfg.inter_wiki_map[cap1] then -- is language prefix in the interwiki map? | |||
return cap2, cap1; -- return interwiki project and interwiki language | |||
end | |||
end | |||
return nil; -- unknown interwiki language | |||
elseif not (cap1 or cap2) then -- both are nil? | |||
return nil; -- we got something that looks like a project prefix but isn't; return fail | |||
elseif 1 == #cap1 then -- here when one capture | |||
return cap1, nil; -- length is 1 so return project, nil language | |||
else -- here when one capture and its length it more than 1 | |||
if cfg.inter_wiki_map[cap1] then -- is language prefix in the interwiki map? | |||
return nil, cap1; -- return nil project, language | |||
end | |||
end | |||
end | |||
--[[--------------------------< L I S T _ P E O P L E >-------------------------- | |||
Formats a list of people (authors, contributors, editors, interviewers, translators) | |||
names in the list will be linked when | |||
|<name>-link= has a value | |||
|<name>-mask- does NOT have a value; masked names are presumed to have been | |||
rendered previously so should have been linked there | |||
when |<name>-mask=0, the associated name is not rendered | |||
]] | |||
local function list_people (control, people, etal) | |||
local sep; | local sep; | ||
local namesep; | local namesep; | ||
Line 1,246: | Line 1,250: | ||
one = utilities.make_wikilink (person.link, one); -- link author/editor | one = utilities.make_wikilink (person.link, one); -- link author/editor | ||
end | end | ||
if one then -- if <one> has a value (name, mdash replacement, or mask text replacement) | if one then -- if <one> has a value (name, mdash replacement, or mask text replacement) | ||
local proj, tag = interwiki_prefixen_get (one, true); -- get the interwiki prefixen if present | |||
if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then | |||
proj = nil; -- for stuff like :w:de:<article>, :w is unnecessary TODO: maint cat? | |||
end | |||
if proj then | |||
proj = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj]; -- :w (wikipedia) for linking from a non-wikipedia project | |||
if proj then | |||
one = one .. utilities.wrap_style ('interproj', proj); -- add resized leading space, brackets, static text, language name | |||
tag = nil; -- unset; don't do both project and language | |||
end | |||
end | |||
if tag == cfg.this_wiki_code then | |||
tag = nil; -- stuff like :en:<article> at en.wiki is pointless TODO: maint cat? | |||
end | |||
if tag then | |||
local lang = cfg.lang_code_remap[tag] or cfg.mw_languages_by_tag_t[tag]; | |||
if lang then -- error messaging done in extract_names() where we know parameter names | |||
one = one .. utilities.wrap_style ('interwiki', lang); -- add resized leading space, brackets, static text, language name | |||
end | |||
end | |||
table.insert (name_list, one); -- add it to the list of names | table.insert (name_list, one); -- add it to the list of names | ||
table.insert (name_list, sep_one); -- add the proper name-list separator | table.insert (name_list, sep_one); -- add the proper name-list separator | ||
Line 1,276: | Line 1,303: | ||
return result, count; -- return name-list string and count of number of names (count used for editor names only) | return result, count; -- return name-list string and count of number of names (count used for editor names only) | ||
end | end | ||
--[[--------------------< M A K E _ C I T E R E F _ I D >----------------------- | --[[--------------------< M A K E _ C I T E R E F _ I D >----------------------- | ||
Line 1,380: | Line 1,408: | ||
--[[ | --[[-----------------< N A M E _ H A S _ M U L T _ N A M E S >------------------ | ||
Evaluates the content of last/surname (authors etc.) parameters for multiple names. | |||
Evaluates the content of last/surname (authors etc.) parameters for multiple names. | |||
Multiple names are indicated if there is more than one comma or any "unescaped" | Multiple names are indicated if there is more than one comma or any "unescaped" | ||
semicolons. Escaped semicolons are ones used as part of selected HTML entities. | semicolons. Escaped semicolons are ones used as part of selected HTML entities. | ||
Line 1,438: | Line 1,441: | ||
--[[ | --[=[-------------------------< I S _ G E N E R I C >---------------------------------------------------------- | ||
Compares values assigned to various | Compares values assigned to various parameters according to the string provided as <item> in the function call. | ||
'generic_names': |last=, |first=, |editor-last=, etc | <item> can have on of two values: | ||
'generic_titles' | 'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc | ||
'generic_titles' – for |title= | |||
The | There are two types of generic tests. The 'accept' tests look for a pattern that should not be rejected by the | ||
' | 'reject' test. For example, | ||
|author=[[John Smith (author)|Smith, John]] | |||
would be rejected by the 'author' reject test. But piped wikilinks with 'author' disambiguation should not be | |||
rejected so the 'accept' test prevents that from happening. Accept tests are always performed before reject | |||
tests. | |||
Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local']) | |||
that each can hold a test sequence table The sequence table holds, at index [1], a test pattern, and, at index | |||
[2], a boolean control value. The control value tells string.find() or mw.ustring.find() to do plain-text search (true) | |||
or a pattern search (false). The intent of all this complexity is to make these searches as fast as possible so | or a pattern search (false). The intent of all this complexity is to make these searches as fast as possible so | ||
that we don't run out of processing time on very large articles. | that we don't run out of processing time on very large articles. | ||
]] | Returns | ||
true when a reject test finds the pattern or string | |||
false when an accept test finds the pattern or string | |||
nil else | |||
]=] | |||
local function is_generic (item, value, wiki) | |||
local test_val; | |||
local str_lower = { -- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local']) | |||
['en'] = string.lower, | |||
['local'] = mw.ustring.lower, | |||
} | |||
local str_find = { -- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local']) | |||
['en'] = string.find, | |||
['local'] = mw.ustring.find, | |||
} | |||
local function test (val, test_t, wiki) -- local function to do the testing; <wiki> selects lower() and find() functions | |||
val = test_t[2] and str_lower[wiki](value) or val; -- when <test_t[2]> set to 'true', plaintext search using lowercase value | |||
return str_find[wiki] (val, test_t[1], 1, test_t[2]); -- return nil when not found or matched | |||
end | |||
local test_types_t = {'accept', 'reject'}; -- test accept patterns first, then reject patterns | |||
local wikis_t = {'en', 'local'}; -- do tests for each of these keys; en.wiki first, local.wiki second | |||
for _, test_type in ipairs (test_types_t) do -- for each test type | |||
for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do -- spin through the list of generic value fragments to accept or reject | |||
for _, wiki in ipairs (wikis_t) do | |||
if generic_value[wiki] then | |||
if test (value, generic_value[wiki], wiki) then -- go do the test | |||
return ('reject' == test_type); -- param value rejected, return true; false else | |||
end | |||
end | |||
end | end | ||
end | end | ||
Line 1,468: | Line 1,502: | ||
--[[--------------------------< N A M E _ I S _ G E N E R I C >------------------------------------------------ | --[[--------------------------< N A M E _ I S _ G E N E R I C >------------------------------------------------ | ||
calls is_generic() to determine if <name> is a 'generic name' listed in cfg.generic_names; <name_alias> is the | |||
parameter name used in error messaging | |||
]] | ]] | ||
Line 1,493: | Line 1,530: | ||
if not accept_name then -- <last> not wrapped in accept-as-written markup | if not accept_name then -- <last> not wrapped in accept-as-written markup | ||
name_has_mult_names (last, list_name); -- check for multiple names in the parameter (last only) | name_has_mult_names (last, list_name); -- check for multiple names in the parameter (last only) | ||
name_is_numeric (last, list_name); -- check for names that are composed of digits and punctuation | name_is_numeric (last, list_name); -- check for names that are composed of digits and punctuation | ||
name_is_generic (last, last_alias); -- check for names found in the generic names list | name_is_generic (last, last_alias); -- check for names found in the generic names list | ||
Line 1,503: | Line 1,539: | ||
if not accept_name then -- <first> not wrapped in accept-as-written markup | if not accept_name then -- <first> not wrapped in accept-as-written markup | ||
name_is_numeric (first, list_name); -- check for names that are composed of digits and punctuation | name_is_numeric (first, list_name); -- check for names that are composed of digits and punctuation | ||
name_is_generic (first, first_alias); -- check for names found in the generic names list | name_is_generic (first, first_alias); -- check for names found in the generic names list | ||
Line 1,519: | Line 1,554: | ||
--[[----------------------< E X T R A C T _ N A M E S >------------------------- | --[[----------------------< E X T R A C T _ N A M E S >------------------------- | ||
Gets name list from the input arguments | Gets name list from the input arguments | ||
Line 1,556: | Line 1,592: | ||
link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ); | link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ); | ||
mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i ); | mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i ); | ||
if last then -- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name | |||
local project, language = interwiki_prefixen_get (last, true); -- true because we expect interwiki links in |lastn= to be wikilinked | |||
if nil == project and nil == language then -- when both are nil | |||
utilities.set_message ('err_bad_paramlink', last_alias); -- not known, emit an error message -- TODO: err_bad_interwiki? | |||
last = utilities.remove_wiki_link (last); -- remove wikilink markup; show display value only | |||
end | |||
end | |||
if link then -- error check |linkn= alias for unknown interwiki link prefix | |||
local project, language = interwiki_prefixen_get (link, false); -- false because wiki links in |author-linkn= is an error | |||
if nil == project and nil == language then -- when both are nil | |||
utilities.set_message ('err_bad_paramlink', link_alias); -- not known, emit an error message -- TODO: err_bad_interwiki? | |||
link = nil; -- unset so we don't link | |||
link_alias = nil; | |||
end | |||
end | |||
last, etal = name_has_etal (last, etal, false, last_alias); -- find and remove variations on et al. | last, etal = name_has_etal (last, etal, false, last_alias); -- find and remove variations on et al. | ||
first, etal = name_has_etal (first, etal, false, first_alias); -- find and remove variations on et al. | first, etal = name_has_etal (first, etal, false, first_alias); -- find and remove variations on et al. | ||
Line 1,594: | Line 1,647: | ||
--[[---------------------< | --[[--------------------------< N A M E _ T A G _ G E T >------------------------------------------------------ | ||
attempt to decode |language=<lang_param> and return language name and matching tag; nil else. | |||
This function looks for: | |||
<lang_param> as a tag in cfg.lang_code_remap{} | |||
<lang_param> as a name in cfg.lang_name_remap{} | |||
<lang_param> as a name in cfg.mw_languages_by_name_t | |||
<lang_param> as a tag in cfg.mw_languages_by_tag_t | |||
when those fail, presume that <lang_param> is an IETF-like tag that MediaWiki does not recognize. Strip all | |||
script, region, variant, whatever subtags from <lang_param> to leave just a two or three character language tag | |||
and look for the new <lang_param> in cfg.mw_languages_by_tag_t{} | |||
on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil | |||
]] | |||
local function name_tag_get (lang_param) | |||
local lang_param_lc = mw.ustring.lower (lang_param); -- use lowercase as an index into the various tables | |||
local name; | |||
local tag; | |||
name = cfg.lang_code_remap[lang_param_lc]; -- assume <lang_param_lc> is a tag; attempt to get remapped language name | |||
if name then -- when <name>, <lang_param> is a tag for a remapped language name | |||
return name, lang_param_lc; -- so return <name> from remap and <lang_param_lc> | |||
end | |||
] | tag = lang_param_lc:match ('^(%a%a%a?)%-.*'); -- still assuming that <lang_param_lc> is a tag; strip script, region, variant subtags | ||
name = cfg.lang_code_remap[tag]; -- attempt to get remapped language name with language subtag only | |||
if name then -- when <name>, <tag> is a tag for a remapped language name | |||
return name, tag; -- so return <name> from remap and <tag> | |||
end | |||
if cfg.lang_name_remap[lang_param_lc] then -- not a tag, assume <lang_param_lc> is a name; attempt to get remapped language tag | |||
if cfg.lang_name_remap[ | return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2]; -- for this <lang_param_lc>, return a (possibly) new name and appropriate tag | ||
return cfg.lang_name_remap[ | |||
end | end | ||
tag = cfg.mw_languages_by_name_t[lang_param_lc]; -- assume that <lang_param_lc> is a language name; attempt to get its matching tag | |||
if tag then | |||
return cfg.mw_languages_by_tag_t[tag], tag; -- <lang_param_lc> is a name so return the name from the table and <tag> | |||
end | |||
name = cfg.mw_languages_by_tag_t[lang_param_lc]; -- assume that <lang_param_lc> is a tag; attempt to get its matching language name | |||
if name then | |||
return name, lang_param_lc; -- <lang_param_lc> is a tag so return it and <name> | |||
end | |||
tag = lang_param_lc:match ('^(%a%a%a?)%-.*'); -- is <lang_param_lc> an IETF-like tag that MediaWiki doesn't recognize? <tag> gets the language subtag; nil else | |||
if tag then | |||
name = cfg.mw_languages_by_tag_t[tag]; -- attempt to get a language name using the shortened <tag> | |||
if name then | |||
return name, tag; -- <lang_param_lc> is an unrecognized IETF-like tag so return <name> and language subtag | |||
end | end | ||
end | end | ||
end | end | ||
Line 1,672: | Line 1,730: | ||
local function language_parameter (lang) | local function language_parameter (lang) | ||
local | local tag; -- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags | ||
local lang_subtag; -- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag | |||
local name; -- the language name | local name; -- the language name | ||
local language_list = {}; -- table of language names to be rendered | local language_list = {}; -- table of language names to be rendered | ||
local | local names_t = {}; -- table made from the value assigned to |language= | ||
local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code); -- get this wiki's language name | local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code); -- get this wiki's language name | ||
names_t = mw.text.split (lang, '%s*,%s*'); -- names should be a comma separated list | |||
for _, lang in ipairs ( | for _, lang in ipairs (names_t) do -- reuse lang here because we don't yet know if lang is a language name or a language tag | ||
name = | name, tag = name_tag_get (lang); -- attempt to get name/tag pair for <lang>; <name> has proper capitalization; <tag> is lowercase | ||
if | if utilities.is_set (tag) then | ||
lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1'); -- for categorization, strip any IETF-like tags from language tag | |||
if cfg.this_wiki_code ~= | if cfg.this_wiki_code ~= lang_subtag then -- when the language is not the same as this wiki's language | ||
if 2 == | if 2 == lang_subtag:len() then -- and is a two-character tag | ||
utilities.add_prop_cat ('foreign-lang-source', {name, | utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag); -- categorize it; tag appended to allow for multiple language categorization | ||
else -- or is a recognized language (but has a three-character | else -- or is a recognized language (but has a three-character tag) | ||
utilities.add_prop_cat ('foreign-lang-source-2', { | utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag); -- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template? | ||
end | end | ||
elseif cfg.local_lang_cat_enable then -- when the language and this wiki's language are the same and categorization is enabled | elseif cfg.local_lang_cat_enable then -- when the language and this wiki's language are the same and categorization is enabled | ||
utilities.add_prop_cat ('local-lang-source', {name, | utilities.add_prop_cat ('local-lang-source', {name, lang_subtag}); -- categorize it | ||
end | end | ||
else | else | ||
name = lang; -- return whatever <lang> has so that we show something | |||
utilities.set_message ('maint_unknown_lang'); -- add maint category if not already added | utilities.set_message ('maint_unknown_lang'); -- add maint category if not already added | ||
end | end | ||
Line 1,722: | Line 1,765: | ||
name = utilities.make_sep_list (#language_list, language_list); | name = utilities.make_sep_list (#language_list, language_list); | ||
if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then -- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English' | |||
if | |||
return ''; -- if one language and that language is this wiki's return an empty string (no annotation) | return ''; -- if one language and that language is this wiki's return an empty string (no annotation) | ||
end | end | ||
Line 1,731: | Line 1,773: | ||
]] | ]] | ||
end | end | ||
--[[-----------------------< S E T _ C S _ S T Y L E >-------------------------- | --[[-----------------------< S E T _ C S _ S T Y L E >-------------------------- | ||
Gets the default CS style configuration for the given mode. | Gets the default CS style configuration for the given mode. | ||
Returns default separator and either postscript as passed in or the default. | Returns default separator and either postscript as passed in or the default. | ||
In CS1, the default postscript and separator are '.'. | In CS1, the default postscript and separator are '.'. | ||
In CS2, the default postscript is the empty string and the default separator is ','. | In CS2, the default postscript is the empty string and the default separator is ','. | ||
]] | ]] | ||
local function set_cs_style (postscript, mode) | local function set_cs_style (postscript, mode) | ||
if utilities.is_set(postscript) then | if utilities.is_set(postscript) then | ||
Line 1,750: | Line 1,796: | ||
return cfg.presentation['sep_' .. mode], postscript; | return cfg.presentation['sep_' .. mode], postscript; | ||
end | end | ||
--[[--------------------------< S E T _ S T Y L E >----------------------------- | --[[--------------------------< S E T _ S T Y L E >----------------------------- | ||
Sets the separator and postscript styles. Checks the |mode= first and the | Sets the separator and postscript styles. Checks the |mode= first and the | ||
#invoke CitationClass second. Removes the postscript if postscript == none. | #invoke CitationClass second. Removes the postscript if postscript == none. | ||
]] | ]] | ||
local function set_style (mode, postscript, cite_class) | local function set_style (mode, postscript, cite_class) | ||
local sep; | local sep; | ||
Line 1,837: | Line 1,887: | ||
inputs: | inputs: | ||
max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal | max: A['DisplayAuthors'] or A['DisplayEditors'], etc; a number or some flavor of etal | ||
count: #a or #e | count: #a or #e | ||
list_name: 'authors' or 'editors' | list_name: 'authors' or 'editors' | ||
etal: author_etal or editor_etal | etal: author_etal or editor_etal | ||
This function sets an error message when |display-xxxxors= value greater than or equal to number of names but | |||
not when <max> comes from {{cs1 config}} global settings. When using global settings, <param> is set to the | |||
keyword 'cs1 config' which is used to supress the normal error. Error is suppressed because it is to be expected | |||
that some citations in an article will have the same or fewer names that the limit specified in {{cs1 config}}. | |||
]] | ]] | ||
Line 1,851: | Line 1,906: | ||
elseif max:match ('^%d+$') then -- if is a string of numbers | elseif max:match ('^%d+$') then -- if is a string of numbers | ||
max = tonumber (max); -- make it a number | max = tonumber (max); -- make it a number | ||
if max >= count then | if (max >= count) and ('cs1 config' ~= param) then -- error when local |display-xxxxors= value greater than or equal to number of names; not an error when using global setting | ||
utilities.set_message ('err_disp_name', {param, max}); -- add error message | utilities.set_message ('err_disp_name', {param, max}); -- add error message | ||
max = nil; | max = nil; | ||
end | end | ||
else -- not a valid keyword or number | else -- not a valid keyword or number | ||
utilities.set_message ('err_disp_name', {param, max}); | utilities.set_message ('err_disp_name', {param, max}); -- add error message | ||
max = nil; -- unset; as if |display-xxxxors= had not been set | max = nil; -- unset; as if |display-xxxxors= had not been set | ||
end | end | ||
Line 2,154: | Line 2,209: | ||
--[[-------------------------< F O R M A T _ V O L U M E _ I S S U E >---------------------------------------- | --[[-------------------------< F O R M A T _ V O L U M E _ I S S U E >----------------------------------------- | ||
returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume | returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single | ||
or formatted issue, or an empty string if neither are set. | string; or formatted volume or formatted issue, or an empty string if neither are set. | ||
]] | ]] | ||
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower) | local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower) | ||
if not utilities.is_set (volume) and not utilities.is_set (issue) then | if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then | ||
return ''; | return ''; | ||
end | end | ||
-- same condition as in format_pages_sheets() | |||
local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin); | |||
local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')); -- is only uppercase roman numerals or only digits? | |||
local is_long_vol = volume and (4 < mw.ustring.len(volume)); -- is |volume= value longer than 4 characters? | |||
if | if volume and (not is_numeric_vol and is_long_vol) then -- when not all digits or Roman numerals, is |volume= longer than 4 characters? | ||
if utilities.is_set (volume | utilities.add_prop_cat ('long-vol'); -- yes, add properties cat | ||
end | |||
if is_journal then -- journal-style formatting | |||
local vol = ''; | |||
if utilities.is_set (volume) then | |||
if is_numeric_vol then -- |volume= value all digits or all uppercase Roman numerals? | |||
vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume}); -- render in bold face | |||
elseif is_long_vol then -- not all digits or Roman numerals; longer than 4 characters? | |||
vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)}); -- not bold | |||
else -- four or fewer characters | |||
vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)}); -- bold | |||
end | |||
end | end | ||
vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '') | |||
vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '') | |||
return vol; | |||
end | end | ||
if 'podcast' == cite_class and utilities.is_set (issue) then | if 'podcast' == cite_class and utilities.is_set (issue) then | ||
return wrap_msg ('issue', {sepc, issue}, lower); | return wrap_msg ('issue', {sepc, issue}, lower); | ||
end | end | ||
if 'conference' == cite_class and utilities.is_set (article) then -- |article-number= supported only in journal and conference cites | |||
if utilities.is_set (volume) and utilities.is_set (article) then -- both volume and article number | |||
return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower); | |||
elseif utilities.is_set (article) then -- article number alone; when volume alone, handled below | |||
return wrap_msg ('art', {sepc, article}, lower); | |||
end | end | ||
end | end | ||
if utilities.is_set (issue) then | |||
return vol .. utilities. | -- all other types of citation | ||
if utilities.is_set (volume) and utilities.is_set (issue) then | |||
return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower); | |||
elseif utilities.is_set (volume) then | |||
return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower); | |||
else | |||
return wrap_msg ('issue', {sepc, issue}, lower); | |||
end | end | ||
end | end | ||
Line 2,355: | Line 2,427: | ||
for timestamp errors when the timestamp has a wildcard, return the URL unmodified | for timestamp errors when the timestamp has a wildcard, return the URL unmodified | ||
for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/) | for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/) | ||
A secondary function is to return an archive-url timestamp from those urls that have them (archive.org and | |||
archive.today). The timestamp is used by validation.archive_date_check() to see if the value in |archive-date= | |||
matches the timestamp in the archive url. | |||
]=] | ]=] | ||
Line 2,362: | Line 2,438: | ||
local path, timestamp, flag; -- portions of the archive.org URL | local path, timestamp, flag; -- portions of the archive.org URL | ||
timestamp = url:match ('//archive.today/(%d%d%d%d%d%d%d%d%d%d%d%d%d%d)/'); -- get timestamp from archive.today urls | |||
if timestamp then -- if this was an archive.today url ... | |||
return url, date, timestamp; -- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=, and done | |||
end | |||
-- here for archive.org urls | |||
if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then -- also deprecated liveweb Wayback machine URL | if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then -- also deprecated liveweb Wayback machine URL | ||
return url, date; -- not an archive.org archive, return ArchiveURL and ArchiveDate | return url, date; -- not an archive.org archive, return ArchiveURL and ArchiveDate | ||
Line 2,391: | Line 2,472: | ||
err_msg = cfg.err_msg_supl.flag; | err_msg = cfg.err_msg_supl.flag; | ||
else | else | ||
return url, date; | return url, date, timestamp; -- return ArchiveURL, ArchiveDate, and timestamp from |archive-url= | ||
end | end | ||
end | end | ||
Line 2,398: | Line 2,479: | ||
if is_preview_mode then | if is_preview_mode then | ||
return url, date; | return url, date, timestamp; -- preview mode so return ArchiveURL, ArchiveDate, and timestamp from |archive-url= | ||
else | else | ||
return '', ''; -- return empty strings for ArchiveURL and ArchiveDate | return '', ''; -- return empty strings for ArchiveURL and ArchiveDate | ||
Line 2,465: | Line 2,546: | ||
local a = {}; -- authors list from |lastn= / |firstn= pairs or |vauthors= | local a = {}; -- authors list from |lastn= / |firstn= pairs or |vauthors= | ||
local Authors; | local Authors; | ||
local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], ''); | local NameListStyle; | ||
if cfg.global_cs1_config_t['NameListStyle'] then -- global setting in {{cs1 config}} overrides local |name-list-style= parameter value; nil when empty or assigned value invalid | |||
NameListStyle = is_valid_parameter_value (cfg.global_cs1_config_t['NameListStyle'], 'cs1 config: name-list-style', cfg.keywords_lists['name-list-style'], ''); -- error messaging 'param' here is a hoax | |||
else | |||
NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], ''); | |||
end | |||
if cfg.global_cs1_config_t['NameListStyle'] and utilities.is_set (A['NameListStyle']) then -- when template has |name-list-style=<something> which global setting has overridden | |||
utilities.set_message ('maint_overridden_setting'); -- set a maint message | |||
end | |||
local Collaboration = A['Collaboration']; | local Collaboration = A['Collaboration']; | ||
Line 2,474: | Line 2,565: | ||
elseif 2 == selected then | elseif 2 == selected then | ||
NameListStyle = 'vanc'; -- override whatever |name-list-style= might be | NameListStyle = 'vanc'; -- override whatever |name-list-style= might be | ||
a, author_etal = parse_vauthors_veditors (args, | a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList'); -- fetch author list from |vauthors=, |author-linkn=, and |author-maskn= | ||
elseif 3 == selected then | elseif 3 == selected then | ||
Authors = A['Authors']; -- use content of |authors= | Authors = A['Authors']; -- use content of |authors= | ||
Line 2,559: | Line 2,650: | ||
if 'mailinglist' == config.CitationClass then -- special case for {{cite mailing list}} | if 'mailinglist' == config.CitationClass then -- special case for {{cite mailing list}} | ||
if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then -- both set emit an error TODO: make a function for this and similar? | if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then -- both set emit an error TODO: make a function for this and similar? | ||
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' | utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')}); | ||
end | end | ||
Line 2,582: | Line 2,673: | ||
if 'citation' == config.CitationClass then | if 'citation' == config.CitationClass then | ||
if utilities.is_set (Periodical) then | if utilities.is_set (Periodical) then | ||
if not utilities.in_array (Periodical_origin, | if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then -- {{citation}} does not render |volume= when these parameters are used | ||
Volume = A['Volume']; -- but does for all other 'periodicals' | Volume = A['Volume']; -- but does for all other 'periodicals' | ||
end | end | ||
Line 2,599: | Line 2,690: | ||
local Issue; | local Issue; | ||
if 'citation' == config.CitationClass then | if 'citation' == config.CitationClass then | ||
if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, | if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then -- {{citation}} may render |issue= when these parameters are used | ||
utilities. | Issue = utilities.hyphen_to_dash (A['Issue']); | ||
end | end | ||
elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then -- conference & map books do not support issue; {{citation}} listed here because included in settings table | elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then -- conference & map books do not support issue; {{citation}} listed here because included in settings table | ||
if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then | if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then | ||
Issue = hyphen_to_dash (A['Issue']); | Issue = utilities.hyphen_to_dash (A['Issue']); | ||
end | end | ||
end | end | ||
local ArticleNumber; | |||
if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then | |||
ArticleNumber = A['ArticleNumber']; | |||
end | |||
extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i'); | extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i'); | ||
Line 2,613: | Line 2,710: | ||
local Pages; | local Pages; | ||
local At; | local At; | ||
if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then | local QuotePage; | ||
local QuotePages; | |||
if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then -- TODO: rewrite to emit ignored parameter error message? | |||
Page = A['Page']; | Page = A['Page']; | ||
Pages = hyphen_to_dash (A['Pages']); | Pages = utilities.hyphen_to_dash (A['Pages']); | ||
At = A['At']; | At = A['At']; | ||
QuotePage = A['QuotePage']; | |||
QuotePages = utilities.hyphen_to_dash (A['QuotePages']); | |||
end | end | ||
Line 2,670: | Line 2,771: | ||
-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories | -- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories | ||
if not utilities.is_set (no_tracking_cats) then -- ignore if we are already not going to categorize this page | if not utilities.is_set (no_tracking_cats) then -- ignore if we are already not going to categorize this page | ||
if | if cfg.uncategorized_namespaces[this_page.namespace] then -- is this page's namespace id one of the uncategorized namespace ids? | ||
no_tracking_cats = "true"; -- set no_tracking_cats | no_tracking_cats = "true"; -- set no_tracking_cats | ||
end | end | ||
Line 2,735: | Line 2,836: | ||
if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then | if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then | ||
if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then -- when both set emit an error TODO: make a function for this and similar? | if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then -- when both set emit an error TODO: make a function for this and similar? | ||
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' | utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Periodical_origin)}); | ||
end | end | ||
Line 2,781: | Line 2,882: | ||
ID = A['Number']; -- yes, use it | ID = A['Number']; -- yes, use it | ||
else -- ID has a value so emit error message | else -- ID has a value so emit error message | ||
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' | utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')}); | ||
end | end | ||
end | end | ||
Line 2,814: | Line 2,915: | ||
-- CS1/2 mode | -- CS1/2 mode | ||
local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], ''); | local Mode; | ||
if cfg.global_cs1_config_t['Mode'] then -- global setting in {{cs1 config}} overrides local |mode= parameter value; nil when empty or assigned value invalid | |||
Mode = is_valid_parameter_value (cfg.global_cs1_config_t['Mode'], 'cs1 config: mode', cfg.keywords_lists['mode'], ''); -- error messaging 'param' here is a hoax | |||
else | |||
Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], ''); | |||
end | |||
if cfg.global_cs1_config_t['Mode'] and utilities.is_set (A['Mode']) then -- when template has |mode=<something> which global setting has overridden | |||
utilities.set_message ('maint_overridden_setting'); -- set a maint message | |||
end | |||
-- separator character and postscript | -- separator character and postscript | ||
local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass); | local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass); | ||
Line 2,826: | Line 2,937: | ||
local Sheets = A['Sheets'] or ''; | local Sheets = A['Sheets'] or ''; | ||
if config.CitationClass == "map" then | if config.CitationClass == "map" then | ||
if utilities.is_set (Chapter) then --TODO: make a function for this and similar? | if utilities.is_set (Chapter) then --TODO: make a function for this and similar? | ||
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' | utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)}); -- add error message | ||
end | end | ||
Chapter = A['Map']; | Chapter = A['Map']; | ||
Line 2,870: | Line 2,981: | ||
if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then -- these are mutually exclusive so if both are set TODO: make a function for this and similar? | if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then -- these are mutually exclusive so if both are set TODO: make a function for this and similar? | ||
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' | utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')}); -- add error message | ||
SeriesNumber = ''; -- unset; prefer |season= over |seriesno= | SeriesNumber = ''; -- unset; prefer |season= over |seriesno= | ||
end | end | ||
Line 2,887: | Line 2,998: | ||
ChapterUrlAccess = UrlAccess; | ChapterUrlAccess = UrlAccess; | ||
ChapterURL_origin = URL_origin; | ChapterURL_origin = URL_origin; | ||
ChapterFormat = Format; | |||
Title = Series; -- promote series to title | Title = Series; -- promote series to title | ||
TitleLink = SeriesLink; | TitleLink = SeriesLink; | ||
Line 2,900: | Line 3,012: | ||
TransTitle = ''; | TransTitle = ''; | ||
ScriptTitle = ''; | ScriptTitle = ''; | ||
Format = ''; | |||
else -- now oddities that are cite serial | else -- now oddities that are cite serial | ||
Line 2,964: | Line 3,077: | ||
local ArchiveDate; | local ArchiveDate; | ||
local ArchiveFormat = A['ArchiveFormat']; | local ArchiveFormat = A['ArchiveFormat']; | ||
local archive_url_timestamp; -- timestamp from wayback machine url | |||
ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate']) | |||
ArchiveURL, ArchiveDate, archive_url_timestamp = archive_url_check (A['ArchiveURL'], A['ArchiveDate']) | |||
ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url'); | ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url'); | ||
ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate); -- add error message when URL or ChapterURL == ArchiveURL | ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate); -- add error message when URL or ChapterURL == ArchiveURL | ||
local AccessDate = A['AccessDate']; | local AccessDate = A['AccessDate']; | ||
local LayDate = A['LayDate']; | local LayDate = A['LayDate']; | ||
Line 3,029: | Line 3,142: | ||
LayDate = date_parameters_list['lay-date'].val; | LayDate = date_parameters_list['lay-date'].val; | ||
PublicationDate = date_parameters_list['publication-date'].val; | PublicationDate = date_parameters_list['publication-date'].val; | ||
end | |||
if archive_url_timestamp and utilities.is_set (ArchiveDate) then | |||
validation.archive_date_check (ArchiveDate, archive_url_timestamp); -- does YYYYMMDD in archive_url_timestamp match date in ArchiveDate | |||
end | end | ||
else | else | ||
Line 3,048: | Line 3,165: | ||
-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data. | -- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data. | ||
if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then | if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then -- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |ssrn= required for their templates | ||
if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or -- can't use ID_list_coins k/v table here because invalid parameters omitted | |||
utilities.set_message ('err_' .. config.CitationClass .. '_missing'); -- add error message | args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then -- which causes unexpected parameter missing error message | ||
utilities.set_message ('err_' .. config.CitationClass .. '_missing'); -- add error message | |||
end | end | ||
Line 3,072: | Line 3,190: | ||
end | end | ||
if utilities.is_set (URL) | if utilities.is_set (URL) then -- set when using an identifier-created URL | ||
utilities.set_message (' | if utilities.is_set (AccessDate) then -- |access-date= requires |url=; identifier-created URL is not |url= | ||
utilities.set_message ('err_accessdate_missing_url'); -- add an error message | |||
AccessDate = ''; -- unset | |||
end | |||
if utilities.is_set (ArchiveURL) then -- |archive-url= requires |url=; identifier-created URL is not |url= | |||
utilities.set_message ('err_archive_missing_url'); -- add an error message | |||
ArchiveURL = ''; -- unset | |||
end | |||
end | end | ||
end | end | ||
Line 3,110: | Line 3,235: | ||
end | end | ||
-- this is the function call to COinS() | -- this is the function call to COinS() | ||
local OCinSoutput = metadata.COinS({ | local OCinSoutput = metadata.COinS({ | ||
['Periodical'] = utilities.strip_apostrophe_markup (Periodical), -- no markup in the metadata | ['Periodical'] = utilities.strip_apostrophe_markup (Periodical), -- no markup in the metadata | ||
['Encyclopedia'] = Encyclopedia, -- just a flag; content ignored by ~/COinS | ['Encyclopedia'] = Encyclopedia, -- just a flag; content ignored by ~/COinS | ||
['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter), -- Chapter and ScriptChapter stripped of bold / italic | ['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter), -- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup | ||
['Degree'] = Degree; -- cite thesis only | ['Degree'] = Degree; -- cite thesis only | ||
['Title'] = metadata.make_coins_title (coins_title, ScriptTitle), -- Title and ScriptTitle stripped of bold / italic | ['Title'] = metadata.make_coins_title (coins_title, ScriptTitle), -- Title and ScriptTitle stripped of bold / italic / accept-as-written markup | ||
['PublicationPlace'] = PublicationPlace, | ['PublicationPlace'] = PublicationPlace, | ||
['Date'] = COinS_date.rftdate, -- COinS_date has correctly formatted date if Date is valid; | ['Date'] = COinS_date.rftdate, -- COinS_date has correctly formatted date if Date is valid; | ||
Line 3,128: | Line 3,250: | ||
['Volume'] = Volume, | ['Volume'] = Volume, | ||
['Issue'] = Issue, | ['Issue'] = Issue, | ||
['ArticleNumber'] = ArticleNumber, | |||
['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)), -- pages stripped of external links | ['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)), -- pages stripped of external links | ||
['Edition'] = Edition, | ['Edition'] = Edition, | ||
Line 3,166: | Line 3,289: | ||
local last_first_list; | local last_first_list; | ||
local control = { | local control = { | ||
format = NameListStyle, -- empty string or 'vanc' | format = NameListStyle, -- empty string, '&', 'amp', 'and', or 'vanc' | ||
maximum = nil, -- as if display-authors or display-editors not set | maximum = nil, -- as if display-authors or display-editors not set | ||
mode = Mode | mode = Mode | ||
Line 3,172: | Line 3,295: | ||
do -- do editor name list first because the now unsupported coauthors used to modify control table | do -- do editor name list first because the now unsupported coauthors used to modify control table | ||
control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors')); | if cfg.global_cs1_config_t['DisplayEditors'] then -- global setting from {{cs1 config}} overrides local setting | ||
control.maximum , editor_etal = get_display_names (cfg.global_cs1_config_t['DisplayEditors'], #e, 'editors', editor_etal, 'cs1 config'); | |||
else | |||
control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors')); | |||
end | |||
if cfg.global_cs1_config_t['DisplayEditors'] and utilities.is_set (A['DisplayEditors']) then -- when template has |display-editors=<something> which global setting has overridden | |||
utilities.set_message ('maint_overridden_setting'); -- set a maint message | |||
end | |||
Editors, EditorCount = list_people (control, e, editor_etal); | Editors, EditorCount = list_people (control, e, editor_etal); | ||
Line 3,180: | Line 3,312: | ||
end | end | ||
do -- now do interviewers | do -- now do interviewers | ||
control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers')); | if cfg.global_cs1_config_t['DisplayInterviewers'] then -- global setting from {{cs1 config}} overrides local setting | ||
Interviewers = list_people (control, interviewers_list, interviewer_etal); | control.maximum, interviewer_etal = get_display_names (cfg.global_cs1_config_t['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, 'cs1 config'); | ||
end | else | ||
control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers')); | |||
end | |||
if cfg.global_cs1_config_t['DisplayInterviewers'] and utilities.is_set (A['DisplayInterviewers']) then -- when template has |display-interviewers=<something> which global setting has overridden | |||
utilities.set_message ('maint_overridden_setting'); -- set a maint message | |||
end | |||
Interviewers = list_people (control, interviewers_list, interviewer_etal); | |||
end | |||
do -- now do translators | do -- now do translators | ||
control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators')); | if cfg.global_cs1_config_t['DisplayTranslators'] then -- global setting from {{cs1 config}} overrides local setting | ||
control.maximum, translator_etal = get_display_names (cfg.global_cs1_config_t['DisplayTranslators'], #t, 'translators', 'cs1 config'); | |||
else | |||
control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators')); | |||
end | |||
if cfg.global_cs1_config_t['DisplayTranslators'] and utilities.is_set (A['DisplayTranslators']) then -- when template has |display-translators=<something> which global setting has overridden | |||
utilities.set_message ('maint_overridden_setting'); -- set a maint message | |||
end | |||
Translators = list_people (control, t, translator_etal); | Translators = list_people (control, t, translator_etal); | ||
end | end | ||
do -- now do contributors | do -- now do contributors | ||
control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors')); | if cfg.global_cs1_config_t['DisplayContributors'] then -- global setting from {{cs1 config}} overrides local setting | ||
control.maximum, contributor_etal = get_display_names (cfg.global_cs1_config_t['DisplayContributors'], #c, 'contributors', contributor_etal, 'cs1 config'); | |||
else | |||
control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors')); | |||
end | |||
if cfg.global_cs1_config_t['DisplayContributors'] and utilities.is_set (A['DisplayContributors']) then -- when template has |display-contributors=<something> which global setting has overridden | |||
utilities.set_message ('maint_overridden_setting'); -- set a maint message | |||
end | |||
Contributors = list_people (control, c, contributor_etal); | Contributors = list_people (control, c, contributor_etal); | ||
end | end | ||
do -- now do authors | do -- now do authors | ||
control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors')); | if cfg.global_cs1_config_t['DisplayAuthors'] then -- global setting from {{cs1 config}} overrides local setting | ||
control.maximum, author_etal = get_display_names (cfg.global_cs1_config_t['DisplayAuthors'], #a, 'authors', author_etal, 'cs1 config'); | |||
else | |||
control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors')); | |||
end | |||
if cfg.global_cs1_config_t['DisplayAuthors'] and utilities.is_set (A['DisplayAuthors']) then -- when template has |display-authors=<something> which global setting has overridden | |||
utilities.set_message ('maint_overridden_setting'); -- set a maint message | |||
end | |||
last_first_list = list_people (control, a, author_etal); | last_first_list = list_people (control, a, author_etal); | ||
Line 3,425: | Line 3,592: | ||
if utilities.is_set (Minutes) then | if utilities.is_set (Minutes) then | ||
if utilities.is_set (Time) then --TODO: make a function for this and similar? | if utilities.is_set (Time) then --TODO: make a function for this and similar? | ||
utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' | utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')}); | ||
end | end | ||
Position = " " .. Minutes .. " " .. cfg.messages['minutes']; | Position = " " .. Minutes .. " " .. cfg.messages['minutes']; | ||
Line 3,497: | Line 3,664: | ||
local Agency = A['Agency']; | local Agency = A['Agency']; | ||
Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or ""; | Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or ""; | ||
Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase); | Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase); | ||
if utilities.is_set (AccessDate) then | if utilities.is_set (AccessDate) then | ||
Line 3,533: | Line 3,700: | ||
end | end | ||
end | end | ||
Quote = kern_quotes (Quote); -- kern if needed | |||
Quote = utilities.wrap_style ('quoted-text', Quote ); -- wrap in <q>...</q> tags | Quote = utilities.wrap_style ('quoted-text', Quote ); -- wrap in <q>...</q> tags | ||
Line 3,586: | Line 3,754: | ||
local Archived; | local Archived; | ||
if utilities.is_set (ArchiveURL) then | if utilities.is_set (ArchiveURL) then | ||
if not utilities.is_set (ArchiveDate) then -- ArchiveURL set but ArchiveDate not set | |||
if | utilities.set_message ('err_archive_missing_date'); -- emit an error message | ||
utilities.set_message (' | ArchiveURL = ''; -- empty string for concatenation | ||
ArchiveDate = ''; -- empty string for concatenation | |||
end | |||
else | |||
if utilities.is_set (ArchiveDate) then -- ArchiveURL not set but ArchiveDate is set | |||
utilities.set_message ('err_archive_date_missing_url'); -- emit an error message | |||
ArchiveURL = ''; -- empty string for concatenation | |||
ArchiveDate = ''; -- empty string for concatenation | ArchiveDate = ''; -- empty string for concatenation | ||
end | end | ||
end | |||
if utilities.is_set (ArchiveURL) then | |||
local arch_text; | |||
-- if not utilities.is_set (ArchiveDate) then | |||
-- utilities.set_message ('err_archive_missing_date'); | |||
-- ArchiveDate = ''; -- empty string for concatenation | |||
-- end | |||
if "live" == UrlStatus then | if "live" == UrlStatus then | ||
arch_text = cfg.messages['archived']; | arch_text = cfg.messages['archived']; | ||
Line 3,625: | Line 3,807: | ||
end | end | ||
else -- OriginalUrl not set | else -- OriginalUrl not set | ||
utilities.set_message ('err_archive_missing_url'); | utilities.set_message ('err_archive_missing_url'); | ||
Archived = ''; -- empty string for concatenation | Archived = ''; -- empty string for concatenation | ||
Line 3,731: | Line 3,911: | ||
if utilities.in_array (config.CitationClass, {"journal", "citation"}) and utilities.is_set (Periodical) then | if utilities.in_array (config.CitationClass, {"journal", "citation"}) and utilities.is_set (Periodical) then | ||
if not (utilities.is_set (Authors) or utilities.is_set (Editors)) then | |||
Others = Others:gsub ('^' .. sepc .. ' ', ''); -- when no authors and no editors, strip leading sepc and space | |||
end | |||
if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. " "}, sepc) end -- add terminal punctuation & space; check for dup sepc; TODO why do we need to do this here? | if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. " "}, sepc) end -- add terminal punctuation & space; check for dup sepc; TODO why do we need to do this here? | ||
tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc ); | tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc ); | ||
Line 3,826: | Line 4,009: | ||
if utilities.is_set (Date) then | if utilities.is_set (Date) then | ||
if EditorCount <= 1 then | if EditorCount <= 1 then | ||
Editors = Editors .. | Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor']; | ||
else | else | ||
Editors = Editors .. | Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors']; | ||
end | end | ||
else | else | ||
Line 3,903: | Line 4,086: | ||
local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass); | local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass); | ||
local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]'; | local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]'; | ||
local msg_prefix = '<code class="cs1-code">{{' .. template_link .. '}}</code>: '; | local msg_prefix = '<code class="cs1-code">{{' .. template_link .. '}}</code>: '; | ||
Line 3,969: | Line 4,152: | ||
]] | ]] | ||
local function validate (name, cite_class, empty) | local function validate (name, cite_class, empty) | ||
Line 4,091: | Line 4,273: | ||
if value:match ('[,;:]$') then | if value:match ('[,;:]$') then | ||
utilities.set_message ('maint_extra_punct'); -- has extraneous punctuation; add maint cat | |||
end | |||
if value:match ('^=') then -- sometimes an extraneous '=' character appears ... | |||
utilities.set_message ('maint_extra_punct'); -- has extraneous punctuation; add maint cat | utilities.set_message ('maint_extra_punct'); -- has extraneous punctuation; add maint cat | ||
end | end | ||
Line 4,121: | Line 4,306: | ||
local function citation(frame) | local function citation(frame) | ||
Frame = frame; -- save a copy in case we need to display an error message in preview mode | Frame = frame; -- save a copy in case we need to display an error message in preview mode | ||
is_sandbox = nil ~= string.find (frame:getTitle(), | |||
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 support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep? | |||
end | |||
-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here) | |||
local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox'; -- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}} | |||
is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true); -- is this invoke the sandbox module? | |||
sandbox = is_sandbox and sandbox or ''; -- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else | |||
local pframe = frame:getParent() | local pframe = frame:getParent() | ||
local styles; | local styles; | ||
cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox); -- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else | |||
whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox); | |||
utilities = require ('Module:Citation/CS1/Utilities' .. sandbox); | |||
validation = require ('Module:Citation/CS1/Date_validation' .. sandbox); | |||
identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox); | |||
metadata = require ('Module:Citation/CS1/COinS' .. sandbox); | |||
styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css'; | |||
utilities.set_selected_modules (cfg); -- so that functions in Utilities can see the selected cfg tables | utilities.set_selected_modules (cfg); -- so that functions in Utilities can see the selected cfg tables | ||
Line 4,156: | Line 4,340: | ||
local suggestions = {}; -- table where we store suggestions if we need to loadData them | local suggestions = {}; -- table where we store suggestions if we need to loadData them | ||
local error_text; -- used as a flag | local error_text; -- used as a flag | ||
local capture; -- the single supported capture when matching unknown parameters using patterns | local capture; -- the single supported capture when matching unknown parameters using patterns | ||
Line 4,180: | Line 4,358: | ||
else | else | ||
if nil == suggestions.suggestions then -- if this table is nil then we need to load it | if nil == suggestions.suggestions then -- if this table is nil then we need to load it | ||
suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox); --load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else | |||
end | end | ||
for pattern, param in pairs (suggestions.patterns) do -- loop through the patterns to see if we can suggest a proper parameter | for pattern, param in pairs (suggestions.patterns) do -- loop through the patterns to see if we can suggest a proper parameter |