Modul:Citation/CS1: Razlika med redakcijama

Izbrisana vsebina Dodana vsebina
za test
 
Brez povzetka urejanja
Vrstica 1:
local z = {
error_categories = {};
error_ids = {};
message_tail = {};
}
 
-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
 
-- Whether variable is set or not
-- Checks that parameter name is valid
function is_set( var )
return not (var == nil or var == '');
end
 
-- First set variable or nil if none
function first_set(...)
local list = {...};
for _, var in pairs(list) do
if is_set( var ) then
return var;
end
end
end
 
-- Whether needle is in haystack
function inArray( needle, haystack )
if needle == nil then
return false;
end
for n,v in ipairs( haystack ) do
if v == needle then
return n;
end
end
return false;
end
 
-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end
 
-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
if not is_set( str ) then
return "";
elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
str = safeforitalics( str );
end
if lower == true then
return substitute( cfg.messages[key]:lower(), {str} );
else
return substitute( cfg.messages[key], {str} );
end
end
 
--[[
Argument wrapper. This function provides support for argument
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
local origin = {};
return setmetatable({
ORIGIN = function( self, k )
local dummy = self[k]; --force the variable to be loaded.
return origin[k];
end
},
{
__index = function ( tbl, k )
if origin[k] ~= nil then
return nil;
end
local args, list, v = args, cfg.aliases[k];
if type( list ) == 'table' then
v, origin[k] = selectone( args, list, 'redundant_parameters' );
if origin[k] == nil then
origin[k] = ''; -- Empty string, not nil
end
elseif list ~= nil then
v, origin[k] = args[list], list;
else
-- 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
v = cfg.defaults[k] or '';
origin[k] = '';
end
tbl = rawset( tbl, k, v );
return v;
end,
});
end
 
-- Checks that parameter name is valid using the whitelist
function validate( name )
name = tostring( name );
Vrstica 25 ⟶ 124:
end
 
-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencommenterrorcomment( content, hidden )
return wrap( hidden and 'hidden-error' or 'visible-error', content );
return '<span style="display: none;" class="citation-comment">' .. content .. '</span>';
end
 
--[[
-- This returns a string with HTML character entities for wikitext markup characters.
Sets an error condition and returns the appropriate error message. The actual placement
function wikiescape(text)
of the error message in the output is the responsibility of the calling function.
text = text:gsub( '[&\'%[%]{|}]', {
]]
['&'] = '&#38;',
function seterror( error_id, arguments, raw, prefix, suffix )
["'"] = '&#39;',
local error_state = cfg.error_conditions[ error_id ];
['['] = '&#91;',
[']'] = '&#93;',
prefix = prefix or "";
['{'] = '&#123;',
suffix = suffix or "";
['|'] = '&#124;',
['}'] = '&#125;' } );
if error_state == nil then
return text;
error( cfg.messages['undefined_error'] );
end
elseif is_set( error_state.category ) then
 
table.insert( z.error_categories, error_state.category );
-- Create an HTML tag
function createTag(t, frame)
local name = t.name or "!-- --"
local content = t.contents or ""
local attrs = {}
for n,v in pairs(t.params) do
if (v) then
table.insert(attrs, n .. "=\"" .. wikiescape(v) .. "\"")
else
table.insert(attrs, n)
end
end
if ("" == content) then
local message = substitute( error_state.message, arguments );
return "<" .. name .. " " .. table.concat(attrs, " ") .. "/>"
else
message = return "<" .. namemessage .. " " .. table.concat(attrs, [[" ") .. ">" .cfg.messages['help contentpage .. "</"link'] .. name .. ">"
"#" .. error_state.anchor .. "|" ..
cfg.messages['help page label'] .. "]])";
z.error_ids[ error_id ] = true;
if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
and z.error_ids['citation_missing_title'] then
return '', false;
end
end
message = table.concat({ prefix, message, suffix });
 
--[[
if raw == true then
This is a clone of mw.text.nowiki. When the mw.text library is installed,
return message, error_state.hidden;
this can be replaced by a call to that library.
end
]]
function nowiki( s )
return errorcomment( message, error_state.hidden );
-- string.gsub is safe here, because we're only caring about ASCII chars
s = string.gsub( s, '["&\'<=>%[%]{|}]', {
['"'] = '&#34;',
['&'] = '&#38;',
["'"] = '&#39;',
['<'] = '&#60;',
['='] = '&#61;',
['>'] = '&#62;',
['['] = '&#91;',
[']'] = '&#93;',
['{'] = '&#123;',
['|'] = '&#124;',
['}'] = '&#125;',
} )
s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
["\n#"] = "\n&#35;",
["\n*"] = "\n&#42;",
["\n:"] = "\n&#58;",
["\n;"] = "\n&#59;",
} ), 2 )
s = string.gsub( s, '://', '&#58;//' )
s = string.gsub( s, 'ISBN ', 'ISBN&#32;' )
s = string.gsub( s, 'RFC ', 'RFC&#32;' )
 
return s
end
 
-- Formats a wiki style external link
function externallinkid(options)
local sepurl_string = options.separator or "&nbspid;"
options.suffix = options.suffix or ""
local url_string = options.id
if options.encode == true or options.encode == nil then
url_string = mw.uri.encode( url_string );
end
return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
return "[[" .. options.link .. "|" .., options.label, options..separator "]]" .. sep ..or "[&nbsp;" .. ,
options.prefix .., url_string .., options.suffix ..or " ",
mw.text. nowiki(options.id)
.. "]" );
end
 
-- Formats a wiki style internal link
function internallinkid(options)
return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
local sep = options.separator or "&nbsp;"
options.suffixlink, =options.label, options.suffixseparator or "&nbsp;",
return "[[" .. options.linkprefix, options.. "|" ..id, options.labelsuffix ..or "]]" .. sep .. "[[" .. ,
optionsmw.prefix text.. options.id .. options.suffix .. "|" .. nowiki(options.id) .. "]]"
);
end
 
-- Format an external link with error checking
function externallink( URL, label, source )
local error_str = "";
if not is_set( label ) then
label = URL;
if is_set( source ) then
error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, " " );
else
error( cfg.messages["bare_url_no_origin"] );
end
end
if not checkurl( URL ) then
error_str = seterror( 'bad_url', {}, false, " " ) .. error_str;
end
return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str });
end
 
-- Formats a link to Amazon
function amazon(id, domain)
if not is_set( nil == domain ) then
domain = "com"
elseif ( "jp" == domain or "uk" == domain ) then
domain = "co." .. domain
end
local handler = cfg.id_handlers['ASIN'];
return externallinkid({link="Amazon Standard Identification Number",
return externallinkid({link = handler.link,
label="ASIN",prefix="//www.amazon."..domain.."/dp/",id=id,encode=false})
label=handler.label , prefix="//www.amazon."..domain.."/dp/",id=id,
encode=handler.encode, separator = handler.separator})
end
 
Vrstica 129 ⟶ 221:
function doi(id, inactive)
local cat = ""
local handler = cfg.id_handlers['DOI'];
local text;
if is_set( inactive ~= nil ) then
text = "[[Digital" object.. identifierhandler.link .. "|doi" .. handler.label .. "]]:" .. id;
table.insert( z.error_categories, "Pages with DOIs inactive since " .. selectyear(inactive) );
inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
else
text = externallinkid({link ="Digital object identifier"handler.link, label ="doi" handler.label,
prefix="http://dxhandler.doi.org/"prefix,id=id,separator=":"handler.separator, encode=handler.encode})
inactive = ""
end
if ( string.sub(id,1,3) ~= "10." ) then
cat = seterror( 'bad_doi' );
table.insert( z.error_categories, "Pages with DOI errors" );
cat = ' <span class="error">Bad DOI (expected "10." prefix) in code number</span>'
end
return text .. inactive .. cat
end
 
-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
local code = id:sub(-1,-1)
local handler = cfg.id_handlers['OL'];
if ( code == "A" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/authors/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "M" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix="http://openlibrary.org/books/OL",id=id, separator=handler.separator,
encode = handler.encode})
elseif ( code == "W" ) then
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/works/OL",id=id, separator=handler.separator,
encode = handler.encode})
else
return externallinkid({link=handler.link, label=handler.label,
prefix= "http://openlibrary.org/OL",id=id, separator=handler.separator,
encode = handler.encode}) ..
' ' .. seterror( 'bad_ol' );
end
end
 
--[[
Determines whether an URL string is valid
 
At present the only check is whether the string appears to
be prefixed with a URI scheme. It is not determined whether
the URI scheme is valid or whether the URL is otherwise well
formed.
]]
function checkurl( url_str )
-- Protocol-relative or URL scheme
return url_str:sub(1,2) == "//" or url_str:match( "^[^/]*:" ) ~= nil;
end
 
-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
return isbn_str:gsub( "[^-0-9X]", "" );
end
 
-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
isbn_str = cleanisbn( isbn_str ):gsub( "-", "" );
local len = isbn_str:len();
if len ~= 10 and len ~= 13 then
return false;
end
local temp = 0;
if len == 10 then
if isbn_str:match( "^%d*X?$" ) == nil then return false; end
isbn_str = { isbn_str:byte(1, len) };
for i, v in ipairs( isbn_str ) do
if v == string.byte( "X" ) then
temp = temp + 10*( 11 - i );
else
temp = temp + tonumber( string.char(v) )*(11-i);
end
end
return temp % 11 == 0;
else
if isbn_str:match( "^%d*$" ) == nil then return false; end
isbn_str = { isbn_str:byte(1, len) };
for i, v in ipairs( isbn_str ) do
temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
end
return temp % 10 == 0;
end
end
 
-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
return (str:gsub( "%[%[([^%[%]]*)%]%]", function(l)
return l:gsub( "^[^|]*|(.*)$", "%1" ):gsub("^%s*(.-)%s*$", "%1");
end));
end
 
