Modhul:Citation/CS1: Béda antara owahan
Konten dihapus Konten ditambahkan
MRZQ (parembugan | pasumbang) Tenger: Pawurungan |
MRZQ (parembugan | pasumbang) Tenger: Pawurungan |
||
Larik 1:
local cs1 ={};
--[[--------------------------< F O R W A R D D E C L A R A T I O N S >--------------------------------------
]]
local dates, year_date_check, reformat_dates
local is_set, in_array, substitute, error_comment, set_error, select_one, -- functions in Module:Citation/CS1/Utilities
add_maint_cat, wrap_style, safe_for_italics,
local z ={}; -- tables in Module:Citation/CS1/Utilities
local extract_ids
local make_coins_title, get_coins_pages, COinS; -- functions in Module:Citation/CS1/COinS
Baris 18 ⟶ 19:
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
--[[--------------------------< F I R S T _ S E T >------------------------------------------------------------
Baris 54 ⟶ 40:
end
end
--[[--------------------------< A D D _ P R O P _ C A T >--------------------------------------------------------
Adds a category to z.properties_cats using names from the configuration file with additional text if any.
]]
local added_prop_cats = {} -- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
if not added_prop_cats [key] then
added_prop_cats [key] = true; -- note that we've added this category
table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments)); -- make name then add to table
end
end
--[[--------------------------< A D D _ V A N C _ E R R O R >----------------------------------------------------
Baris 80 ⟶ 59:
Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.
]]
local added_vanc_errs; -- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
if not added_vanc_errs then
added_vanc_errs = true; -- note that we've added this category
table.insert( z.message_tail, { set_error( 'vancouver', {
end
end
Baris 131 ⟶ 109:
There are several tests:
the first character of the whole domain name including subdomains must be a letter or a digit
single-letter/digit second-level domains in the .org TLD
q, x, and z SL domains in the .com TLD
i and q SL domains in the .net TLD
Baris 151 ⟶ 128:
domain = domain:gsub ('^//', ''); -- strip '//' from domain name if present; done here so we only have to do it once
if not domain:match ('^[%
return false;
end
-- Do most common case first
if domain:match ('
return true;
elseif domain:match ('%f[%a%d][%a%d]%.org$') then -- one character .org hostname
return true;
elseif domain:match ('%f[%a][qxz]%.com$') then -- assigned one character .com hostname (x.com times out 2015-12-10)
return true;
elseif domain:match ('%f[%a][iq]%.net$') then -- assigned one character .net hostname (q.net registered but not active 2015-12-10)
return true;
elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then -- one character hostname and cctld (2 chars)
return true;
elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then -- two character hostname and tld
return true;
elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then -- IPv4 address
return true;
else
return false;
end
end
Baris 262 ⟶ 230:
return not is_url (scheme, domain); -- return true if value DOES NOT appear to be a valid url
end
--[[--------------------------< L I N K _ T I T L E _ O K >---------------------------------------------------
Baris 276 ⟶ 243:
local orig;
if is_set (link) then -- don't bother if
if not link_param_ok (link) then -- check |<param>-link= markup
orig = lorig; -- identify the failing link parameter
elseif title:find ('%[%[') then -- check |title= for wikilink markup
orig = torig; -- identify the failing
end
end
Baris 390 ⟶ 357:
['\n'] = ' ' } );
end
--[[--------------------------< E X T E R N A L _ L I N K >----------------------------------------------------
Baris 398 ⟶ 364:
]]
local function external_link( URL, label, source
local error_str = "";
if not is_set( label ) then
label = URL;
Baris 415 ⟶ 377:
error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, " " ) .. error_str;
end
return table.concat({ "[", URL, " ", safe_for_url( label ), "]", error_str });
end
--[[--------------------------< D E P R E C A T E D _ P A R A M E T E R >--------------------------------------
Baris 437 ⟶ 385:
offending parameter name to the error message. Only one error message is emitted regardless of the number of deprecated
parameters in the citation.
]]
local page_in_deprecated_cat; -- sticky flag so that the category is added only once
local function deprecated_parameter(name)
if not
table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } ); -- add error message
end
end
--[[--------------------------< K E R N _ Q U O T E S >--------------------------------------------------------
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
"'Unkerned title with leading and trailing single quote marks'"
" 'Kerned title with leading and trailing single quote marks' " (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.
Call this function for chapter titles, for website titles, etc; not for book titles.
]
local function kern_quotes (str)
local cap='';
local cap2='';
if is_set (cap) then
end
cap, cap2 = str:match ("^(.+[^\'])([\"\'])$")
if is_set (cap) then
str = substitute (cfg.presentation['kern-right'], {cap, cap2});
end
return str;
end
--[[--------------------------< F O R M A T _ S C R I P T _ V A L U E >----------------------------------------
Baris 527 ⟶ 444:
is not added. At this time there is no error message for this condition.
Supports |script-title=
TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]
local function format_script_value (script_value
local lang=''; -- initialize to empty string
local name;
if script_value:match('^%l%l
lang = script_value:match('^(%l%l
if not is_set (lang) then
return ''; -- script_value was just the prefix so return empty string
end
-- if we get this far we have prefix and script
name =
if is_set (name) then -- is prefix a proper ISO 639-1 language code?
script_value = script_value:gsub ('^%l
-- is prefix one of these language codes?
if in_array (lang, {'am', 'ar', 'be', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ml', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
add_prop_cat ('script_with_name', {name, lang})
else
add_prop_cat ('script')
end
lang = ' lang="' .. lang .. '" '; -- convert prefix into a lang attribute
else
lang = ''; -- invalid so set lang to empty string
end
end
script_value = substitute (cfg.presentation['bdi'], {lang, script_value}); -- isolate in case script is rtl
Baris 562 ⟶ 476:
return script_value;
end
--[[--------------------------< S C R I P T _ C O N C A T E N A T E >------------------------------------------
Baris 570 ⟶ 483:
]]
local function script_concatenate (title, script
if is_set (script) then
script = format_script_value (script
if is_set (script) then
title = title .. ' ' .. script; -- concatenate title and script title
Baris 596 ⟶ 509:
local msg;
msg = cfg.messages[key]:lower(); -- set the message to lower case before
return substitute( msg, str );
else
return substitute( cfg.messages[key], str );
end
end
Baris 695 ⟶ 523:
]]
local function format_chapter_title (scriptchapter
local chapter_error = '';
if not is_set (chapter) then
chapter = ''; -- to be safe for concatenation
else
if false == no_quotes then
chapter = kern_quotes (chapter); -- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
chapter = wrap_style ('quoted-title', chapter);
end
end
chapter = script_concatenate (chapter, scriptchapter
if is_set (transchapter) then
Baris 727 ⟶ 542:
chapter = chapter .. ' ' .. transchapter;
else -- here when transchapter without chapter or script-chapter
chapter = transchapter; --
chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
end
end
if is_set (chapterurl) then
chapter = external_link (chapterurl, chapter, chapter_url_source); -- adds bare_url_missing_title error if appropriate
end
return chapter .. chapter_error;
end
--[[--------------------------< H A S _ I N V I S I B L E _ C H A R S >----------------------------------------
Baris 745 ⟶ 563:
Detects but ignores nowiki and math stripmarkers. Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message. See also coins_cleanup().
Detects but ignores the character pattern that results from the transclusion of {{'}} templates.
Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
Baris 768 ⟶ 588:
local pattern=cfg.invisible_chars[i][2] -- the pattern used to find it
position, dummy, capture = mw.ustring.find (v, pattern) -- see if the parameter value contains characters that match the pattern
if position then
-- if 'nowiki' == capture or 'math' == capture or
elseif true == stripmarker and 'delete' == char then -- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
position = nil; -- unset
elseif 'apostrophe' == char then -- apostrophe template uses ‍, hair space and zero-width space
apostrophe = true;
elseif true == apostrophe and in_array (char, {'zero width joiner', 'zero width space', 'hair space'}) then
position = nil; -- unset
else
Baris 832 ⟶ 650:
-- maybe let through instead of raising an error?
-- v, origin[k] = args[k], k;
error( cfg.messages['unknown_argument_map']
end
-- Empty strings, not nil;
if v == nil then
origin[k] = '';
end
Baris 846 ⟶ 663:
end,
});
end
--[[--------------------------< V A L I D A T E >--------------------------------------------------------------
Looks for a parameter's name in the whitelist.
Parameters in the whitelist can have three values:
true - active, supported parameters
false - deprecated, supported parameters
nil - unsupported parameters
]]
local function validate( name )
local name = tostring( name );
local state = whitelist.basic_arguments[ name ];
-- Normal arguments
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
-- Arguments with numbers in them
name = name:gsub( "%d+", "#" ); -- replace digit(s) with # (last25 becomes last#
state = whitelist.numbered_arguments[ name ];
if true == state then return true; end -- valid actively supported parameter
if false == state then
deprecated_parameter (name); -- parameter is deprecated but still supported
return true;
end
return false; -- Not supported because not found or name is set to nil
end
Baris 872 ⟶ 722:
return date;
end
--[[--------------------------< S E T _ T I T L E T Y P E >----------------------------------------------------
Baris 883 ⟶ 732:
local function set_titletype (cite_class, title_type)
if is_set(title_type) then
if "none" == title_type then
title_type = ""; -- if |type=none then type parameter not displayed
end
Baris 896 ⟶ 744:
--[[--------------------------< H Y P H E N _ T O _ D A S H >--------------------------------------------------
Converts a hyphen to a dash
]]
local function hyphen_to_dash( str )
if not is_set
return str;
end
return str:gsub( '-', '–' );
end
Baris 954 ⟶ 763:
local function safe_join( tbl, duplicate_char )
--[[
Note: we use string functions here, rather than ustring functions.
This has considerably faster performance and should work correctly as
long as the duplicate_char is strict ASCII. The strings
in tbl may be ASCII or UTF8.
]]
local str = ''; -- the output string
local comp = ''; -- what does 'comp' mean?
Baris 981 ⟶ 787:
end
-- typically duplicate_char is sepc
if
-- Because individual string segments often (always?) begin with terminal punct for
-- preceding segment: 'First element' .. 'sepc next element' .. etc?
trim = false;
end_chr =
-- str = str .. "<HERE(enchr=" .. end_chr.. ")" -- debug stuff?
if end_chr == duplicate_char then -- if same as separator
str =
elseif end_chr == "'" then -- if it might be wikimarkup
if
str =
elseif
trim = true; -- why? why do this and next differently from previous?
elseif
trim = true; -- same question
end
elseif end_chr == "]" then -- if it might be wikimarkup
if
trim = true;
elseif
trim = true;
elseif
trim = true;
end
elseif end_chr == " " then -- if last char of output string is a space
if
str =
end
end
Baris 1.016 ⟶ 820:
if value ~= comp then -- value does not equal comp when value contains html markup
local dup2 = duplicate_char;
if
value =
else
value =
end
end
Baris 1.028 ⟶ 832:
end
return str;
end
--[[--------------------------< I S _ G O O D _ V A N C _ N A M E >--------------------------------------------
Baris 1.061 ⟶ 850:
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods
At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.
]]
local function is_good_vanc_name (last, first)
if nil == mw.ustring.find (last, "^[A-Za-zÀ-ÖØ-öø-ƿDŽ-ɏ%-%s%']*$") or nil == mw.ustring.find (first, "^[A-Za-zÀ-ÖØ-öø-ƿDŽ-ɏ%-%s%'%.]*$") then
add_vanc_error ();
return false; -- not a string of latin characters; Vancouver required Romanization
end;
return true;
end
--[[--------------------------< R E D U C E _ T O _ I N I T I A L S >------------------------------------------
Baris 1.098 ⟶ 869:
Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.
Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().
Baris 1.106 ⟶ 877:
local function reduce_to_initials(first)
local initials = {}
table.insert(initials, mw.ustring.sub(word,1,1)) -- Vancouver format does not include full stops.
i = i + 1; -- bump the counter
if 2 <= i then break; end -- only two initials allowed in Vancouver system; if 2, quit
end
return table.concat(initials) -- Vancouver format does not include spaces.
end
--[[--------------------------< L I S T _ P E O P L E >-------------------------------------------------------
Baris 1.156 ⟶ 894:
]]
local function list_people(control, people, etal, list_name) -- TODO: why is list_name here? not used in this function
local sep;
local namesep;
Baris 1.165 ⟶ 903:
if 'vanc' == format then -- Vancouver-like author/editor name styling?
sep =
namesep =
else
sep =
namesep =
end
Baris 1.195 ⟶ 932:
one = person.last
local first = person.first
if is_set(first) then
if ( "vanc" == format ) then -- if vancouver format
one = one:gsub ('%.', ''); -- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
if not person.corporate and is_good_vanc_name (one, first) then -- and name is all Latin characters; corporate authors not tested
first = reduce_to_initials(first) -- attempt to convert first name(s) to initials
end
end
one = one .. namesep .. first
end
if is_set(person.link) and person.link ~= control.page_name then
one = "[[" .. person.link .. "|" .. one .. "]]" -- link author/editor if this page is not the author's/editor's page
end
end
table.insert( text, one )
table.insert( text, sep_one )
end
end
Baris 1.228 ⟶ 965:
return result, count
end
--[[--------------------------< A N C H O R _ I D >------------------------------------------------------------
Baris 1.237 ⟶ 973:
]]
local function anchor_id (namelist, year)
local names={}; -- a table for the one to four names and year
Baris 1.256 ⟶ 991:
--[[--------------------------< N A M E _ H A S _ E T A L >----------------------------------------------------
Evaluates the content of
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.
This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the
]]
local function name_has_etal (name, etal, nocat
if is_set (name) then -- name can be nil in which case just return
local etal_pattern = "[;,]? *[\"']*%f[%a][Ee][Tt] *[Aa][Ll][%.\"']*$" -- variations on the 'et al' theme
local others_pattern = "[;,]? *%f[%a]and [Oo]thers"; -- and alternate to et al.
etal = true; -- set flag (may have been set previously here or by |display-authors=etal)
end
elseif name:match (others_pattern) then -- if not 'et al.', then 'and others'?
name = name:gsub (others_pattern, ''); -- if found, remove
etal = true; -- set flag (may have been set previously here or by |display-authors=etal)
if not nocat then -- no categorization for |vauthors=
add_maint_cat ('etal'); -- and add a category if not already added
end
end
end
return name, etal; --
end
--[[--------------------------< E X T R A C T _ N A M E S >----------------------------------------------------
Baris 1.404 ⟶ 1.049:
local etal=false; -- return value set to true when we find some form of et al. in an author parameter
local err_msg_list_name = list_name:match ("(%w+)List") .. 's list'; -- modify AuthorList or EditorList for use in error messages if necessary
while true do
last
first
link
mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
last, etal = name_has_etal (last, etal, false
first, etal = name_has_etal (first, etal, false
if first and not last then -- if there is a firstn without a matching lastn
table.insert( z.message_tail, { set_error( 'first_missing_last', {
elseif not first and not last then -- if both firstn and lastn aren't found, are we done?
count = count + 1; -- number of times we haven't found last and first
Baris 1.423 ⟶ 1.067:
end
else -- we have last with or without a first
link_title_ok (link,
names[n] = {last = last, first = first, link = link, mask = mask, corporate=false}; -- add this name to our names list (corporate for |vauthors= only)
n = n + 1; -- point to next location in the names table
if 1 == count then -- if the previous name was missing
table.insert( z.message_tail, { set_error( 'missing_name', {
end
count = 0; -- reset the counter, we're looking for two consecutive missing names
Baris 1.440 ⟶ 1.081:
return names, etal; -- all done, return our list of names
end
--[[--------------------------< G E T _ I S O 6 3 9 _ C O D E >------------------------------------------------
Validates language names provided in |language= parameter if not an ISO639-1
Returns the language name and associated
mw.language.fetchLanguageNames(
in the list will be found if that name is provided in the |language= parameter. For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code. When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.
Adapted from code taken from Module:Check ISO 639-1.
Baris 1.470 ⟶ 1.100:
local function get_iso639_code (lang, this_wiki_code)
local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all') -- get a list of language names known to Wikimedia
-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
local langlc = mw.ustring.lower(lang); -- lower case version for comparisons
for code, name in pairs(languages) do -- scan the list to see if we can find our language
if langlc == mw.ustring.lower(name) then
if 2
return name
end
end
end
end
--[[--------------------------< L A N G U A G E _ P A R A M E T E R >------------------------------------------
When |language= contains a
the page is a mainspace page and the ISO639-1 code is not the local wiki's language code. Similarly, if the parameter is |language=Norwegian,
it will be categorized in the same way.
This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.
]]
local function language_parameter (lang)
local code; -- the
local name; -- the language name
local language_list = {}; -- table of language names to be rendered
local names_table = {}; -- table made from the value assigned to |language=
local
local this_wiki_code = this_wiki:getCode() -- get this wiki's language code
local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code); -- get this wiki's language name
names_table = mw.text.split (lang, '%s*,%s*'); -- names should be a comma separated list
for _, lang in ipairs (names_table) do -- reuse lang
if
end
if 2 == lang:len() then -- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
end
if is_set (name) then -- if Language specified a valid ISO639-1 code
code = lang:lower(); -- save it
else
name, code = get_iso639_code (lang,
end
if is_set (code) then
if this_wiki_code ~= code then -- when the language is not the same as this wiki's language
add_prop_cat ('foreign_lang_source', {name, code}) -- categorize it
end
else
Baris 1.564 ⟶ 1.168:
code = #language_list -- reuse code as number of languages in the list
if 2 >= code then
name = table.concat (language_list,
elseif 2 < code then
language_list[code] = 'and ' .. language_list[code]; -- prepend last name with 'and<space>'
name = table.concat (
end
if this_wiki_name == name then
Baris 1.573 ⟶ 1.177:
end
return (" " .. wrap_msg ('language', name)); -- otherwise wrap with '(in ...)'
end
--[[--------------------------< S E T _ C S 1 _ S T Y L E >----------------------------------------------------
Set style settings for CS1 citation templates. Returns separator and postscript settings
]]
local function set_cs1_style (ps)
if not is_set (ps) then -- unless
ps =
end
return
end
--[[--------------------------< S E T _ C S 2 _ S T Y L E >----------------------------------------------------
Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
]]
Baris 1.607 ⟶ 1.200:
local function set_cs2_style (ps, ref)
if not is_set (ps) then -- if |postscript= has not been set, set cs2 default
ps =
end
if not is_set (ref) then -- if |ref= is not set
ref = "harv"; -- set default |ref=harv
end
return
end
--[[--------------------------< G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S >----------------------
Baris 1.633 ⟶ 1.225:
return sep, ps, ref -- return them all
end
--[[--------------------------< S E T _ S T Y L E >------------------------------------------------------------
Baris 1.651 ⟶ 1.242:
sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class); -- get settings based on the template's CitationClass
end
if 'none' == ps:lower() then -- if assigned value is 'none' then
ps = ''; -- set to empty string
end
Baris 1.658 ⟶ 1.248:
return sep, ps, ref
end
--[=[-------------------------< I S _ P D F >------------------------------------------------------------------
Baris 1.665 ⟶ 1.254:
applying the pdf icon to external links.
returns true if file extension is one of the recognized
]=]
local function is_pdf (url)
return url:match ('%.pdf
end
--[[--------------------------< S T Y L E _ F O R M A T >------------------------------------------------------
Baris 1.687 ⟶ 1.273:
local function style_format (format, url, fmt_param, url_param)
if is_set (format) then
format = wrap_style ('format', format); -- add leading space,
if not is_set (url) then
format = format .. set_error( 'format_missing_url', {fmt_param, url_param} ); -- add an error message
Baris 1.699 ⟶ 1.285:
end
--[[--------------------------< G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S >------------------------
Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
Baris 1.723 ⟶ 1.308:
]]
local function
if is_set (max) then
if 'etal' == max:lower():gsub("[ '%.]", '') then -- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
Baris 1.731 ⟶ 1.316:
max = tonumber (max); -- make it a number
if max >= count then -- if |display-xxxxors= value greater than or equal to number of authors/editors
add_maint_cat ('
end
else -- not a valid keyword or number
Baris 1.741 ⟶ 1.326:
return max, etal;
end
--[[--------------------------< E X T R A _ T E X T _ I N _ P A G E _ C H E C K >------------------------------
Baris 1.755 ⟶ 1.339:
local function extra_text_in_page_check (page)
-- local good_pattern = '^P[^%.P%l]';
local good_pattern = '^P[^%.Pp]'; -- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
-- local bad_pattern = '^[Pp][Pp]';
local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';
Baris 1.761 ⟶ 1.347:
add_maint_cat ('extra_text');
end
-- if Page:match ('^[Pp]?[Pp]%.?[ %d]') or Page:match ('^[Pp]ages?[ %d]') or
-- Pages:match ('^[Pp]?[Pp]%.?[ %d]') or Pages:match ('^[Pp]ages?[ %d]') then
-- add_maint_cat ('extra_text');
-- end
end
Baris 1.816 ⟶ 1.362:
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.
This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.
TODO: check for names like Coon V JS (Coon JS 5th at PMID 25205766, John S. Coon V at doi:10.1093/humupd/dmu048)?
]]
Baris 1.826 ⟶ 1.372:
local names = {}; -- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
local v_name_table = {};
local etal = false; -- return value set to true when we find some form of et al. vauthors parameter
local last, first, link, mask
local corporate = false;
vparam, etal = name_has_etal (vparam, etal, true); -- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
if vparam:find ('%[%[') or vparam:find ('%]%]') then -- no wikilinking vauthors names
add_vanc_error ();
end
v_name_table = mw.text.split(vparam, "%s*,%s*") -- names are separated by commas
for i, v_name in ipairs(v_name_table) do
if v_name:match ('^%(%(.+%)%)$') then -- corporate authors are wrapped in doubled
first = ''; -- set to empty string for concatenation and because it may have been set for previous author/editor
last = v_name:match ('^%(%((.+)%)%)$')
corporate = true;
elseif string.find(v_name, "%s") then
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
last = table.concat(lastfirstTable, " ") -- returns a string that is the concatenation of all other names that are not initials
if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
add_vanc_error (); -- matches last II last; the case when a comma is missing or a space between two intiials
end
else
Baris 1.862 ⟶ 1.400:
end
if is_set (first) and not mw.ustring.match (first, "^%u?%u$") then -- first shall contain one or two upper-case letters, nothing else
add_vanc_error ();
end
-- this from extract_names ()
link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i )
mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate}; -- add this assembled name to our names list
Baris 1.883 ⟶ 1.410:
return names, etal; -- all done, return our list of names
end
--[[--------------------------< S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E >------------------------
Baris 1.904 ⟶ 1.430:
local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or -- do this twice incase we have a
select_one( args, cfg.aliases[list_name .. '-
lastfirst=true;
end
Baris 1.935 ⟶ 1.459:
This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true,
]]
local function is_valid_parameter_value (value, name, possible
if not is_set (value) then
return
elseif in_array
return true;
else
table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } ); -- not an allowed value so add error message
return
end
end
Baris 1.964 ⟶ 1.487:
local function terminate_name_list (name_list, sepc)
if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. '
return name_list .. " "; -- don't add another
else
Baris 1.995 ⟶ 1.516:
end
end
local vol = '';
if is_set (volume) then
if (4 < mw.ustring.len(volume)) then
vol = substitute (cfg.
else
vol =
end
end
Baris 2.018 ⟶ 1.532:
end
--[[-------------------------< N O R M A L I Z E _ P A G E _ L I S T >-----------------------------------------
not currently used
normalizes a comma, ampersand, and/or space separated list to be '<value>, <value>, ..., <value>'
returns list unchanged if there are no commas else strips whitespace and then reformats the list
]]
--[[
local function normalize_page_list (list)
if not list:find ('[,& ]') then return list end -- if list is not delimited with commas, ampersands, or spaces; done
list = mw.text.split (list, '[,&%s]+'); -- make a table of values
list = table.concat (list, ', '); -- and now make a normalized list
return list;
end
]]
--[[-------------------------< F O R M A T _ P A G E S _ S H E E T S >-----------------------------------------
Baris 2.046 ⟶ 1.582:
end
local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map
if is_set (page) then
if is_journal then
Baris 2.059 ⟶ 1.595:
if is_journal then
return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
elseif tonumber(pages) ~= nil and not nopp then -- if pages is only digits, assume a single page number
return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
elseif not nopp then
Baris 2.070 ⟶ 1.606:
return '', '', '', ''; -- return empty strings
end
--[[--------------------------< C I T A T I O N 0 >------------------------------------------------------------
Baris 2.240 ⟶ 1.623:
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
local author_etal;
local a = {}; -- authors list from |lastn= / |firstn= pairs or |vauthors=
local Authors;
local NameListFormat = A['NameListFormat'];
local Collaboration = A['Collaboration'];
Baris 2.259 ⟶ 1.638:
elseif 3 == selected then
Authors = A['Authors']; -- use content of |authors=
end
if is_set (Collaboration) then
Baris 2.268 ⟶ 1.644:
end
local Coauthors = A['Coauthors'];
local Others = A['Others'];
Baris 2.283 ⟶ 1.660:
elseif 3 == selected then
Editors = A['Editors']; -- use content of |editors=
end
end
local t = {}; -- translators list from |translator-lastn= / translator-firstn= pairs
local Translators; -- assembled translators name list
t = extract_names (args, 'TranslatorList'); -- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
local c = {}; -- contributors list from |contributor-lastn= / contributor-firstn= pairs
local Contributors; -- assembled contributors name list
local Contribution = A['Contribution'];
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=
Baris 2.321 ⟶ 1.690:
end
if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then -- only accepted value for this parameter is 'vanc'
NameListFormat = ''; -- anything else, set to empty string
end
Baris 2.342 ⟶ 1.709:
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 Chapter = A['Chapter'];
local ScriptChapter = A['ScriptChapter'];
local ChapterLink -- = A['ChapterLink']; -- deprecated as a parameter but still used internally by cite episode
local TransChapter = A['TransChapter'];
Baris 2.351 ⟶ 1.717:
local Docket = A['Docket'];
local ArchiveFormat = A['ArchiveFormat'];
local ArchiveURL = A['ArchiveURL'];
local URL = A['URL']
local URLorigin = A:ORIGIN('URL'); -- get name of parameter that holds URL
Baris 2.367 ⟶ 1.725:
local ConferenceURL = A['ConferenceURL'];
local ConferenceURLorigin = A:ORIGIN('ConferenceURL'); -- get name of parameter that holds ConferenceURL
local Periodical = A['Periodical'];
local Periodical_origin = A:ORIGIN('Periodical'); -- get the name of the periodical parameter
local Series = A['Series'];
Baris 2.402 ⟶ 1.736:
local At;
if in_array (config.CitationClass, cfg.templates_using_volume) and not ('
Volume = A['Volume'];
end
if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
Issue = A['Issue'];
end
local Position = '';
if not in_array (config.CitationClass, cfg.templates_not_using_page) then
Page = A['Page'];
Pages = hyphen_to_dash
At = A['At'];
end
local Edition = A['Edition'];
local PublicationPlace =
local Place =
local PublisherName = A['PublisherName'];
local
if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
RegistrationRequired=nil;
end
local SubscriptionRequired = A['SubscriptionRequired'];
if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
SubscriptionRequired=nil;
end
local Via = A['Via'];
local AccessDate = A['AccessDate'];
local ArchiveDate = A['ArchiveDate'];
local Agency = A['Agency'];
local DeadURL = A['DeadURL']
if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then -- set in config.defaults to 'yes'
DeadURL = ''; -- anything else, set to empty string
end
local Language = A['Language'];
Baris 2.493 ⟶ 1.778:
local ID = A['ID'];
local ASINTLD = A['ASINTLD'];
local IgnoreISBN =
if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
IgnoreISBN = nil; -- anything else, set to empty string
end
local Embargo = A['Embargo'];
local Class = A['Class']; -- arxiv class identifier
local ID_list = extract_ids( args );
local Quote = A['Quote'];
Baris 2.513 ⟶ 1.797:
local TranscriptURLorigin = A:ORIGIN('TranscriptURL'); -- get name of parameter that holds TranscriptURL
local LastAuthorAmp =
if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
LastAuthorAmp = nil; -- set to empty string
end
local no_tracking_cats = A['NoTracking'];
if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
no_tracking_cats = nil; -- set to empty string
end
--these are used by cite interview
local Callsign = A['Callsign'];
local City = A['City'];
local Program = A['Program'];
local use_lowercase; -- controls capitalization of certain static text
local this_page = mw.title.getCurrentTitle(); -- also used for COinS and for language
Baris 2.523 ⟶ 1.817:
local COinS_date = {}; -- holds date info extracted from |date= for the COinS metadata by Module:Date verification
local DF = A['DF']; -- date format set in cs1|2 template
if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then -- validate reformatting keyword
DF =
end
-- set default parameter values defined by |mode= parameter. If |mode= is empty or omitted, use CitationClass to set these values
local
if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
Mode = '';
end
local sepc; -- separator between citation elements for CS1 a period, for CS2, a comma
local PostScript;
local Ref; sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass); use_lowercase = ( sepc == ',' );
if not is_set (no_tracking_cats) then -- ignore if we are already not going to categorize this page
if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
Baris 2.552 ⟶ 1.845:
end
end
-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' ); -- this is a dummy call simply to get the error message and category
local NoPP =
if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
NoPP = true;
else
NoPP = nil; -- unset, used as a flag later
end
if is_set(Page) then
if is_set(Pages) or is_set(At) then
Pages = ''; -- unset the others
At = '';
end
extra_text_in_page_check (Page); -- add this page to maint cat if |page= value begins with what looks like p. or pp.
elseif is_set(Pages) then
if is_set(At) then
At = ''; -- unset
end
extra_text_in_page_check (Pages); -- add this page to maint cat if |pages= value begins with what looks like p. or pp.
end
-- both |publication-place= and |place= (|location=) allowed if different
if not is_set(PublicationPlace) and is_set(Place) then
PublicationPlace = Place; -- promote |place= (|location=) to |publication-place
end
if PublicationPlace == Place then Place = ''; end -- don't need both if they are the same
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
|encyclopedia and |title then map |title to |article and |encyclopedia to |title
|encyclopedia and |article then map |encyclopedia to |title
|encyclopedia then map |encyclopedia to |title
|trans_title maps to |trans_chapter when |title is re-mapped
|url maps to |chapterurl when |title is remapped
All other combinations of |encyclopedia, |title, and |article are not modified
]]
local Encyclopedia = A['Encyclopedia'];
if ( config.CitationClass == "encyclopaedia" ) or ( config.CitationClass == "citation" and is_set (Encyclopedia)) then -- test code for citation
if is_set
if is_set(Title) or is_set (ScriptTitle) then
if not is_set(Chapter) then
Chapter = Title; -- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
ScriptChapter = ScriptTitle;
TransChapter = TransTitle;
ChapterURL = URL;
if not is_set (ChapterURL) and is_set (TitleLink) then
Chapter
end
Title = Periodical;
Baris 2.612 ⟶ 1.912:
ScriptTitle = '';
end
Title = Periodical; -- |encyclopedia set and |article set or not set so map |encyclopedia to |title
Periodical = ''; -- redundant so unset
end
Baris 2.619 ⟶ 1.919:
end
if (config.CitationClass == "techreport") then -- special case for cite techreport
if is_set(A['Number']) then -- cite techreport uses 'number', which other citations alias to 'issue'
if not is_set(ID) then -- can we use ID for the "number"?
ID = A['Number']; -- yes, use it
else -- ID has a value so emit error message
table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
Baris 2.630 ⟶ 1.930:
end
if (config.CitationClass == "
if is_set(Program) then
ID = ' ' .. Program;
end
if is_set(Callsign) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. Callsign;
else
ID = ' ' .. Callsign;
end
end
if is_set(City) then
if is_set(ID) then
ID = ID .. sepc .. ' ' .. City;
else
ID = ' ' .. City;
end
end
if is_set(Others) then
if is_set(TitleType) then
Others = ' ' .. TitleType .. ' with ' .. Others;
TitleType = '';
else
Others = ' ' .. 'Interview with ' .. Others;
end
else
Others = '(Interview)';
end
end
-- special case for cite mailing list
if (config.CitationClass == "mailinglist") then
Periodical = A ['MailingList'];
elseif 'mailinglist' ==
Periodical = ''; -- unset because mailing list is only used for cite mailing list
end
if 'conference' == config.CitationClass then
if is_set(BookTitle) then
Chapter = Title;
ChapterURL = URL;
ChapterURLorigin = URLorigin;
URLorigin = '';
Baris 2.650 ⟶ 1.981:
Title = BookTitle;
Format = '';
TransTitle = '';
URL = '';
Baris 2.658 ⟶ 1.989:
end
local Cartography = "";
local Scale = "";
Baris 2.666 ⟶ 1.997:
Chapter = A['Map'];
ChapterURL = A['MapURL'];
TransChapter = A['TransMap'];
ChapterURLorigin = A:ORIGIN('MapURL');
ChapterFormat = A['MapFormat'];
Cartography = A['Cartography'];
if is_set( Cartography ) then
Baris 2.684 ⟶ 2.011:
end
if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
local AirDate = A['AirDate'];
local SeriesLink = A['SeriesLink'];
Baris 2.698 ⟶ 2.026:
ID = table.concat(n, sepc .. ' ');
if not is_set (Date) and is_set (AirDate) then -- promote airdate to date
Date = AirDate;
end
if 'episode' == config.CitationClass then -- handle the oddities that are strictly {{cite episode}}
local Season = A['Season'];
Baris 2.708 ⟶ 2.040:
-- assemble a table of parts concatenated later into Series
if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
if is_set(SeriesNumber) then table.insert(s, wrap_msg ('
if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
Issue = ''; -- unset because this is not a unique parameter
Baris 2.714 ⟶ 2.046:
Chapter = Title; -- promote title parameters to chapter
ScriptChapter = ScriptTitle;
ChapterLink = TitleLink; -- alias episodelink
TransChapter = TransTitle;
ChapterURL = URL;
ChapterURLorigin = A:ORIGIN('URL');
Baris 2.726 ⟶ 2.056:
if is_set (ChapterLink) and not is_set (ChapterURL) then -- link but not URL
Chapter =
elseif is_set (ChapterLink) and is_set (ChapterURL) then -- if both are set, URL links episode;
Series =
end
URL = ''; -- unset
Baris 2.738 ⟶ 2.068:
Chapter = A['Episode']; -- TODO: make |episode= available to cite episode someday?
if is_set (Series) and is_set (SeriesLink) then
Series =
end
Series = wrap_style ('italic-title', Series); -- series is italicized
end
end
if 'arxiv' == config.CitationClass then
if not is_set (ID_list['ARXIV']) then -- |arxiv= or |eprint= required for cite arxiv
table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } ); -- add error message
elseif is_set (Series) then -- series is an alias of version
ID_list['ARXIV'] = ID_list['ARXIV'] .. Series; -- concatenate version onto the end of the arxiv identifier
Series = ''; -- unset
deprecated_parameter ('version'); -- deprecated parameter but only for cite arxiv
end
if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL, -- a crude list of parameters that are not supported by cite arxiv
ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } ); -- add error message
AccessDate= ''; -- set these to empty string; not supported in cite arXiv
PublisherName = ''; -- (if the article has been published, use cite journal, or other)
Chapter = '';
URL = '';
Format = '';
Page = ''; Pages = ''; At = '';
end
Periodical = 'arXiv'; -- set to arXiv for COinS; after that, must be set to empty string
end
if in_array(config.CitationClass, {"AV-media-notes", "
TitleType = set_titletype (config.CitationClass, TitleType);
if is_set(Degree) and "Thesis" == TitleType then -- special case for cite thesis
TitleType =
end
end
if is_set(TitleType) then -- if type parameter is specified
end
if not is_set (Date) then
Date = Year; -- promote Year to Date
Baris 2.778 ⟶ 2.120:
Date = PublicationDate; -- promote PublicationDate to Date
PublicationDate = ''; -- unset, no longer needed
end
end
if PublicationDate == Date then PublicationDate = ''; end -- if PublicationDate is same as Date, don't display in rendered citation
do -- create defined block to contain local variables error_message
local error_message = '';
-- AirDate has been promoted to Date so not necessary to check it
anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);
if is_set (Year) and is_set (Date) then -- both |date= and |year= not normally needed;
Baris 2.826 ⟶ 2.148:
end
end
if is_set(error_message) then
table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } ); -- add this error message
elseif is_set (DF) then
local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate};
if reformat_dates (date_parameters_list, DF, false) then -- reformat to DF format, use long month names if appropriate
AccessDate = date_parameters_list['access-date']; -- overwrite date holding parameters with reformatted values
ArchiveDate = date_parameters_list['archive-date']; -- TODO: move all dates into this table at the beginning and ...
Date = date_parameters_list['date']; -- ... use them from this table? no in-and-out like we're doing here
DoiBroken = date_parameters_list['doi-broken-date'];
Embargo = date_parameters_list['embargo'];
LayDate = date_parameters_list['lay-date'];
end
end
end -- end of do
Embargo = is_embargoed (Embargo); --
if config.CitationClass == "journal" and not is_set(URL) and is_set(ID_list['PMC']) then
Baris 2.867 ⟶ 2.175:
URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC']; -- set url to be the same as the PMC external link if not embargoed
URLorigin = cfg.id_handlers['PMC'].parameters[1]; -- set URLorigin to parameter name for use in error message if citation is missing a |title=
end
end
-- Test if citation has no title
if not is_set(Title) and
Baris 2.886 ⟶ 2.189:
end
end
if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then -- special case for journal cites
Title = ''; -- set title to empty string
add_maint_cat ('untitled');
end
check_for_url ({ -- add error message when any of these parameters
['title']=Title,
[A:ORIGIN('Chapter')]=Chapter,
[
[
});
Baris 2.919 ⟶ 2.219:
coins_author = c; -- use that instead
end
-- this is the function call to COinS()
local OCinSoutput = COinS({
['Periodical'] =
['Encyclopedia'] =
['Chapter'] = make_coins_title (coins_chapter, ScriptChapter), -- Chapter and ScriptChapter stripped of bold / italic wikimarkup
['Degree'] = Degree; -- cite thesis only
Baris 2.934 ⟶ 2.234:
['Volume'] = Volume,
['Issue'] = Issue,
['Pages'] =
['Edition'] = Edition,
['PublisherName'] = PublisherName
['URL'] = first_set ({ChapterURL, URL}, 2),
['Authors'] = coins_author,
Baris 2.943 ⟶ 2.243:
}, config.CitationClass);
if
Periodical = ''; -- periodical not allowed in
end
if 'newsgroup' == config.CitationClass
if is_set ( PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' ..
end
end
-- Now perform various field substitutions.
Baris 2.959 ⟶ 2.263:
do
local last_first_list;
-- local maximum;
local control = {
format = NameListFormat, -- empty string or 'vanc'
maximum = nil, -- as if display-authors or display-editors not set
lastauthoramp = LastAuthorAmp,
page_name = this_page.text -- get current page name so that we don't wikilink to it via editorlinkn
};
do -- do editor name list first because
control.maximum , editor_etal =
last_first_list, EditorCount = list_people(control, e, editor_etal, 'editor');
if is_set (Editors) then
if editor_etal then
Editors = Editors .. ' ' .. cfg.messages['et al']; -- add et al. to editors parameter beause |display-editors=etal
EditorCount = 2; -- with et al., |editors= is multiple names; spoof to display (eds.) annotation
else
EditorCount = 2; -- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
end
else
Editors = last_first_list; -- either an author name list or an empty string
Baris 2.983 ⟶ 2.289:
EditorCount = 2; -- spoof to display (eds.) annotation
end
end
do -- now do translators
control.maximum
Translators = list_people
end
do -- now do contributors
control.maximum
Contributors = list_people
end
do -- now do authors
control.maximum , author_etal =
if is_set(Coauthors) then -- if the coauthor field is also used, prevent ampersand and et al. formatting.
control.lastauthoramp = nil;
control.maximum = #a + 1;
end
last_first_list = list_people(control, a, author_etal, 'author');
if is_set (Authors) then
Authors, author_etal = name_has_etal (Authors, author_etal, false
if author_etal then
Authors = Authors .. ' ' .. cfg.messages['et al']; -- add et al. to authors parameter
Baris 3.015 ⟶ 2.322:
end
if not is_set(Authors) and is_set(Coauthors) then -- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } ); -- emit error message
end
end
ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
Baris 3.025 ⟶ 2.335:
TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
if not (in_array(config.CitationClass, {'web',
('citation' == config.CitationClass and
ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
end
if not is_set(URL) then
if in_array(config.CitationClass, {"web","podcast", "mailinglist"})
table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
end
--
if is_set(AccessDate) and not is_set(ChapterURL)then -- ChapterURL may be set when
table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
AccessDate = '';
Baris 3.044 ⟶ 2.353:
end
local OriginalURL, OriginalURLorigin, OriginalFormat
if is_set( ArchiveURL ) then
if is_set (
OriginalURL = URL; -- save copy of original source URL
OriginalURLorigin = URLorigin; -- name of url parameter for error messages
OriginalFormat = Format;
if 'no' ~= DeadURL then -- if URL set then archive-url applies to it
URL = ArchiveURL -- swap-in the archive's url
URLorigin = A:ORIGIN('ArchiveURL') -- name of archive url parameter for error messages
Format = ArchiveFormat or ''; -- swap in archive's format
end
elseif is_set (ChapterURL) then -- URL not set so if chapter-url is set apply archive url to it
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
OriginalURLorigin = ChapterURLorigin; -- name of chapter-url parameter for error messages
OriginalFormat = ChapterFormat; -- and original |format=
if 'no' ~= DeadURL then
ChapterURL = ArchiveURL -- swap-in the archive's url
ChapterURLorigin = A:ORIGIN('ArchiveURL') -- name of archive-url parameter for error messages
ChapterFormat = ArchiveFormat or ''; -- swap in archive's format
end
end
end
if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease',
('citation' == config.CitationClass and
local chap_param;
if is_set (Chapter) then -- get a parameter name from one of these chapter related meta-parameters
Baris 3.083 ⟶ 2.387:
chap_param = A:ORIGIN ('ChapterURL')
elseif is_set (ScriptChapter) then
chap_param =
else is_set (ChapterFormat)
chap_param = A:ORIGIN ('ChapterFormat')
Baris 3.099 ⟶ 2.403:
local no_quotes = false; -- default assume that we will be quoting the chapter parameter value
if is_set (Contribution) and 0 < #c then -- if this is a contribution with contributor(s)
if in_array (Contribution:lower(), cfg.
no_quotes = true; -- then render it unquoted
end
end
Chapter = format_chapter_title (ScriptChapter
if is_set (Chapter) then
Chapter = Chapter .. ChapterFormat ;
Baris 3.116 ⟶ 2.420:
end
-- Format main title.
if is_set
Title = "[[" .. TitleLink .. "|" .. Title .. "]]"
end
if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
('map' == config.CitationClass and is_set (Periodical)) then -- special case for cite map when the map is in a periodical treat as an article
Title = kern_quotes (Title); -- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
Title = wrap_style ('quoted-title', Title);
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle= wrap_style ('trans-quoted-title', TransTitle );
elseif 'report' == config.CitationClass then -- no styling for cite report
Title = script_concatenate (Title, ScriptTitle
TransTitle= wrap_style ('trans-quoted-title', TransTitle ); -- for cite report, use this form for trans-title
else
Title = wrap_style ('italic-title', Title);
Title = script_concatenate (Title, ScriptTitle
TransTitle = wrap_style ('trans-italic-title', TransTitle);
end
Baris 3.158 ⟶ 2.450:
end
end
Title = Title .. TransTitle;
if is_set(Title) then
if not is_set(TitleLink) and is_set(URL) then
Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
URL = "";
Format = "";
else
Title = Title .. TransError;
end
end
Baris 3.196 ⟶ 2.469:
if is_set (Conference) then
if is_set (ConferenceURL) then
Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin
end
Conference = sepc .. " " .. Conference .. ConferenceFormat;
elseif is_set(ConferenceURL) then
Conference = sepc .. " " .. external_link( ConferenceURL, nil, ConferenceURLorigin
end
Baris 3.233 ⟶ 2.506:
At = is_set(At) and (sepc .. " " .. At) or "";
Position = is_set(Position) and (sepc .. " " .. Position) or "";
if config.CitationClass == 'map' then
local Section = A['Section'];
local Sections = A['Sections'];
local Inset = A['Inset'];
Baris 3.254 ⟶ 2.527:
else
Language=""; -- language not specified so make sure this is an empty string;
end
Baris 3.262 ⟶ 2.532:
if is_set (Translators) then
Others =
end
TitleNote = is_set(TitleNote) and (sepc .. " " .. TitleNote) or "";
if is_set (Edition) then
Baris 3.278 ⟶ 2.545:
end
Series = is_set
OrigYear = is_set
Agency = is_set
Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);
------------------------------------ totally unrelated data
Via = " " .. wrap_msg ('via', Via);
end
--[[
Subscription implies paywall; Registration does not. If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.
]]
if is_set (SubscriptionRequired) then
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription']; -- subscription required message
elseif is_set (RegistrationRequired) then
SubscriptionRequired = sepc .. " " .. cfg.messages['registration']; -- registration required message
else
SubscriptionRequired = ''; -- either or both might be set to something other than yes true y
end
if is_set(AccessDate) then
Baris 3.290 ⟶ 2.573:
AccessDate = nowrap_date (AccessDate); -- wrap in nowrap span if date in appropriate format
if (sepc ~= ".") then retrv_text = retrv_text:lower() end -- if
AccessDate = substitute (retrv_text, AccessDate); -- add retrieved text
-- neither of these work; don't know why; it seems that substitute() isn't being called
AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate}); -- allow editors to hide accessdates
end
if is_set(ID) then ID = sepc .." ".. ID; end
if "
ID = sepc .." Docket ".. Docket .. ID;
end
Baris 3.304 ⟶ 2.587:
end
ID_list = build_id_list( ID_list, {
if is_set(URL) then
URL = " " .. external_link( URL, nil, URLorigin
end
Baris 3.320 ⟶ 2.603:
local Archived
if is_set(ArchiveURL) then
if not is_set(ArchiveDate) then
ArchiveDate = set_error('archive_missing_date');
end
if "
local arch_text = cfg.messages['archived'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( cfg.messages['archived-
{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL')
if not is_set
Archived = Archived .. " " .. set_error('archive_missing_url');
end
elseif is_set(OriginalURL) then --
local arch_text = cfg.messages['archived-dead'];
if sepc ~= "." then arch_text = arch_text:lower() end
if in_array (DeadURL, {'unfit', 'usurped'}) then
Archived = sepc .. " " ..
else -- DeadURL is empty, 'yes', 'true', or 'y'
Archived = sepc .. " " .. substitute( arch_text,
{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin
end
else
local arch_text = cfg.messages['archived-missing'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
Baris 3.369 ⟶ 2.644:
end
if sepc == '.' then
Lay = sepc .. " " .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL')
else
Lay = sepc .. " " .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL')
end
elseif is_set (LayFormat) then -- Test if |lay-format= is given without giving a |lay-url=
Baris 3.379 ⟶ 2.654:
if is_set(Transcript) then
if is_set(TranscriptURL) then
Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin
end
Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
elseif is_set(TranscriptURL) then
Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin
end
local Publisher;
if is_set(
not in_array(config.CitationClass, {"encyclopaedia","web","pressrelease","podcast"}) then
if is_set(PublisherName) then
else
Publisher = PublisherName;
end
elseif is_set(PublicationPlace) then
else
Publisher = "";
end
if is_set(PublicationDate) then
if is_set(Publisher) then
Publisher = Publisher .. ", " .. wrap_msg ('published', PublicationDate);
else
Publisher = PublicationDate;
end
end
if is_set(Publisher) then
Publisher = " (" .. Publisher .. ")";
end
else
if is_set(PublicationDate) then
PublicationDate = " (" .. wrap_msg ('published', PublicationDate) .. ")";
end
if is_set(PublisherName) then
if is_set(PublicationPlace) then
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
end
elseif is_set(PublicationPlace) then
Publisher= sepc .. " " .. PublicationPlace .. PublicationDate;
else
Publisher = PublicationDate;
end
end
-- Several of the above rely upon detecting this as nil, so do it last.
if
if is_set(Title) or is_set(TitleNote) then
Periodical = sepc .. " " ..
else
Periodical =
end
end
if "speech" == config.CitationClass then
TitleNote = " (Speech)";
if is_set (Periodical) then
if is_set (Conference) then
Conference = Conference .. sepc .. " ";
end
end
Baris 3.432 ⟶ 2.732:
if in_array(config.CitationClass, {"journal","citation"}) and is_set(Periodical) then
if is_set(Others) then Others =
tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series,
Language, Edition, Publisher, Agency, Volume}, sepc ); elseif in_array(config.CitationClass, {"book","citation"}) and not is_set(Periodical) then -- special cases for book cites
if is_set (Contributors) then -- when we are citing foreword, preface, introduction, etc
Baris 3.452 ⟶ 2.754:
elseif 'episode' == config.CitationClass then -- special case for cite episode
tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
else -- all other CS1 templates
tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language,
Baris 3.465 ⟶ 2.766:
end
local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
local text;
local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;
Baris 3.487 ⟶ 2.782:
end
if is_set(Authors) then
if is_set(Coauthors) then
if 'vanc' == NameListFormat then -- separate authors and coauthors with proper name-list-separator
Authors = Authors .. ', ' .. Coauthors;
else
Authors = Authors .. '; ' .. Coauthors;
end
end
if not is_set (Date) then -- when date is set it's in parentheses; no Authors termination
Authors = terminate_name_list (Authors, sepc); -- when no date, terminate with 0 or 1 sepc and a space
end
Baris 3.495 ⟶ 2.797:
if is_set(Chapter) and 0 == #c then
in_text = in_text .. cfg.messages['in'] .. " "
if (sepc ~= '.') then in_text = in_text:lower() end -- lowercase for cs2
else
if EditorCount <= 1 then
post_text = ", " .. cfg.messages['editor'];
else
post_text = ", " .. cfg.messages['editors'];
end
end
Editors = terminate_name_list (in_text .. Editors .. post_text, sepc); -- terminate with 0 or 1 sepc and a space
end
Baris 3.510 ⟶ 2.811:
if (sepc ~= '.') then by_text = by_text:lower() end -- lowercase for cs2
Authors = by_text .. Authors; -- author follows title so tweak it here
if is_set (Editors
Authors = terminate_name_list (Authors, sepc); -- terminate with 0 or 1 sepc and a space
end
if
Contributors = terminate_name_list (Contributors, sepc); -- terminate with 0 or 1 sepc and a space
end
Baris 3.536 ⟶ 2.837:
text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
else
if
text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
else
Baris 3.544 ⟶ 2.845:
if is_set(PostScript) and PostScript ~= sepc then
text = safe_join( {text, sepc}, sepc );
text = text:sub(1,-sepc:len()-1);
end
Baris 3.560 ⟶ 2.861:
end
if is_set(Ref) and
local id = Ref
if ('harv' == Ref ) then
Baris 3.573 ⟶ 2.874:
namelist = e;
end
end
options.id = id;
end
if string.len(text:gsub("<span[^>/]*>
z.error_categories = {};
text = set_error('empty_citation');
Baris 3.588 ⟶ 2.885:
end
if is_set(options.id) then -- here we wrap the rendered citation in <cite ...>...</cite> tags
else
end
if
text = text .. " ";
for i,v in ipairs( z.message_tail ) do
if is_set(v[1]) then
if i == #z.message_tail then
else
end
end
Baris 3.611 ⟶ 2.906:
end
if
text = text .. '<span class="citation-comment" style="display:none; color:#33aa33">';
for _, v in ipairs( z.maintenance_cats ) do -- append maintenance categories
text = text .. ' ' .. v .. ' ([[:Kategori:' .. v ..'|link]])';
end
text = text .. '</span>'; -- maintenance mesages (realy just the names of the categories for now)
end
if in_array(no_tracking_cats, {"", "no", "false", "n"}) then
for _, v in ipairs( z.error_categories ) do
end
for _, v in ipairs( z.maintenance_cats ) do -- append maintenance categories
end
for _, v in ipairs( z.properties_cats ) do -- append
end
end
return text
end
--[[--------------------------< C S 1 . C I T A T I O N >------------------------------------------------------
This is used by templates such as {{cite book}} to create the actual citation text.
Baris 3.747 ⟶ 2.936:
]]
local pframe = frame:getParent()
local validation, utilities, identifiers, metadata
if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then -- did the {{#invoke:}} use sandbox version?
Baris 3.759 ⟶ 2.947:
identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
metadata = require ('Module:Citation/CS1/COinS/sandbox');
else -- otherwise
Baris 3.768 ⟶ 2.955:
identifiers = require ('Module:Citation/CS1/Identifiers');
metadata = require ('Module:Citation/CS1/COinS');
end
utilities.set_selected_modules (cfg); -- so that functions in Utilities can see the cfg tables
identifiers.set_selected_modules (cfg, utilities); -- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
validation.set_selected_modules (
metadata.set_selected_modules (cfg, utilities); -- so that functions in COinS can see the selected cfg tables and selected Utilities module
Baris 3.780 ⟶ 2.965:
year_date_check = validation.year_date_check;
reformat_dates = validation.reformat_dates;
is_set = utilities.is_set; -- imported functions from Module:Citation/CS1/Utilities
in_array = utilities.in_array;
Baris 3.792 ⟶ 2.975:
wrap_style = utilities.wrap_style;
safe_for_italics = utilities.safe_for_italics;
z = utilities.z; -- table of error and category tables in Module:Citation/CS1/Utilities
extract_ids = identifiers.extract_ids; -- imported functions from Module:Citation/CS1/
build_id_list = identifiers.build_id_list;
is_embargoed = identifiers.is_embargoed;
make_coins_title = metadata.make_coins_title; -- imported functions from Module:Citation/CS1/COinS
Baris 3.807 ⟶ 2.987:
COinS = metadata.COinS;
local args = {};
local suggestions = {};
local error_text, error_state;
local config = {};
for k, v in pairs( frame.args ) do
config[k] = v;
args[k] = v;
end
Baris 3.820 ⟶ 3.001:
for k, v in pairs( pframe.args ) do
if v ~= '' then
if not validate(
error_text = "";
if type( k ) ~= 'string' then
Baris 3.830 ⟶ 3.008:
error_text, error_state = set_error( 'text_ignored', {v}, true );
end
elseif validate( k:lower()
error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
else
if nil == suggestions.suggestions then -- if this table is nil then we need to load it
Baris 3.843 ⟶ 3.021:
capture = k:match (pattern); -- the whole match if no caputre in pattern else the capture if a match
if capture then -- if the pattern matches
param = substitute
error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true ); -- set the error message
end
end
Baris 3.857 ⟶ 3.030:
else
error_text, error_state = set_error( 'parameter_ignored', {k}, true );
end
end
Baris 3.865 ⟶ 3.037:
end
end
args[k] = v;
elseif args[k] ~= nil or (k == 'postscript') then
end
end
Baris 3.876 ⟶ 3.046:
if 'string' == type (k) then -- don't evaluate positional parameters
has_invisible_chars (k, v);
end
end
return citation0( config, args)
end
return cs1;
|