"ମଡ୍ୟୁଲ:Citation/CS1" ପୃଷ୍ଠାର ସଂସ୍କରଣଗୁଡ଼ିକ ମଧ୍ୟରେ ତଫାତ
Content deleted Content added
try again; vauthors generational suffix fix; |
Synch from sandbox; |
||
୨୨ କ ଧାଡ଼ି:
--[[--------------------------< P A G E S C O P E V A R I A B L E S >--------------------------------------
delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here
]]
local
local added_prop_cats = {}; -- list of property categories that have been added to z.properties_cats
local added_vanc_errs; -- boolean flag so we only emit one Vancouver error / category
local Frame; -- holds the module's frame table
--[[--------------------------< F I R S T _ S E T >------------------------------------------------------------
Line ୫୨ ⟶ ୫୮:
Adds a category to z.properties_cats using names from the configuration file with additional text if any.
added_prop_cats is a table declared in page scope variables above
]]
local function add_prop_cat (key, arguments)
if not added_prop_cats [key] then
Line ୬୭ ⟶ ୭୪:
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.
added_vanc_errs is a boolean declared in page scope variables above
]]
local function add_vanc_error (source)
if not added_vanc_errs then
Line ୪୦୭ ⟶ ୪୧୫:
offending parameter name to the error message. Only one error message is emitted regardless of the number of deprecated
parameters in the citation.
added_deprecated_cat is a boolean declared in page scope variables above
]]
local function deprecated_parameter(name)
if not
table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } ); -- add error message
end
Line ୪୨୫ ⟶ ୪୩୪:
" '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.
Replaces unicode quotemarks with typewriter quote marks regardless of the need for kerning.
Call this function for chapter titles, for website titles, etc; not for book titles.
Line ୪୩୩ ⟶ ୪୪୪:
local cap='';
local cap2='';
-- TODO: move this elswhere so that all title-holding elements get these quote marks replaced?
str= mw.ustring.gsub (str, '[“”]', '\"'); -- replace “” (U+201C & U+201D) with " (typewriter double quote mark)
str= mw.ustring.gsub (str, '[‘’]', '\''); -- replace ‘’ (U+2018 & U+2019) with ' (typewriter single quote mark)
cap, cap2 = str:match ("^([\"\'])([^\'].+)"); -- match leading double or single quote but not double single quotes
Line ୮୮୭ ⟶ ୯୦୧:
to use an external editor to maintain this code.
\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A & B)
\199\132-\201\143 – DŽ-ɏ
]]
Line ୯୬୬ ⟶ ୯୮୦:
end
return table.concat(initials) -- Vancouver format does not include spaces.
end
Line ୧,୪୭୭ ⟶ ୧,୪୮୬:
end
--[[--------------------------< G E T _ V _ N A M E _ T A B L E >----------------------------------------------
split apart a |vautthors= or |veditors= parameter. This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.
|vauthors=Jones AB, White EB, ((Black, Brown, and Co.))
This code is experimental and may not be retained.
]]
local function get_v_name_table (vparam, output_table)
local name_table = mw.text.split(vparam, "%s*,%s*"); -- names are separated by commas
local i = 1;
while name_table[i] do
if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then -- first segment of corporate with one or more commas; this segment has the opening doubled parens
local name = name_table[i];
i=i+1; -- bump indexer to next segment
while name_table[i] do
name = name .. ', ' .. name_table[i]; -- concatenate with previous segments
if name_table[i]:match ('^.*%)%)$') then -- if this table member has the closing doubled parens
break; -- and done reassembling so
end
i=i+1; -- bump indexer
end
table.insert (output_table, name); -- and add corporate name to the output table
else
table.insert (output_table, name_table[i]); -- add this name
end
i = i+1;
end
return output_table;
end
--[[--------------------------< P A R S E _ V A U T H O R S _ V E D I T O R S >--------------------------------
Line ୧,୫୦୪ ⟶ ୧,୫୪୮:
add_vanc_error ('wikilink');
end
v_name_table =
for i, v_name in ipairs(v_name_table) do
Line ୧,୫୪୪ ⟶ ୧,୫୮୮:
end
else
if not corporate then
is_good_vanc_name (last, '');
end
end
-- this from extract_names ()
link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
Line ୧,୫୫୫ ⟶ ୧,୫୯୯:
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 >------------------------
Line ୧,୫୭୬ ⟶ ୧,୬୨୧:
local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
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 .. '-
select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
lastfirst=true;
end
Line ୧,୬୬୧ ⟶ ୧,୭୦୮:
end
end
local vol = '';
Line ୧,୬୬୮ ⟶ ୧,୭୧୫:
vol = substitute (cfg.messages['j-vol'], {sepc, volume});
else
vol =
end
end
Line ୧,୬୭୬ ⟶ ୧,୭୨୩:
return vol;
end
Line ୧,୬୯୯ ⟶ ୧,୭୪୨:
end
]]
--[[-------------------------< F O R M A T _ P A G E S _ S H E E T S >-----------------------------------------
Line ୧,୭୯୫ ⟶ ୧,୮୩୯:
if url:match('//web%.archive%.org/save/') then -- if a save command url, we don't want to allow saving of the target page
err_msg = 'save command';
url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1); -- for preview mode: modify ArchiveURL
else
path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/'); -- split out some of the url parts for evaluation
if not is_set(timestamp) or 14 ~= timestamp:len() then -- path and flag optional, must have 14-digit timestamp here
err_msg = 'timestamp';
if '*' ~= flag then
url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1) -- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
end
elseif is_set(path) and 'web/' ~= path then -- older archive urls do not have the extra 'web/' path element
err_msg = 'path';
elseif is_set (flag) and not is_set (path) then -- flag not allowed with the old form url (without the 'web/' path element)
err_msg = 'flag';
elseif is_set (flag) and not flag:match ('%a%a_') then -- flag if present must be two alpha characters and underscore (requires 'web/' path element)
err_msg = 'flag';
else
return
end
end
-- if here, something not right so
table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } ); -- add error message and
if is_set (Frame:preprocess('{{REVISIONID}}')) then
else
return url, date; -- preview mode so return archiveURL and ArchiveDate
end
end
Line ୧,୮୯୦ ⟶ ୧,୯୨୫:
elseif 3 == selected then
Authors = A['Authors']; -- use content of |authors=
if 'authors' == A:ORIGIN('Authors') then -- but add a maint cat if the parameter is |authors=
add_maint_cat ('authors'); -- because use of this parameter is discouraged; what to do about the aliases is a TODO:
end
end
if is_set (Collaboration) then
Line ୧,୯୧୨ ⟶ ୧,୯୫୦:
elseif 3 == selected then
Editors = A['Editors']; -- use content of |editors=
add_maint_cat ('editors'); -- but add a maint cat because use of this parameter is discouraged
end
end
Line ୨,୧୭୮ ⟶ ୨,୨୧୭:
-- Special case for cite techreport.
if (config.CitationClass == "techreport") then -- special case for cite techreport
if is_set(A['Number']) then
if not is_set(ID) then -- can we use ID for the "number"?
ID = A['Number'];
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 )});
Line ୨,୧୮୭ ⟶ ୨,୨୨୬:
end
-- special case for cite interview -- TODO: make cite interveiw not need special cases
if (config.CitationClass == "interview") then
if is_set(Program) then
Line ୨,୨୦୯ ⟶ ୨,୨୪୮:
if is_set(Others) then
if is_set(TitleType) then
Others =
TitleType = '';
else
Others =
end
else
Others = cfg.title_types ['
end
end
Line ୨,୩୪୨ ⟶ ୨,୩୮୧:
end
if first_set ({AccessDate, At, Authors, 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'], -- TODO: find a better way to do this
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 = '';
Authors = '';
PublisherName = ''; -- (if the article has been published, use cite journal, or other)
Chapter = '';
Line ୨,୩୬୨ ⟶ ୨,୪୦୨:
TitleType = set_titletype (config.CitationClass, TitleType);
if is_set(Degree) and "Thesis" == TitleType then -- special case for cite thesis
TitleType = Degree ..
end
end
Line ୨,୩୭୦ ⟶ ୨,୪୧୦:
end
-- legacy:
if not is_set (Date) then
Date = Year; -- promote Year to Date
Line ୨,୪୩୦ ⟶ ୨,୪୭୦:
table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } ); -- add this error message
end
end -- end of do
Line ୨,୪୫୩ ⟶ ୨,୪୮୦:
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=
if is_set(AccessDate) then -- access date requires |url=; pmc created url is not |url=
table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
AccessDate = ''; -- unset
end
end
end
Line ୨,୫୪୧ ⟶ ୨,୫୭୩:
do
local last_first_list;
local control = {
format = NameListFormat, -- empty string or 'vanc'
Line ୨,୬୩୧ ⟶ ୨,୬୬୨:
end
local OriginalURL, OriginalURLorigin, OriginalFormat;
DeadURL = DeadURL:lower(); -- used later when assembling archived text
if is_set( ArchiveURL ) then
if is_set (ChapterURL) then
OriginalURL = ChapterURL; -- save copy of source chapter's url for archive text
OriginalURLorigin = ChapterURLorigin; -- name of chapter-url parameter for error messages
Line ୨,୭୦୮ ⟶ ୨,୭୩୯:
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 );
Line ୨,୮୨୨ ⟶ ୨,୮୫୨:
if is_set (Translators) then
Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others;
end
Line ୨,୯୦୮ ⟶ ୨,୯୩୭:
local arch_text = cfg.messages['archived-dead'];
if sepc ~= "." then arch_text = arch_text:lower() end
if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
Archived = sepc .. " " .. 'Archived from the original on ' .. ArchiveDate; -- format already styled
if 'bot: unknown' == DeadURL then
add_maint_cat ('bot:_unknown'); -- and add a category if not already added
else
add_maint_cat ('unfit'); -- and add a category if not already added
end
else -- DeadURL is empty, 'yes', 'true', or 'y'
Archived = sepc .. " " .. substitute( arch_text,
Line ୨,୯୫୩ ⟶ ୨,୯୮୭:
local Publisher;
if is_set(
PublicationDate = wrap_msg ('published', PublicationDate);
end
Publisher = sepc .. " " .. PublicationPlace .. ": " .. PublisherName .. PublicationDate;
else
Publisher = sepc .. " " .. PublisherName .. PublicationDate;
end
Publisher= sepc .. " " .. PublicationPlace .. PublicationDate;
else
Publisher = PublicationDate;
end
Line ୩,୨୩୨ ⟶ ୩,୨୪୧:
function cs1.citation(frame)
Frame = frame; -- save a copy incase we need to display an error message in preview mode
local pframe = frame:getParent()
local validation, utilities, identifiers, metadata;
Line ୩,୨୮୩ ⟶ ୩,୨୯୩:
COinS = metadata.COinS;
local args = {};
local suggestions = {};
|