-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
if str:match( "%[%[.-%]%]" ) ~= nil then
table.insert( z.error_categoriesmessage_tail, "Pages{ withseterror( citations'wikilink_in_url', having wikilinks embedded{}, intrue URL) titles"} );
table.insert( z.message_tail, "Wikilink embedded in URL title" );
end
return str:gsub( '[%[%]\n]', {
['['] = '&#91;',
[']'] = '&#93;',
['\n'] = ' ' } );
end
Vrstica 162 ⟶ 334:
-- Converts a hyphen to a dash
function hyphentodash( str )
if not is_set(str) or str:match( "[%[%]{}<>]" ) =~= nil then
return nil;
end
if str:match( "[%[%]{}<>]" ) ~= nil then
return str;
end
Vrstica 178 ⟶ 347:
tend to interact poorly under Mediawiki's HTML tidy. ]]
if str == nil ornot is_set(str == '') then
return str;
else
if str:sub(1,1) == "'" then str = "<span />" .. str; end
if str:sub(-1,-1) == "'" then str = str .. "<span />"; end
return str;
-- Remove newlines as they break italics.
return str:gsub( '\n', ' ' );
end
end
Vrstica 268 ⟶ 439:
-- Is the input a simple number?
local num = tonumber( str );
if num ~= nil and num > 0 and num < 2100 and num == math.absfloor(num) then
return str;
else
Vrstica 281 ⟶ 452:
return "";
end
end
end
 
-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
local code = id:sub(-1,-1)
if ( code == "A" ) then
return externallinkid({link="Open Library",label="OL",
prefix="http://openlibrary.org/authors/OL",id=id})
elseif ( code == "M" ) then
return externallinkid({link="Open Library",label="OL",
prefix="http://openlibrary.org/books/OL",id=id})
elseif ( code == "W" ) then
return externallinkid({link="Open Library",label="OL",
prefix= "http://openlibrary.org/works/OL",id=id})
else
table.insert( z.error_categories, "Pages with OL errors" );
return externallinkid({link="Open Library",label="OL",
prefix= "http://openlibrary.org/OL",id=id}) ..
' <span class="error">Bad OL specified</span>';
end
end
Vrstica 316 ⟶ 467:
function listpeople(control, people)
local sep = control.sep;
if sep:sub(-1,-1) ~= " " then sep = sep .. " " end
local namesep = control.namesep
local format = control.format
Vrstica 323 ⟶ 473:
local text = {}
local etal = false;
if sep:sub(-1,-1) ~= " " then sep = sep .. " " end
if maximum ~= nil and maximum < 1 then return "", 0; end
for i,person in ipairs(people) do
if is_set(person.last ~= nil or person.last ~= "") then
local mask = person.mask
local one
iflocal (sep_one maximum ~= nil and i == maximum + 1 ) thensep;
if maximum ~= nil and i > maximum then
etal = true;
break;
Vrstica 335 ⟶ 490:
one = string.rep("&mdash;",n)
else
one = mask;
sep_one = " ";
end
else
one = person.last
local first = person.first
if is_set(first ~= nil and first ~= '') then
if ( "vanc" == format ) then first = reducetoinitials(first) end
one = one .. namesep .. first
end
if is_set(person.link ~= nil and person.link ~= "") then one = "[[" .. person.link .. "|" .. one .. "]]" end
end
table.insert( text, one )
table.insert( text, sep_one )
end
end
 
local count = #text;
local count = #text / 2;
if count > 1 and lastauthoramp ~= nil and lastauthoramp ~= "" and not etal then
if text[count-1] => text[count-1]0 ..then " & " .. text[count];
text[if count] => 1 and is_set(lastauthoramp) and not etal nil;then
end text[#text-2] = " & ";
end
local result = table.concat(text, sep) -- construct list
text[#text] = nil;
end
local result = table.concat(text) -- construct list
if etal then
local etal_text = "cfg.messages['et al."'];
if (sepc == ".") then etal_text = "et al" end
result = result .. " " .. etal_text;
end
-- if necessary wrap result in <span> tag to format in Small Caps
if ( "scap" == format ) then result= createTag({name="span", contents=result,
params={'<span class="smallcaps", style="font-variant:small-caps;"}})>' end.. result .. '</span>';
end
return result, count
end
 
-- Generates a CITEREF anchor ID.
function anchorid( options )
localreturn P1"CITEREF" =.. table.concat( options[1] or "");
local P2 = options[2] or ""
local P3 = options[3] or ""
local P4 = options[4] or ""
local P5 = options[5] or ""
-- Bugzilla 46608
local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
if encoded == false then
encoded = "";
end
return "CITEREF" .. encoded;
end
 
-- Gets authorname list from the input arguments
function extractauthorsextractnames(args, list_name)
local authorsnames = {};
local i = 1;
local last;
while true do
last = selectone( args["author", cfg.. ialiases[list_name .. "'-last"Last'], or args["author-last" ..'redundant_parameters', i] or );
if not is_set(last) then
args["last" .. i] or args["surname" .. i] or args["Author" .. i] or args["author" .. i]
if ( last and "" < last ) then -- just in case someone passed in an empty parameter
authors[i] = {
last = last,
first = args["author" .. i .. "-first"] or args["author-first" .. i] or
args["first" .. i] or args["given" .. i],
link = args["author" .. i .. "-link"] or args["author-link" .. i] or
args["author" .. i .. "link"] or args["authorlink" .. i],
mask = args["author" .. i .. "-mask"] or args["author-mask" .. i] or
args["author" .. i .. "mask"] or args["authormask" .. i]
}
else
break;
end
names[i] = {
last = last,
first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
};
i = i + 1;
end
return authorsnames;
end
 
-- Populates ID table from arguments using configuration settings
-- Gets editor list from the input arguments
function extracteditorsextractids( args )
local editorsid_list = {};
for k, v in pairs( cfg.id_handlers ) do
local i = 1;
v = selectone( args, v.parameters, 'redundant_parameters' );
local last;
if is_set(v) then id_list[k] = v; end
end
return id_list;
end
 
-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
local new_list, handler = {};
function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
while true do
last = args["editor" .. i .. "-last"] or args["editor-last" .. i] or
for k, v in pairs( id_list ) do
args["EditorSurname" .. i] or args["Editor" .. i] or args["editor" .. i]
-- fallback to read-only cfg
if ( last and "" < last ) then -- just in case someone passed in an empty parameter
handler = setmetatable( { editors[i'id'] = {v }, fallback(k) );
last = last,
if handler.mode == 'external' then
first = args["editor" .. i .. "-first"] or args["editor-first" .. i] or args["EditorGiven" .. i],
table.insert( new_list, {handler.label, externallinkid( handler ) } );
link = args["editor" .. i .. "-link"] or args["editor-link" .. i] or
elseif handler.mode == 'internal' then
args["editor" .. i .. "link"] or args["editorlink" .. i],
table.insert( new_list, {handler.label, internallinkid( handler ) } );
mask = args["editor" .. i .. "-mask"] or args["editor-mask" .. i] or
elseif handler.mode ~= 'manual' then
args["editor" .. i .. "mask"] or args["editormask" .. i]
}error( cfg.messages['unknown_ID_mode'] );
elseif k == 'DOI' then
table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
elseif k == 'ASIN' then
table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } );
elseif k == 'OL' then
table.insert( new_list, {handler.label, openlibrary( v ) } );
elseif k == 'ISBN' then
local ISBN = internallinkid( handler );
if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
ISBN = ISBN .. seterror( 'bad_isbn', {}, false, " ", "" );
end
table.insert( new_list, {handler.label, ISBN } );
else
breakerror( cfg.messages['unknown_manual_ID'] );
end
i = i + 1;
end
return editors;
function comp( a, b )
return a[1] < b[1];
end
table.sort( new_list, comp );
for k, v in ipairs( new_list ) do
new_list[k] = v[2];
end
return new_list;
end
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
local value = nil;
local selected = '';
local error_list = {};
if index ~= nil then index = tostring(index); end
-- Handle special case of "#" replaced by empty string
if index == '1' then
for _, v in ipairs( possible ) do
v = v:gsub( "#", "" );
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
end
for _, v in ipairs( possible ) do
if index ~= nil then
v = v:gsub( "#", index );
end
if is_set(args[v]) then
if value ~= nil and selected ~= v then
table.insert( error_list, v );
else
value = args[v];
selected = v;
end
end
end
if #error_list > 0 then
local error_str = "";
for _, k in ipairs( error_list ) do
if error_str ~= "" then error_str = error_str .. cfg.messages['parameter-separator'] end
error_str = error_str .. wrap( 'parameter', k );
end
if #error_list > 1 then
error_str = error_str .. cfg.messages['parameter-final-separator'];
else
error_str = error_str .. cfg.messages['parameter-pair-separator'];
end
error_str = error_str .. wrap( 'parameter', selected );
table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
end
return value, selected;
end
 
-- COinS metadata (see <http://ocoins.info/>) allows automated tools to parse
-- the citation information.
function COinS(data)
if 'table' ~= type(data) or nil == next(data) then
return '';
end
local ctx_ver = "Z39.88-2004";
-- treat table strictly as an array with only set values.
local OCinSoutput = setmetatable( {}, {
__newindex = function(self, key, value)
if is_set(value) then
rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
end
end
});
if is_set(data.Chapter) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "bookitem";
OCinSoutput["rft.btitle"] = data.Chapter;
OCinSoutput["rft.atitle"] = data.Title;
elseif is_set(data.Periodical) then
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:journal";
OCinSoutput["rft.genre"] = "article";
OCinSoutput["rft.jtitle"] = data.Periodical;
OCinSoutput["rft.atitle"] = data.Title;
else
OCinSoutput.rft_val_fmt = "info:ofi/fmt:kev:mtx:book";
OCinSoutput["rft.genre"] = "book"
OCinSoutput["rft.btitle"] = data.Title;
end
OCinSoutput["rft.place"] = data.PublicationPlace;
OCinSoutput["rft.date"] = data.Date;
OCinSoutput["rft.series"] = data.Series;
OCinSoutput["rft.volume"] = data.Volume;
OCinSoutput["rft.issue"] = data.Issue;
OCinSoutput["rft.pages"] = data.Pages;
OCinSoutput["rft.edition"] = data.Edition;
OCinSoutput["rft.pub"] = data.PublisherName;
for k, v in pairs( data.ID_list ) do
local id, value = cfg.id_handlers[k].COinS;
if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
if string.sub( id or "", 1, 4 ) == 'info' then
OCinSoutput["rft_id"] = table.concat{ id, "/", v };
else
OCinSoutput[ id ] = value;
end
end
local last, first;
for k, v in ipairs( data.Authors ) do
last, first = v.last, v.first;
if k == 1 then
if is_set(last) then
OCinSoutput["rft.aulast"] = last;
end
if is_set(first) then
OCinSoutput["rft.aufirst"] = first;
end
end
if is_set(last) and is_set(first) then
OCinSoutput["rft.au"] = table.concat{ last, ", ", first };
elseif is_set(last) then
OCinSoutput["rft.au"] = last;
end
end
OCinSoutput.rft_id = data.URL;
OCinSoutput.rfr_id = table.concat{ "info:sid/", mw.site.server:match( "[^/]*$" ), ":", data.RawPage };
OCinSoutput = setmetatable( OCinSoutput, nil );
-- sort with version string always first, and combine.
table.sort( OCinSoutput );
table.insert( OCinSoutput, 1, "ctx_ver=" .. ctx_ver ); -- such as "Z39.88-2004"
return table.concat(OCinSoutput, "&");
end
 
Vrstica 442 ⟶ 753:
]]
function citation0( config, args)
--[[
Load Input Parameters
The argment_wrapper facillitates the mapping of multiple
aliases to single internal variable.
]]
local A = argument_wrapper( args );
 
local PPrefixi = config.PPrefix or "p.&nbsp;"
local PPPrefixPPrefix = config.PPPrefix or "pp.&nbsp;"A['PPrefix']
iflocal (PPPrefix nil ~= args.nopp ) then A['PPPrefix = "" PPrefix = "" end']
if is_set( A['NoPP'] ) then PPPrefix = "" PPrefix = "" end
-- Transfer unnumbered arguments to numbered arguments if necessary.
args["author1"] = args.author1 or args.author or args.authors
args["author1-last"] = args["author1-last"] or args["author-last"] or args["last"]
args["author1-first"] = args["author1-first"] or args["author-first"]
or args.first or args.first1 or args.given or args.given1
args["author1-link"] = args["author1-link"] or args["author-link"]
args["author1-mask"] = args["author1-mask"] or args["author-mask"] or args["authormask"]
args["author1link"] = args["author1link"] or args["authorlink"]
args["editor1"] = args["editor1"] or args["editor"]
args["editor1-last"] = args["editor1-last"] or args["editor-last"]
args["editor1-first"] = args["editor1-first"] or args["editor-first"]
args["editor1-link"] = args["editor1-link"] or args["editor-link"]
args["editor1-mask"] = args["editor1-mask"] or args["editor-mask"] or args["editormask"]
args["editor1link"] = args["editor1link"] or args["editorlink"]
 
-- Pick out the relevant fields from the arguments. Different citation templates
-- define different field names for the same underlying things.
local Authors = args.authorsA['Authors'];
local ia = extractnames( args, 'AuthorList' );
local a = extractauthors( args );
 
local Coauthors = args.coauthors or args.coauthor A['Coauthors'];
local Others = args.others A['Others'];
local EditorMaskEditors = args.editormask or argsA["editor-mask"'Editors'];
local EditorFormate = extractnames( args["editor-format"], or'EditorList' args.editorformat);
local Editors = args.editors
local e = extracteditors( args );
 
local Year = args.year A['Year'];
local PublicationDate = args.publicationdate or argsA["publication-date"'PublicationDate'];
local OrigYear = args.origyearA['OrigYear'];
local Date = args.dateA['Date'];
local LayDate = args.laydateA['LayDate'];
------------------------------------------------- Get title data
local Title = A['Title'];
local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
local BookTitle = args.booktitleA['BookTitle'];
local Conference = args.conferenceA['Conference'];
local TransTitle = args.trans_titleA['TransTitle'];
local TitleNote = args.departmentA['TitleNote'];
local TitleLink = args.titlelink or args.episodelinkA['TitleLink'];
local Chapter = args.chapter or args.contribution or args.entryA['Chapter'];
local ChapterLink = args.chapterlinkA['ChapterLink'];
local TransChapter = argsA["trans-chapter"'TransChapter'] or args.trans_chapter;
local TitleType = args.typeA['TitleType'];
local ArchiveURL = argsA["archive-url"'ArchiveURL'] or args.archiveurl;
local URL = args.url or args.A['URL']
local URLorigin = A:ORIGIN('URL');
local ChapterURL = args["chapter-url"] or args.chapterurl or args["contribution-url"]
local ConferenceURLChapterURL = argsA["conference-url"'ChapterURL'] or args.conferenceurl;
local ChapterURLorigin = A:ORIGIN('ChapterURL');
local Periodical = args.journal or args.newspaper or args.magazine or args.work
local ConferenceURL = A['ConferenceURL'];
or args.periodical or args.encyclopedia or args.encyclopaedia
local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
local Periodical = A['Periodical'];
if ( config.CitationClass == "encyclopaedia" ) then
if not is_set( args.article and args.article ~= ""Chapter) then
if not is_set( Title and Title ~= "") then Periodical = Title end
Chapter Title = args.articlePeriodical;
TransChapter Periodical = TransTitle'';
Title = nil else
TransTitle = nil
elseif ( Chapter == nil or Chapter == '' ) then
if Title ~= args.encyclopedia then
Chapter = Title
TransChapter = TransTitle
Title = nil '';
TransTitle = nil'';
end
end
if ( Periodical and Periodical ~= "") then
if Periodical == Title or Periodical == Chapter then Periodical = nil end
end
end
 
local Series = args.series or args.version
local VolumeSeries = args.volumeA['Series'];
local IssueVolume = args.issue or args.numberA['Volume'];
local PositionIssue = nilA['Issue'];
local PagePosition = args.p or args.page'';
local Page, Pages, = hyphentodash( args.pp or args.pagesAt, )page_type;
local At = args.at
local page_error = false;
if Page ~= nil and A['Page ~= '' then];
if (Pages ~= nil andhyphentodash( A['Pages ~= '')] or (At ~= nil and At ~= '') then;
PagesAt = nilA['At'];
At = nil;
if is_set(Page) then
page_error = true;
if is_set(Pages) or is_set(At) then
Page = Page .. " " .. seterror('extra_pages');
Pages = '';
At = '';
end
elseif is_set(Pages ~= nil and Pages ~= '') then
if is_set(At ~= nil and At ~= '') then
AtPages = nilPages .. " " .. seterror('extra_pages');
page_errorAt = true'';
end
end
local Edition = A['Edition'];
local PublicationPlace = A['PublicationPlace']
local Place = A['Place'];
if not is_set(PublicationPlace) and is_set(Place) then
PublicationPlace = Place;
end
if PublicationPlace == Place then Place = ''; end
local Edition = args.edition
local PublicationPlace = args["publication-place"] or args.publicationplace
or args.place or args.location
local Place = args.place or args.location
if PublicationPlace == Place then Place = nil; end
local PublisherName = args.publisherA['PublisherName'];
local SubscriptionRequiredRegistrationRequired = args.subscriptionA['RegistrationRequired'];
local ViaSubscriptionRequired = args.viaA['SubscriptionRequired'];
local AccessDateVia = argsA["access-date"'Via'] or args.accessdate;
local ArchiveDateAccessDate = argsA["archive-date"'AccessDate'] or args.archivedate;
local AgencyArchiveDate = args.agencyA['ArchiveDate'];
local Agency = A['Agency'];
local DeadURL = args.deadurl or "yes" -- Only used is ArchiveURL is present.
local LanguageDeadURL = args.language or argsA["in"'DeadURL']
local FormatLanguage = args.formatA['Language'];
local RefFormat = args.ref or args.RefA['Format'];
local ARXIVRef = args.arxiv or args.ARXIVA['Ref'];
local ASIN = args.asin or args.ASIN
local ASINTLDDoiBroken = argsA["ASIN-TLD"] or args["asin-tld"'DoiBroken'];
local BIBCODEID = args.bibcode or args.BIBCODEA['ID'];
local DOIASINTLD = args.doi or args.DOIA['ASINTLD'];
local IgnoreISBN = A['IgnoreISBN'];
local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
 
local ID = args.id or args.ID
local ISBNID_list = args.isbn13 orextractids( args.isbn or args.ISBN);
local ISSN = args.issn or args.ISSN
local JFMQuote = args.jfm or args.JFMA['Quote'];
local JSTORPostScript = args.jstor or args.JSTORA['PostScript'];
local LCCNLayURL = args.lccn or args.LCCNA['LayURL'];
local MRLaySource = args.mr or args.MRA['LaySource'];
local OCLCTranscript = args.oclc or args.OCLCA['Transcript'];
local OLTranscriptURL = args.olA['TranscriptURL'] or args.OL
local OSTITranscriptURLorigin = args.osti or args.OSTIA:ORIGIN('TranscriptURL');
local PMCsepc = args.pmc or args.PMCA['Separator'];
local PMIDLastAuthorAmp = args.pmid or args.PMIDA['LastAuthorAmp'];
local RFCno_tracking_cats = args.rfc or args.RFCA['NoTracking'];
 
local SSRN = args.ssrn or args.SSRN
local ZBLuse_lowercase = args.zbl( orsepc args~= '.ZBL' );
local Quotethis_page = argsmw.quotetitle.getCurrentTitle(); or args.quotation--Also used for COinS
local PostScript = args.postscript or "."
if not is_set(no_tracking_cats) then
local LaySummary = args.laysummary
for k, v in pairs( cfg.uncategorized_namespaces ) do
local LaySource = args.laysource
if this_page.nsText == v then
local Transcript = args.transcript
no_tracking_cats = "true";
local TranscriptURL = args["transcript-url"] or args.transcripturl
break;
local sepc = args.separator or "."
end
local LastAuthorAmp = args.lastauthoramp
end
local no_tracking_cats = args["template doc demo"] or args.nocat or
end
args.notracking or args["no-tracking"] or "";
 
if ( config.CitationClass == "journal" ) then
if not is_set(URL) ==and nil or URL == ""is_set(ID_list['PMC']) then
if (PMC ~=local nilEmbargo and= PMC ~="")A['Embargo'];
if is_set(Embargo) then
then URL="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC" .. PMC
else URL local lang =nil mw.getContentLanguage();
local good1, result1, good2, result2;
end
good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
good2, result2 = pcall( lang.formatDate, lang, 'U' );
if good1 and good2 and tonumber( result1 ) < tonumber( result2 ) then
URL = "http://www.ncbi.nlm.nih.gov/pmc/articles/PMC" .. ID_list['PMC'];
URLorigin = cfg.id_handlers['PMC'].parameters[1];
end
else
URL = "http://www.ncbi.nlm.nih.gov/pmc/articles/PMC" .. ID_list['PMC'];
URLorigin = cfg.id_handlers['PMC'].parameters[1];
end
end
end
Vrstica 600 ⟶ 912:
-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
if is_set( BookTitle ) then
Chapter = Title;
ChapterLink = TitleLink;
TransChapter = TransTitle;
Title = BookTitle;
TitleLink = nil'';
TransTitle = nil'';
end
-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
if config.CitationClass == "episode" then
local AirDate = args.airdateA['AirDate'];
local SeriesLink = args.serieslinkA['SeriesLink'];
local Season = args.seasonA['Season'];
local SeriesNumber = args.seriesnumber or args.seriesnoA['SeriesNumber'];
local Network = args.networkA['Network'];
local Station = args.stationA['Station'];
local s, n = {}, {};
local Sep = (first_set(A["SeriesSeparator"], A["Separator"]) or "") .. " ";
if Issue ~= nil then table.insert(s, "episode " .. Issue) Issue = nil end
if Season ~= nil then table.insert(s, "season " .. Season) end
if SeriesNumber ~= nilis_set(Issue) then table.insert(s, cfg.messages["episode"] .. "series " .. SeriesNumberIssue); Issue = ''; end
if is_set(Season) then table.insert(s, cfg.messages["season"] .. " " .. Season); end
local n = {}
if Network ~= nilis_set(SeriesNumber) then table.insert(ns, Networkcfg.messages["series"] .. " " .. SeriesNumber); end
if Station ~= nilis_set(Network) then table.insert(n, StationNetwork); end
if is_set(Station) then table.insert(n, Station); end
Date = Date or AirDate
Chapter = Title
ChapterLinkDate = TitleLinkDate or AirDate;
TransChapterChapter = TransTitleTitle;
TitleChapterLink = SeriesTitleLink;
TitleLinkTransChapter = SeriesLinkTransTitle;
TransTitleTitle = nilSeries;
TitleLink = SeriesLink;
local Sep = args["series-separator"] or args["separator"] or ". "
SeriesTransTitle = table.concat(s, Sep)'';
ID
Series = table.concat(ns, Sep);
ID = table.concat(n, Sep);
end
-- These data form a COinS tagmetadata (see <http://ocoins.info/>) which allows for
-- automated toolsparsing to parse theof citation information.
local OCinSoutput = COinS{
local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
['Periodical'] = Periodical,
local ctx_ver = "Z39.88-2004"
['Chapter'] = Chapter,
OCinSdata.rft_val_fmt = "info:ofi/fmt:kev:mtx:book"
if ( nil ~= Periodical['Title'] )= thenTitle,
['PublicationPlace'] = PublicationPlace,
OCinSdata.rft_val_fmt = "info:ofi/fmt:kev:mtx:journal"
['Date'] = first_set(Date, Year, PublicationDate),
OCinSdata["rft.genre"] = "article"
OCinSdata["rft.jtitle"'Series'] = PeriodicalSeries,
['Volume'] = Volume,
if ( nil ~= Title ) then OCinSdata["rft.atitle"] = Title end
['Issue'] = Issue,
end
['Pages'] = first_set(Page, Pages, At),
if ( nil ~= Chapter and "" ~= Chapter) then
['Edition'] = Edition,
OCinSdata.rft_val_fmt = "info:ofi/fmt:kev:mtx:book"
OCinSdata["rft.genre"'PublisherName'] = "bookitem"PublisherName,
OCinSdata["rft.btitle"'URL'] = Chapterfirst_set( URL, ChapterURL ),
['Authors'] = a,
if ( nil ~= Title ) then OCinSdata["rft.atitle"] = Title end
['ID_list'] = ID_list,
else
OCinSdata["rft.genre"'RawPage'] = "book"this_page.prefixedText,
};
if ( nil ~= Title ) then OCinSdata["rft.btitle"] = Title end
end
OCinSdata["rft.place"] = PublicationPlace
OCinSdata["rft.date"] = Date or Year or PublicationDate
OCinSdata["rft.series"] = Series
OCinSdata["rft.volume"] = Volume
OCinSdata["rft.issue"] = Issue
OCinSdata["rft.pages"] = Page or Pages or At
OCinSdata["rft.edition"] = Edition
OCinSdata["rft.pub"] = PublisherName
OCinSdata["rft.isbn"] = ISBN
OCinSdata["rft.issn"] = ISSN
OCinSdata["rft.jfm"] = JFM
OCinSdata["rft.jstor"] = JSTOR
OCinSdata["rft.lccn"] = LCCN
OCinSdata["rft.mr"] = MR
OCinSdata.rft_id = URL or ChapterURL
 
local last, first;
local OCinSauthors = {};
for k, v in ipairs( a ) do
last = v.last;
first = v.first;
if k == 1 then
if last ~= nil then
OCinSdata["rft.aulast"] = last;
end
if first ~= nil then
OCinSdata["rft.aufirst"] = first;
end
end
if last ~= nil and first ~= nil then
table.insert( OCinSauthors, last .. (args.NameSep or ", ") .. first );
elseif last ~= nil then
table.insert( OCinSauthors, last );
end
end
 
local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
OCinSids["info:arxiv"] = ARXIV
OCinSids["info:asin"] = ASIN
OCinSids["info:bibcode"] = BIBCODE
OCinSids["info:doi"] = DOI
OCinSids["info:oclcnum"] = OCLC
OCinSids["info:olnum"] = OL
OCinSids["info:osti"] = OSTI
OCinSids["info:pmc"] = PMC
OCinSids["info:pmid"] = PMID
OCinSids["info:rfc"] = RFC
OCinSids["info:ssrn"] = SSRN
OCinSids["info:zbl"] = ZBL
local OCinStitle = "ctx_ver=" .. ctx_ver -- such as "Z39.88-2004"
for name,value in pairs(OCinSdata) do
OCinStitle = OCinStitle .. "&" .. name .. "=" .. mw.uri.encode(value)
end
for _, value in ipairs(OCinSauthors) do
OCinStitle = OCinStitle .. "&rft.au=" .. mw.uri.encode(value)
end
for name,value in pairs(OCinSids) do
OCinStitle = OCinStitle .. "&rft_id=" .. mw.uri.encode(name .. "/" .. value)
end
local this_page = mw.title.getCurrentTitle();
OCinStitle = OCinStitle .. "&rfr_id=info:sid/en.wikipedia.org:"
.. this_page.prefixedText -- end COinS data by page's non-encoded pagename
 
if is_set(Periodical ~= nil) and Periodicalnot ~= ""is_set(Chapter) and is_set(Title) then
(Chapter == nil or Chapter == '') andTitle;
(TitleChapterLink ~= nil and Title ~= "") thenTitleLink;
ChapterTransChapter = TitleTransTitle;
ChapterLinkTitle = TitleLink'';
TransChapterTitleLink = TransTitle'';
TitleTransTitle = nil'';
TitleLink = nil
TransTitle = nil
end
 
Vrstica 733 ⟶ 981:
-- We also add leading spaces and surrounding markup and punctuation to the
-- various parts of the citation, but only when they are non-nil.
if not is_set( Authors == nil ) then
local Maximum = tonumber(args A["display-authors"'DisplayAuthors'] or args.displayauthors);
-- Preserve old-style implicit et al.
if not is_set(Maximum == nil) and #a == 9 then
Maximum = 8;
table.insert( z.error_categoriesmessage_tail, { seterror('Pagesimplict_etal_author', using{}, citationstrue with) old-style implicit et al.'} );
elseif not is_set(Maximum) then
table.insert( z.message_tail, 'Citation uses old-style implicit et al. for authors' );
elseif Maximum == nil then
Maximum = #a + 1;
end
local control = {
sep = (argsA["author-separatorAuthorSeparator"] or ";") .. " ",
namesep = (argsfirst_set(A["author-name-separatorAuthorNameSeparator"], or argsA["name-separatorNameSeparator"]) or ",") .. " ",
format = argsA["author-formatAuthorFormat"] or args.authorformat,
maximum = Maximum,
lastauthoramp = LastAuthorAmp
};
-- If the coauthor field is also used, prevent ampersand and et al. formatting.
if is_set(Coauthors ~= nil and Coauthors ~= "") then
control.lastauthoramp = nil;
control.maximum = #a + 1;
end
Authors = listpeople(control, a)
end
local EditorCount
if ( Editors == nil ) then
local Maximum = tonumber(args["display-editors"] or args.displayeditors);
 
local EditorCount
if not is_set(Editors) then
local Maximum = tonumber( A['DisplayEditors'] );
-- Preserve old-style implicit et al.
if not is_set(Maximum == nil) and #e == 4 then
Maximum = 3;
table.insert( z.error_categoriesmessage_tail, { seterror('Pagesimplict_etal_editor', using{}, citationstrue) with old-style implicit et al.'} );
elseif not is_set(Maximum) then
table.insert( z.message_tail, 'Citation uses old-style implicit et al. for editors' );
elseif Maximum == nil then
Maximum = #e + 1;
end
 
local control = {
sep = (argsA["editor-separatorEditorSeparator"] or ";") .. " ",
namesep = (argsfirst_set(A["editor-name-separatorEditorNameSeparator"], or argsA["name-separatorNameSeparator"]) or ",") .. " ",
format = argsA["editor-format"'EditorFormat'] or args.editorformat,
maximum = Maximum,
lastauthoramp = LastAuthorAmp
};
 
Editors, EditorCount = listpeople(control, e) ;
else
EditorCount = 1;
end
 
if ( Date == nil or Date == "") then
local Cartography = "";
-- there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[ local DateScale = Year"";
if (config.CitationClass Date ~== nil )"map" then
if not is_set( Authors local) Monthand =is_set( args.monthPublisherName ) then
if ( MonthAuthors == nil ) then PublisherName;
local BeganPublisherName = args.began"";
local Ended = args.ended
if Began ~= nil and Ended ~= nil then
Month = Began .. "&ndash;" .. Ended
else
Month = "&ndash;"
end
end
Date = Month .. " " .. Date
local Day = args.day
if ( Day ~= nil ) then Date = Day .. " " .. Date end
end
Cartography = A['Cartography'];
]] -- so let's use the original version for now
Dateif =is_set( YearCartography ) then
Cartography = sepc .. " " .. wrap( 'cartography', Cartography, use_lowercase );
if ( Date ~= nil and Date ~="") then
end local Month = args.month
Scale = A['Scale'];
if ( Month ~= nil and Month ~= "") then
if is_set( Scale ) Date = Month .. " " .. Date then
Scale = sepc .. local" Day" = args.day. Scale;
end if ( Day ~= nil ) then Date = Day .. " " .. Date end
end
else Month = ""
if not is_set(Date) then
Date = Year;
if is_set(Date) then
local Month = A['Month'];
if is_set(Month) then
Date = Month .. " " .. Date;
local Day = A['Day']
if is_set(Day) then Date = Day .. " " .. Date end
end
else Date = ""
end
end
if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
if( inArray(Date == nil orPublicationDate, {Date, == ""Year}) andthen PublicationDate ~= nil ) then''; end
if not is_set(Date) and is_set(PublicationDate) then
Date = PublicationDate;
PublicationDate = nil'';
end
 
-- Captures the value for Date prior to adding parens or other textual transformations
local DateIn = Date;
if ( URL == nil ornot is_set(URL == '' ) and
not is_set( ChapterURL == nil or ChapterURL == '' ) and
not is_set( ArchiveURL == nil or ArchiveURL == '' ) and
not is_set( ConferenceURL == nil or ConferenceURL == '' ) and
not is_set( TranscriptURL == nil or TranscriptURL == '' ) then
 
-- Test if cite web is called without giving a URL
if ( config.CitationClass == "web" ) then
table.insert( z.error_categoriesmessage_tail, 'Pages{ usingseterror( web'cite_web_url', citations{}, withtrue no) URL'} );
table.insert( z.message_tail, 'No URL on cite web' );
end
 
-- Test if accessdate is given without giving a URL
if is_set( AccessDate ~= nil and AccessDate ~= '' ) then
table.insert( z.error_categoriesmessage_tail, 'Pages{ usingseterror( citations'accessdate_missing_url', with{}, accessdatetrue and) no URL'} );
table.insert(AccessDate z.message_tail,= 'Accessdate used without URL' );
AccessDate = nil;end
end
-- Test if format is given without giving a URL
if is_set( Format ~= nil and Format ~= '' ) then
table.insert(Format z.error_categories,= 'PagesFormat using.. citationsseterror( with format and no URL'format_missing_url' );
end
Format = Format .. hiddencomment( "File format specified without giving a URL" );
end
end
 
-- Test if citation has no title
if ( Chapter == nil ornot is_set(Chapter == "" ) and
not is_set( Title == nil or Title == "" ) and
not is_set( Periodical == nil or Periodical == "" ) and
not is_set( Conference == nil or Conference == "" ) and
not is_set( TransTitle == nil or TransTitle == "" ) and
not is_set( TransChapter == nil or TransChapter == "" ) then
table.insert( z.error_categoriesmessage_tail, { seterror( 'Pagescitation_missing_title', with{}, citationstrue lacking) titles'} );
table.insert( z.message_tail, 'Citation has no title' );
end
 
if ( Format ~= nilis_set(Format) and " (" .. Format ~=.. ")" )or then"";
Format = " (" .. Format .. ")" else Format = "" end
local OriginalURL = URL
DeadURL = DeadURL:lower();
if is_set( ArchiveURL and "" < ArchiveURL ) then
if ( DeadURL ~= "no" ) then
URL = ArchiveURL
URLorigin = A:ORIGIN('ArchiveURL')
end
end
 
if ( TransTitle and "" < TransTitle ) then TransTitle = " [" .. TransTitle .. "&#93;" else TransTitle = "" end
if ( TransChapter and "" < TransChapter ) then TransChapter = " [" .. TransChapter .. "&#93;" else TransChapter = "" end
-- Format chapter / article title
if is_set( Chapter ~= nil) and Chapter ~= "" is_set(ChapterLink) then
if ( ChapterLink and "" < ChapterLink ) then Chapter = "[[" .. ChapterLink .. "|" .. Chapter .. "]]" end;
end
if ( Periodical and "" < Periodical ) and (Title ~= nil and Title ~= "" )
if is_set(Periodical) and is_set(Title) then
Chapter = "wrap( 'italic-title'", ..Chapter safeforitalics(Chapter) .. "''";
TransChapter = wrap( 'trans-italic-title', TransChapter );
else
Chapter = wrap( 'quoted-title', Chapter );
TransChapter = wrap( 'trans-quoted-title', TransChapter );
end
local TransError = ""
if is_set(TransChapter) then
if not is_set(Chapter) then
TransError = " " .. seterror( 'trans_missing_chapter' );
else
ChapterTransChapter = "\" " .. Chapter .. "\""TransChapter;
end
else
Chapter = "";
end
if TransChapter ~= "" and Chapter == "" then
Chapter = Chapter .. TransChapter;
table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
TransChapter = TransChapter .. hiddencomment( "Translated title included without the original" );
if is_set(Chapter) then
end
if not is_set(ChapterLink) then
Chapter = Chapter .. TransChapter
if Chapter ~= "" if is_set(ChapterURL) then
Chapter = externallink( ChapterURL, Chapter ) .. TransError;
if ( ChapterLink == nil ) then
if ( ChapterURL and ""if < ChapterURLnot is_set(URL) then
Chapter = "[" .. ChapterURL .. " " .. safeforurl( Chapter ) .. "]"
if URL == nil or URL == "" then
Chapter = Chapter .. Format;
Format = "";
end
elseif is_set( URL and "" < URL ) then
Chapter = "[" ..externallink( URL .. " " .. safeforurl(, Chapter ) .. "]"TransError .. Format;
URL = nil"";
Format = "";
endelse
Chapter = Chapter .. TransError;
end
elseif is_set(ChapterURL) then
Chapter = Chapter .. " " .. externallink( ChapterURL, nil, ChapterURLorigin ) ..
TransError;
else
Chapter = Chapter .. TransError;
end
Chapter = Chapter .. sepc .. " " -- with end-space
elseif is_set(ChapterURL) then
end
Chapter = " " .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. " ";
end
-- Format main title.
if is_set( TitleTitleLink) and "" < is_set(Title ) then
ifTitle (= "[[" .. TitleLink and.. "|" <.. TitleLinkTitle ).. then"]]"
end
Title = "[[" .. TitleLink .. "|" .. Title .. "]]" end
if ( Periodical and "" < Periodical ) then
if is_set(Periodical) then
Title = "\"" .. Title .. "\""
elseifTitle = wrap( config.CitationClass'quoted-title', ==Title "web");
TransTitle = wrap( 'trans-quoted-title', TransTitle );
or config.CitationClass == "news"
elseif or inArray(config.CitationClass, == {"web","news","pressrelease" ,"conference"}) and
not is_set(Chapter == "") then
Title = "\""wrap( ..'quoted-title', Title .. "\"");
TransTitle = wrap( 'trans-quoted-title', TransTitle );
else
Title = "''" .. safeforitalics(Title) .. "''"
end
else
Title = ""wrap( 'italic-title', Title );
TransTitle = wrap( 'trans-italic-title', TransTitle );
end
if TransTitle ~= "" and Title == "" then
table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
TransTitle = TransTitle .. hiddencomment( "Translated title included without the original" );
end
Title = Title .. TransTitle
ifTransError Title ~= "" then;
if is_set( TitleLink == nil and URL and "" < URL TransTitle) then
if not Title = "[" .. URL .. " " .. safeforurlis_set( Title ) .. "]" .. Formatthen
URLTransError = nil" " .. seterror( 'trans_missing_title' );
Format = ''else
TransTitle = " " .. TransTitle;
end
end
 
Title = Title .. TransTitle;
if ( Place ~= nil and Place ~= "" ) then
if sepc == '.' then
if is_set(Title) then
Place = " Written at " .. Place .. sepc .. " ";
if not is_set(TitleLink) and is_set(URL) then
Title = externallink( URL, Title ) .. TransError .. Format
URL = "";
Format = "";
else
PlaceTitle = " written at "Title .. Place .. sepc .. " "TransError;
end
else
Place = "";
end
if is_set( Conference ~= nil and Conference ~="" Place) then
Place = " " .. wrap( 'written', Place, use_lowercase ) .. sepc .. " ";
if ( ConferenceURL ~= nil ) then
end
Conference = "[" .. ConferenceURL .. " " .. safeforurl( Conference ) .. "]"
if is_set(Conference) then
if is_set(ConferenceURL) then
Conference = externallink( ConferenceURL, Conference );
end
Conference = sepc .. " " .. Conference
elseif is_set(ConferenceURL) then
else
Conference = sepc .. " " .. externallink( ConferenceURL, nil, ConferenceURLorigin );
end
if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
if not is_set( nil == Position and "" ~= Position ) then
local Minutes = args.minutesA['Minutes'];
if is_set( nil ~= Minutes ) then
Position = " " .. Minutes .. " minutes in" .. cfg.messages['minutes'];
else
local Time = args.timeA['Time'];
if is_set( nil ~= Time ) then
local TimeCaption = args.timecaption or "Event occurs at"A['TimeCaption']
Positionif = " " ..not is_set(TimeCaption) .. " " .. Timethen
else TimeCaption = cfg.messages['event'];
Position if sepc ~= ""'.' then
TimeCaption = TimeCaption:lower();
end
end
Position = " " .. TimeCaption .. " " .. Time;
end
end
else
Position = " " .. Position;
At = '';
end
if ( nil == Page or "" == Page ) then
if not is_set(Page) = "" then
if is_set( nil == Pages or "" == Pages) then
Pagesif =is_set(Periodical) ""and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news"}) then
elseif ( Periodical ~= nil and Periodical ~= "" and
Pages config.CitationClass ~= "encyclopaedia: " and.. Pages;
elseif config.CitationClasstonumber(Pages) ~= "web"nil andthen
Pages config.CitationClass ~= sepc .."book " and.. PPrefix .. Pages;
config.CitationClass ~= "news") thenelse
Pages = sepc ..": " .. PPPrefix .. Pages;
else
if ( tonumber(Pages) ~= nil ) then
Pages = sepc .." " .. PPrefix .. Pages
else Pages = sepc .." " .. PPPrefix .. Pages
end
end
else
Pagesif =is_set(Periodical) ""and
not inArray(config.CitationClass, {"encyclopaedia","web","book","news"}) then
if ( Periodical ~= nil and Periodical ~= "" and
Page config.CitationClass ~= "encyclopaedia: " and.. Page;
config.CitationClass ~= "web" and
config.CitationClass ~= "book" and
config.CitationClass ~= "news") then
Page = ": " .. Page
else
Page = sepc .." " .. PPrefix .. Page;
end
end
if ( At ~= nil and At ~="") then At = sepc .. " " .. At
else At = is_set(At) and (sepc .. " " end.. At) or "";
Position = is_set(Position) and (sepc .. " " .. Position) or "";
if ( Coauthors == nil ) then Coauthors = "" end
if (config.CitationClass Others ~= nil and Others ~="" )'map' then
local Section = A['Section'];
Others = sepc .. " " .. Others else Others = "" end
local Inset = A['Inset'];
if ( TitleType ~= nil and TitleType ~="" ) then
TitleType = "if first_set(" ..Pages, TitleTypePage, ..At ")" else~= TitleTypenil or sepc ~= ""'.' endthen
if ( TitleNote ~= nil and TitleNote ~="" if is_set( Section ) then
TitleNote = sepc .. Section = ", " .. TitleNotewrap( else'section', TitleNoteSection, = ""true end);
if ( Language ~= nil and Language ~="" ) thenend
Language = " (in "if ..is_set( LanguageInset .. ")" else Language = "" endthen
Inset = ", " .. wrap( 'inset', Inset, true );
if ( Edition ~= nil and Edition ~="" ) then
Edition = " (" .. Edition .. " ed.)" else Edition = "" end
else
if ( Volume ~= nil and Volume ~="" )
if is_set( Section ) then
Section = sepc .. " " .. wrap( 'section', Section, use_lowercase );
if is_set( Inset ) then
Inset = ", " .. wrap( 'inset', Inset, true );
end
elseif is_set( Inset ) then
Inset = sepc .. " " .. wrap( 'inset', Inset, use_lowercase );
end
end
At = At .. Section .. Inset;
end
Others = is_set(Others) and (sepc .. " " .. Others) or "";
TitleType = is_set(TitleType) and (" (" .. TitleType .. ")") or "";
TitleNote = is_set(TitleNote) and (sepc .. " " .. TitleNote) or "";
Language = is_set(Language) and (" " .. wrap( 'language', Language )) or "";
Edition = is_set(Edition) and (" " .. wrap( 'edition', Edition )) or "";
Issue = is_set(Issue) and (" (" .. Issue .. ")") or "";
Series = is_set(Series) and (sepc .. " " .. Series) or "";
OrigYear = is_set(OrigYear) and (" [" .. OrigYear .. "]") or "";
Agency = is_set(Agency) and (sepc .. " " .. Agency) or "";
if is_set(Volume) then
if ( mw.ustring.len(Volume) > 4 )
then Volume = sepc .." " .. Volume;
else Volume = " <b>" .. hyphentodash(Volume) .. "</b>";
end
else Volume = "" end
if ( Issue ~= nil and Issue ~="" ) then
Issue = " (" .. Issue .. ")" else Issue = "" end
if ( Series ~= nil and Series ~="" ) then
Series = sepc .. " " .. Series else Series = "" end
if ( OrigYear ~= nil and OrigYear ~="" ) then
OrigYear = " [" .. OrigYear .. "]" else OrigYear = "" end
if ( Agency ~= nil and Agency ~="" ) then
Agency = sepc .. " " .. Agency else Agency = "" end
------------------------------------ totally unrelated data
-- Mimic {{subscription required}} template;
if ( Date ~= nil ) then Date = Date else Date = "" end
if is_set( Via ~= nil and Via ~="" ) then
Via = " &mdash; via " .. Viawrap( else'via', Via = "" end);
-- SubscriptionRequired = sepc .. " " .. cfg.messages['subscription']; --citation always requires subscription if 'via' parameter is used
if ( AccessDate ~= nil and AccessDate ~="" )
-- This line removed because of editors desire to use via for citations that do not require subscriptions
then local retrv_text = " retrieved "
elseif is_set(SubscriptionRequired) then
if (sepc == ".") then retrv_text = " Retrieved " end
SubscriptionRequired = sepc .. " " .. cfg.messages['subscription_no_via']; --here when 'via' parameter not used but 'subscription' is
AccessDate = '<span class="reference-accessdate">' .. sepc
elseif is_set(RegistrationRequired) then
.. retrv_text .. AccessDate .. '</span>'
SubscriptionRequired = sepc .. " " .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
else AccessDate = "" end
if ( SubscriptionRequired ~= nil and
SubscriptionRequired ~= "" ) then
SubscriptionRequired = sepc .. " " .. createTag({name="span", contents="(subscription required)",
params={style="font-size:0.95em; font-size: 90%; color: #555"}})
else
SubscriptionRequired = ""
end
if ( ARXIV ~= nil and ARXIV ~= "" ) then
ARXIV = sepc .. " " .. externallinkid({label="arXiv",link="arXiv",
prefix="http://arxiv.org/abs/",id=ARXIV,separator=":",encode=false}) else ARXIV = "" end
if ( ASIN ~= nil and ASIN ~= "" ) then
ASIN = sepc .. " " .. amazon(ASIN, ASINTLD) else ASIN = "" end
if ( BIBCODE ~= nil and BIBCODE ~= "" ) then
BIBCODE = sepc .. " " .. externallinkid({label="Bibcode",link="Bibcode",
prefix="http://adsabs.harvard.edu/abs/",id=BIBCODE,separator=":"}) else BIBCODE = "" end
if ( DOI ~= nil and DOI ~= "" ) then
DOI = sepc .. " " .. doi(DOI, DoiBroken) else DOI = "" end
if ( ID ~= nil and ID ~="") then ID = sepc .." ".. ID else ID="" end
if ( ISBN ~= nil and ISBN ~= "") then
ISBN = sepc .. " " .. internallinkid({label="ISBN",link="International Standard Book Number",
prefix="Special:BookSources/",id=ISBN}) else ISBN = "" end
if ( ISSN ~= nil and ISSN ~="" ) then
ISSN = sepc .. " " .. externallinkid({label="ISSN",link="International Standard Serial Number",
prefix="//www.worldcat.org/issn/",id=ISSN,encode=false}) else ISSN = "" end
if ( JFM ~= nil and JFM ~="" ) then
JFM = sepc .." " .. externallinkid({label="JFM",link="Jahrbuch über die Fortschritte der Mathematik",
prefix="http://www.zentralblatt-math.org/zmath/en/search/?format=complete&q=an:",id=JFM}) else JFM = "" end
if ( JSTOR ~= nil and JSTOR ~="") then
JSTOR = sepc .." " .. externallinkid({label="JSTOR",link="JSTOR",
prefix="http://www.jstor.org/stable/",id=JSTOR}) else JSTOR = "" end
if ( LCCN ~= nil and LCCN ~="" ) then
LCCN = sepc .." " .. externallinkid({label="LCCN",link="Library of Congress Control Number",
prefix="http://lccn.loc.gov/",id=LCCN,encode=false}) else LCCN = "" end
if ( MR ~= nil and MR ~="" ) then
MR = sepc .." " .. externallinkid({label="MR",link="Mathematical Reviews",
prefix="http://www.ams.org/mathscinet-getitem?mr=",id=MR}) else MR = "" end
if ( OCLC ~= nil and OCLC ~="") then
OCLC = sepc .." " .. externallinkid({label="OCLC",link="OCLC",
prefix="//www.worldcat.org/oclc/",id=OCLC}) else OCLC = "" end
if ( OL ~= nil and OL ~="") then
OL = sepc .. " " .. openlibrary(OL) else OL = "" end
if ( OSTI ~= nil and OSTI ~="") then
OSTI = sepc .." " .. externallinkid({label="OSTI",link="Office of Scientific and Technical Information",
prefix="http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=",id=OSTI}) else OSTI = "" end
if ( PMC ~= nil and PMC ~="") then
PMC = sepc .." " .. externallinkid({label="PMC",link="PubMed Central"
,prefix="//www.ncbi.nlm.nih.gov/pmc/articles/PMC",suffix=" ",id=PMC}) else PMC = "" end
if ( PMID ~= nil and PMID ~="") then
PMID = sepc .." " .. externallinkid({label="PMID",link="PubMed Identifier",
prefix="//www.ncbi.nlm.nih.gov/pubmed/",id=PMID,encode=false}) else PMID = "" end
if ( RFC ~= nil and RFC ~="") then
RFC = sepc .." " .. externallinkid({label="RFC",link="Request for Comments",
prefix="//tools.ietf.org/html/rfc",id=RFC,encode=false}) else RFC = "" end
if ( SSRN ~= nil and SSRN ~="") then
SSRN = sepc .." " .. externallinkid({label="SSRN",link="Social Science Research Network",
prefix="http://ssrn.com/abstract=",id=SSRN}) else SSRN = "" end
if ( ZBL ~= nil and ZBL ~="") then
ZBL = sepc .." " .. externallinkid({label="Zbl",link="Zentralblatt MATH",
prefix="http://www.zentralblatt-math.org/zmath/en/search/?format=complete&q=an:",id=ZBL}) else ZBL = "" end
 
if is_set( URL ~= nil and URL ~=""AccessDate) then
URLlocal retrv_text = " " .. "cfg.messages[" .. URL .. " " .. nowiki(URL) .. "'retrieved']";
if (sepc ~= ".") then retrv_text = retrv_text:lower() end
table.insert( z.error_categories, "Pages with citations having bare URLs" );
AccessDate = '<span class="reference-accessdate">' .. sepc
if config.CitationClass == "web" then
.. substitute( retrv_text, {AccessDate} ) .. '</span>'
table.insert( z.error_categories, "Pages using web citations with no title" );
end
URL = URL .. " <span class='error'>No <code>title=</code> specified</span>"
else
if is_set(ID) then URLID = URLsepc .." hiddencomment("Bare.. URLID; needs a title");end
end
ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );
else
 
URL = ""
if is_set(URL) then
URL = " " .. externallink( URL, nil, URLorigin );
end
 
if is_set( Quote and Quote ~="" ) then
if Quote:sub(1,1) == '"' and Quote:sub(-1,-1) == '"' then
Quote = Quote:sub(2,-2);
end
Quote = sepc .." " .. wrap( 'quoted-text', Quote );
QuotePostScript = sepc .." \"" .. Quote .. "\"" ;
elseif PostScript:lower() == "none" then
PostScript = "";
else
if ( PostScript == nil) then PostScript = "" end
Quote = ""
end
local Archived
if is_set( nil ~= ArchiveURL and "" ~= ArchiveURL ) then
if not is_set( ArchiveDate ~= nil and ArchiveDate ~="" ) then
ArchiveDate = " " .. ArchiveDateseterror('archive_missing_date');
else
ArchiveDate = " <span class='error'>If you specify <code>archiveurl=</code>, " ..
"you must also specify <code>archivedate=</code></span> "
table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
end
localif arch_text"no" == "DeadURL archived"then
if (sepc == ".") thenlocal arch_text = " Archived" endcfg.messages['archived'];
if (sepc ~= "no." ==then DeadURLarch_text = arch_text:lower() thenend
Archived = sepc .. " [" .. ArchiveURLsubstitute( cfg.. arch_text .. "messages['archived-not-dead'] from the original on" .. ArchiveDate,
if OriginalURL == nil or{ OriginalUrlexternallink( ==ArchiveURL, ''arch_text then), ArchiveDate } );
if not is_set(OriginalURL) then
table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
Archived = Archived .. " <span" .. class=seterror('errorarchive_missing_url'>If); you specify <code>archiveurl=</code>" ..
" and <code>deadurl=no</code>, then you must also specify <code>url=</code></span>";
end
elseif is_set(OriginalURL) then
local arch_text = cfg.messages['archived-dead'];
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. " " .. substitute( arch_text,
{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
else
local arch_text = cfg.messages['archived-missing'];
if OriginalURL ~= nil and OriginalURL ~= '' then
if sepc ~= "." then arch_text = arch_text:lower() end
Archived = sepc .. arch_text .. " from [" .. OriginalURL .. " the original] on" .. ArchiveDate
Archived = sepc .. " " .. substitute( arch_text,
else
if config.CitationClass ~={ seterror('webarchive_missing_url'), ArchiveDate then} );
Archived = sepc .. arch_text .. " from <span class='error'>If you specify <code>archiveurl=</code>" ..
", you must also specify <code>url=</code></span> on" .. ArchiveDate
table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
else
Archived = sepc .. arch_text .. " from the original on" .. ArchiveDate
end
end
end
else
Archived = ""
end
local Lay
if is_set( nil ~= LaySummary and "" ~= LaySummary LayURL) then
if is_set( LayDate ~= nil ) then LayDate = " (" .. LayDate .. ")" else LayDate = "" end
if is_set( LaySource ~= nil ) then
LaySource = " &ndash; ''" .. safeforitalics(LaySource) .. "''" ;
else
LaySource = "" ;
end
if sepc == '.' then
Lay = sepc .. " [" .. LaySummaryexternallink( LayURL, cfg.. " Laymessages['lay summary']" ) .. LaySource .. LayDate
else
Lay = sepc .. " [" .. LaySummaryexternallink( LayURL, cfg.. " messages['lay summary']":lower() ) .. LaySource .. LayDate
end
else
Lay = "";
end
if ( nil ~= Transcript and "" ~= Transcript ) then
if is_set(Transcript) then
if ( TranscriptURL ~= nil ) then Transcript = "[" .. TranscriptURL .. Transcript .. "]" end
if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
else
elseif is_set(TranscriptURL) then
Transcript = ""
Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
end
local Publisher = ""
local Publisher;
if ( Periodical and Periodical ~= "" and
if is_set(Periodical) and
config.CitationClass ~= "encyclopaedia" and
not inArray(config.CitationClass, ~= {"encyclopaedia","web","pressrelease"}) andthen
if config.CitationClass ~= "pressrelease" is_set(PublisherName) then
if ( PublisherName ~= nil and PublisherName ~=""if is_set(PublicationPlace) then
if (PublicationPlace ~= nil and PublicationPlace ~= '') then
Publisher = PublicationPlace .. ": " .. PublisherName;
else
Publisher = PublisherName;
end
elseif is_set(PublicationPlace ~= nil and PublicationPlace ~= '') then
Publisher= PublicationPlace;
else
Publisher = "";
end
if is_set( PublicationDate and PublicationDate ~="" ) then
if is_set(Publisher ~= '') then
Publisher = Publisher .. ", published " .. wrap( 'published', PublicationDate );
else
Publisher = PublicationDate;
end
end
if is_set(Publisher ~= "") then
Publisher = " (" .. Publisher .. ")";
end
else
if is_set( PublicationDate and PublicationDate ~="" ) then
PublicationDate = " (published " .. wrap( 'published', PublicationDate ) .. ")";
else
PublicationDate = ""
end
if is_set( PublisherName ~= nil and PublisherName ~="" ) then
if is_set(PublicationPlace ~= nil and PublicationPlace ~= '') then
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
end
elseif is_set(PublicationPlace ~= nil and PublicationPlace ~= '') then
Publisher= sepc .. " " .. PublicationPlace .. PublicationDate;
else
Vrstica 1.226 ⟶ 1.427:
end
end
-- Several of the above rely upon detecting this as nil, so do it last.
if is_set( Periodical ~= nil and Periodical ~="" ) then
if is_set( Title and Title ~= "" ) or is_set( TitleNote and TitleNote ~= "" ) then
Periodical = sepc .. " ''" .. safeforitalicswrap( 'italic-title', Periodical ) .. "''"
else
Periodical = "wrap( 'italic-title'", ..Periodical safeforitalics(Periodical) .. "''"
end
else Periodical = "" end
 
-- Piece all bits together at last. Here, all should be non-nil.
Vrstica 1.240 ⟶ 1.442:
 
local tcommon
if ( ( inArray(config.CitationClass, == {"journal") or (config.CitationClass == ,"citation"}) and is_set(Periodical) andthen
if Periodicalis_set(Others) then Others ~= Others .. sepc .. " " ) thenend
iftcommon (Others ~= "") thensafejoin( {Others, =Title, OthersTitleNote, Conference, ..Periodical, sepcFormat, ..TitleType, "Scale, "Series, end
tcommon = safejoin( {Others, TitleLanguage, TitleNoteCartography, ConferenceEdition, PeriodicalPublisher, FormatAgency, TitleTypeVolume, SeriesIssue}, sepc );
Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
else
tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language,
Volume, Issue, Others, Cartography, Edition, Publisher, Agency, Position}, sepc );
end
if #ID_list > 0 then
local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI,
PMC,ID_list PMID,= RFC,safejoin( SSRN,{ URL,sepc ZBL,.. ID," Archived", AccessDate, Via,table.concat( SubscriptionRequiredID_list, Laysepc .. " " ), QuoteID }, sepc );
else
 
ID_list = ID;
local text
local pgtext = Page .. Pages .. At
if page_error then
table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
pgtext = pgtext .. hiddencomment('Bad page specification here');
end
local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
if ( "" ~= Authors ) then
local text;
if (Coauthors ~= "")
local pgtext = Position .. then Authors = AuthorsPage .. "; "Pages .. CoauthorsAt;
if is_set(Authors) then
if is_set(Coauthors) then
Authors = Authors .. A['AuthorSeparator'] .. " " .. Coauthors
end
if is_set( "" ~= Date) )then
then Date = " ("..Date..")" .. OrigYear .. sepc .. " "
elseif string.sub(Authors,-1,-1) == sepc then
else
if ( string.sub(Authors,-1,-1) == sepc)Authors --check.. end" character"
else
then Authors = Authors .. sepc .. " "
else Authors = Authors .. sepc .. " "
end
end
if is_set( "" ~= Editors) then
local in_text = " in ";
iflocal (sepc == '.') then in_textpost_text = " In " end;
if is_set(Chapter) then
in_text = in_text .. cfg.messages['in'] .. " "
else
if EditorCount <= 1 then
post_text = ", " .. cfg.messages['editor'];
else
post_text = ", " .. cfg.messages['editors'];
end
end
if (sepc ~= '.') then in_text = in_text:lower() end
Editors = in_text .. Editors .. post_text;
if (string.sub(Editors,-1,-1) == sepc)
then Editors = in_text .. Editors .. " "
else Editors = in_text .. Editors .. sepc .. " "
end
end
text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
elseif is_set( "" ~= Editors) then
if is_set( "" ~= Date ) then
if EditorCount <= 1 then
Editors = Editors .. ", ed." .. cfg.messages['editor'];
else
Editors = Editors .. ", eds." .. cfg.messages['editors'];
end
Date = " (" .. Date ..")" .. OrigYear .. sepc .. " "
else
if EditorCount <= 1 then
Editors = Editors .. " (ed" .. cfg.messages['editor'] .. ")" .. sepc .. " "
else
Editors = Editors .. " (eds" .. cfg.messages['editors'] .. ")" .. sepc .. " "
end
end
Vrstica 1.300 ⟶ 1.511:
text = safejoin( {text, pgtext, idcommon}, sepc );
else
if is_set( "" ~= Date ) then
if ( string.sub(tcommon,-1,-1) ~= sepc )
then Date = sepc .." " .. Date .. OrigYear
else Date = " " .. Date .. OrigYear
end
end -- endif ""~=Date
if ( config.CitationClass=="journal" and is_set(Periodical ) then
text = safejoin( {Chapter, Place, tcommon}, sepc );
text = safejoin( {text, pgtext, Date, idcommon}, sepc );
else
text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
text = safejoin( {text, pgtext, idcommon}, sepc );
end
end
if is_set(PostScript ~= '' and PostScript ~= nil) and PostScript ~= sepc then
text = safejoin( {text, sepc}, sepc ); --Deals with italics, spaces, etc.
text = text:sub(1,-2); --Remove final seperator
Vrstica 1.323 ⟶ 1.534:
 
-- Now enclose the whole thing in a <span/> element
if not is_set( Year == nil ) then
if is_set( DateIn ~= nil and DateIn ~= "" ) then
Year = selectyear( DateIn );
elseif is_set( PublicationDate ~= nil and PublicationDate ~= "" ) then
Year = selectyear( PublicationDate );
else
Year = ""
end
end
local classname = "citation"
local options = {};
if ( config.CitationClass ~= "citation" )
then classname = "citation " .. (config.CitationClass or "") end
if is_set(config.CitationClass) and config.CitationClass ~= "citation" then
local args = { class=classname }
options.class = "citation " .. config.CitationClass;
if ( Ref ~= nil ) then
else
options.class = "citation";
end
if is_set(Ref) and Ref:lower() ~= "none" then
local id = Ref
if ( "harv" == Ref ) then
local names = {} --table of last names & year
if (#a ""> ~= Authors )0 then
for i,v in ipairs(a) do
names[i] = v.last end
elseif ( "" ~= Editors ) if i == 4 then break end
for i,v in ipairs(e) do names[i] = v.last end
endelseif #e > 0 then
if ( names[1] == nilfor i,v in ipairs(e) thendo
names[1i] = Yearv.last
elseif ( names[2] if i == nil )4 then break end
names[2] = Year end
elseif ( names[3] == nil ) then
names[3] = Year
elseif ( names[4] == nil ) then
names[4] = Year
else
names[5] = Year
end
names[ #names + 1 ] = Year;
id = anchorid(names)
end
argsoptions.id = id;
end
if string.len(text:gsub("<span[^>/]*>.-</span>", ""):gsub("%b<>","")) <= 2 then
z.error_categories = { 'Pages with empty citations' };
text = seterror('<span class="error">Citation is empty</span>empty_citation');
z.message_tail = {};
end
if is_set(options.id) then
text = createTag({name="span", contents=text, params=args})
text = '<span id="' .. mw.uri.anchorEncode(options.id) ..'" class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
else
text = '<span class="' .. mw.text.nowiki(options.class) .. '">' .. text .. "</span>";
end
 
local empty_span = createTag( {name="'<span", contents="&nbsp;", params={style="display: none;"}} )>&nbsp;</span>';
-- Note: Using display: none on then COinS span breaks some clients.
local OCinS = createTag({name="'<span", contentstitle=empty_span,"' .. OCinSoutput .. '" params={class="Z3988",title=OCinStitle>' }}).. empty_span .. '</span>';
text = text .. OCinS;
if #z.message_tail ~= 0 then
text = text .. hiddencomment( table.concat( z.message_tail, "; " ) );
for i,v in ipairs( z.message_tail ) do
if is_set(v[1]) then
if i == #z.message_tail then
text = text .. errorcomment( v[1], v[2] );
else
text = text .. errorcomment( v[1] .. "; ", v[2] );
end
end
end
end
if no_tracking_cats == '' thenno_tracking_cats:lower();
if inArray(no_tracking_cats, {"", "no", "false", "n"}) then
for _, v in ipairs( z.error_categories ) do
text = text .. '[[Category:' .. v ..']]';
Vrstica 1.393 ⟶ 1.617:
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
 
for k, v in pairs( pframe.args ) do
if v ~= '' then
if not validate( k ) then
error_text = "";
if type( k ) ~= 'string' then
-- Exclude empty numbered parameters
if v:match("%S+") ~= nil then
table.insert( z.message_tailerror_text, 'Unnamederror_state parameter= containingseterror( "'text_ignored', .. {v}, .. '" ignored'true );
table.insert( z.error_categories, 'Pages with citations using unsupported parameters' );
end
elseif validate( k:lower() ) then
table.insert( z.message_tailerror_text, 'Unknownerror_state parameter "' .. k .. '=" ignored seterror(suggest "'parameter_ignored_suggest', ..{k, k:lower()}, .. '=")'true );
table.insert( z.error_categories, 'Pages with citations using unsupported parameters' );
else
table.insert(if z.message_tail,#suggestions 'Unknown parameter "' .. k .. '="= ignored'0 );then
table.insert( z.error_categories, 'Pages with citationssuggestions using= unsupportedmw.loadData( parameters'Module:Citation/CS1/Suggestions' );
end end
end if suggestions[ k:lower() ] ~= nil then
error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
else
error_text, error_state = seterror( 'parameter_ignored', {k}, true );
end
end
if error_text ~= '' then
table.insert( z.message_tail, {error_text, error_state} );
end
end
args[k] = v;
elseif args[k] ~= nil or (k == 'postscript') then
args[k] = v;
end
end
 
local config = {};
for k, v in pairs( frame.args ) do
config[k] = v;
if args[k] == nil and (v ~= '' or k == 'postscript') then
args[k] = v;
end
Vrstica 1.428 ⟶ 1.661:
 
return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
-- of citation styles, crossing Vancouver style with Wikipedia's
-- local Citation Style 1 (CS1) from {Template:Citation/core}.
-- However, the conflicting positions of parameters, scattered
-- in twisted locations across this module, led to a separate
-- variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
-- displayed parameters has been a continual headache, to keep
-- coordinated with the data in parentheses "(data)". There
-- has been a need to pre-check for the existence of related
-- options, to keep from putting double-dots ".." in some cases.
-- In particular, the omission of the "title=" parameter has led
-- to several cases of a spurious dot ". ." because the original
-- design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting " ".
--18Oct2012 Fixed lead-space in Chapter/Title as end " " of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot ".." in Title by omitting at end of "tcommon=...".
--19Oct2012 For pages, put &nbsp in "p.&nbsp;" etc.
--19Oct2012 Enhanced "pages=" to detect lone page as "p." else "pp." prefix.
--19Oct2012 Fixed to show "." after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces "[... Archived] from the original".
--19Oct2012 Fixed to show ";" between authors & coauthors.
--19Oct2012 Fixed to omit extra "." after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as "ctx_ver=Z39.88-2004"
--20Oct2012 Fixed COinS to not end as "&" but use lead "&rft...=" form.
--20Oct2012 Fixed COinS to not url.encode page's "rfr_id=..." pagename.
--20Oct2012 Fixed COinS data when "web" to default to rft.genre "book".
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for "agency=xx".
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot "." if already ends with dot.
--20Feb2013 If class "journal" shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + <span class="reference-accessdate">
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put "OCLC" for "Online Computer Library Center".
--20Feb2013 Fix empty "authorlink=" as person.link ~= "".
--20Feb2013 Added space after AuthorSep & AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled "EdithorSep").
--21Feb2013 Set OCinSdata.rft_val_fmt = "info:ofi/fmt:kev:mtx:book"
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass "citation".
--21Feb2013 Fixed to show "issn=x" as the ISSN code.
--21Feb2013 Fixed to show "id=x" after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass "citation": Volume, Issue, Publisher.
--21Feb2013 Put warning "Bad DOI (expected "10."..)" in DOI result.
--21Feb2013 Automatically unbolded volume+comma when > 4 long.
--21Feb2013 Changed to allow lowercase "asin-tld".
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass "citation".
--22Feb2013 Fixed config.CitationClass "citation" as span class="citation".
--22Feb2013 Capitalized "Archived/Retrieved" only when sepc is dot ".".
--23Feb2013 Fixed author editor for "in" or "In" and put space after sepc.
--23Feb2013 Changed to omit dot in "et al." when sepc is "." separator.
--23Feb2013 Fixed "author1-first" to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as "contribution=mytitle").
--23Feb2013 Fixed double-dot ".." at end of Editors list
--26Feb2013 Moved "issue=" data to show before "page=".
--26Feb2013 Moved "type=" data to show after "format=".
--26Feb2013 For "pmc=" link, omitted suffix "/?tool=pmcentrez".
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot ".." at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as ", ed." when date exists.
--27Feb2013 Removed duplicate display of "others=" data.
--27Feb2013 Removed parentheses "( )" around "department" TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as "pp." or "p.".
--07Mar2013 Changed class encyclopaedia to omit "( )" around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was "-1,1".
--13Mar2013 Removed enddot "." after "quote=" parameter.
--13Mar2013 Changed config.CitationClass "news" to use "p." page format.
--13Mar2013 Fixed missing "location=" when "web" or "encyclopaedia".
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before "p." or "pp." page number.
--14Mar2013 Fixed config.CitationClass "book" to use p./pp. page.
--18Mar2013 Fixed "page=" to override "pages=" as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null "postscript=" to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show "others=" before title.
--20Mar2013 If CitationClass is book, show "others=" before edition.
--20Mar2013 If CitationClass is journal, adjust "others=" to have sepc.
--20Mar2013 For class "journal", use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit "." after wikilink ".]]" end dot.
--03Apr2013 Changed safejoin() to omit "." after external ".]" end dot.
--03Apr2013 Changed safejoin() to omit "." at italic wikilink ".]]" end.
--03Apr2013 Changed safejoin() to omit "." at italic external ".]" end.
--04Apr2013 Moved sepc before <span class="reference-accessdate"> for "..".
--
--End