ᱢᱳᱰᱩᱞ:Citation/CS1: ᱨᱮᱱᱟᱜ ᱫᱚᱦᱲᱟᱭᱮᱱ ᱛᱟᱞᱟᱨᱮᱭᱟᱜ ᱯᱷᱟᱨᱟᱠ ᱠᱚ
Content deleted Content added
Trappist the monk (ᱨᱚᱲ | ᱮᱱᱮᱢ) synch from sandbox; |
আফতাবুজ্জামান (ᱨᱚᱲ | ᱮᱱᱮᱢ) No edit summary |
||
ᱫᱷᱟᱹᱲ ᱔᱑᱕:
if path then -- if there is a path portion
path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'}); -- replace '[' and ']' with their percent encoded values
URL
end
if is_set (access) then -- access level (subscription, registration, limited)
label = safe_for_url (label); -- replace square brackets and newlines
base_url = table.concat ( -- assemble external link with access signal
{
'<span class="plainlinks">[', -- opening css and url markup
URL, -- the url
' ', -- the required space
label,
'<span style="padding-left:0.15em">', -- signal spacing css
cfg.presentation[access], -- the appropriate icon
'</span>', -- close signal spacing span
']</span>' -- close url markup and plain links span
});
else
base_url = table.concat({ "[", URL, " ", safe_for_url( label ), "]" }); -- no signal markup
end
return table.concat
end
Line ᱖᱘᱑ ⟶ ᱖᱙᱓:
if position then
if 'nowiki' == capture or 'math' == capture
stripmarker = true; -- set a flag
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
Line ᱗᱕᱐ ⟶ ᱗᱖᱑:
end,
});
end
--[[--------------------------< V A L I D A T E >--------------------------------------------------------------
Looks for a parameter's name in one of several whitelists.
Parameters in the whitelist can have three values:
true - active, supported parameters
false - deprecated, supported parameters
nil - unsupported parameters
]]
local function validate( name, cite_class )
local name = tostring( name );
local state;
if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then -- limited parameter sets allowed for these templates
state = whitelist.limited_basic_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
if 'arxiv' == cite_class then -- basic parameters unique to these templates
state = whitelist.arxiv_basic_arguments[name];
end
if 'biorxiv' == cite_class then
state = whitelist.biorxiv_basic_arguments[name];
end
if 'citeseerx' == cite_class then
state = whitelist.citeseerx_basic_arguments[name];
end
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
-- limited enumerated parameters list
name = name:gsub("%d+", "#" ); -- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
state = whitelist.limited_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 -- end limited parameter-set templates
state = whitelist.basic_arguments[ name ]; -- all other templates; all normal parameters allowed
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
-- all enumerated parameters allowed
name = name:gsub("%d+", "#" ); -- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
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
Line ᱗᱙᱙ ⟶ ᱘᱘᱑:
--[[--------------------------< 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
Line ᱒,᱐᱐᱘ ⟶ ᱒,᱐᱕᱕:
else
return url, date; -- preview mode so return archiveURL and ArchiveDate
end
end
--[[--------------------------< M I S S I N G _ P I P E _ C H E C K >------------------------------------------
Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters. If found, then the string is possibly a
parameter that is missing its pipe:
{{cite ... |title=Title access-date=2016-03-17}}
cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc. To prevent false positives xml/html
tags are removed before the search.
If a missing pipe is detected, this function adds the missing pipe maintenance category.
]]
local function missing_pipe_check (value)
local capture;
value = value:gsub ('%b<>', ''); -- remove xml/html tags because attributes: class=, title=, etc
capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*='); -- find and categorize parameters with possible missing pipes
if capture and validate (capture) then -- if the capture is a valid parameter name
add_maint_cat ('missing_pipe');
end
end
Line ᱒,᱑᱗᱔ ⟶ ᱒,᱒᱔᱖:
-- conference & map books do not support issue
if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
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
Line ᱒,᱕᱕᱙ ⟶ ᱒,᱖᱓᱑:
local error_message = '';
-- AirDate has been promoted to Date so not necessary to check it
-- local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
-- ['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};
local date_parameters_list = {
['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
Line ᱒,᱖᱐᱔ ⟶ ᱒,᱖᱗᱙:
-- uncomment these three lines. Not supported by en.wiki (for obvious reasons)
-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
if modified then -- if the date_parameters_list values were modified
Line ᱒,᱘᱗᱙ ⟶ ᱒,᱙᱕᱔:
-- Format main title.
if '...' == Title:sub (-3) then -- if elipsis is the last three characters of |title=
Title = mw.ustring.gsub (Title, '(%.%.%.)%.+$', '%1'); -- limit the number of dots to three
elseif not mw.ustring.find (Title, '%.%s*%a%.') then -- end of title is not a 'dot-(optional space-)letter-dot' initialism
Title = mw.ustring.gsub(Title, '%'..sepc..'$', ''); -- remove any trailing separator character
end
if is_set(TitleLink) and is_set(Title) then
Title = make_wikilink (TitleLink, Title);
Line ᱓,᱓᱙᱑ ⟶ ᱓,᱔᱕᱖:
return table.concat (render);
end
Line ᱓,᱔᱙᱑ ⟶ ᱓,᱔᱖᱘:
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
if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then -- did the {{#invoke:}} use sandbox version?
Line ᱓,᱕᱐᱐ ⟶ ᱓,᱔᱗᱗:
identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
metadata = require ('Module:Citation/CS1/COinS/sandbox');
else -- otherwise
Line ᱓,᱕᱐᱙ ⟶ ᱓,᱔᱘᱕:
identifiers = require ('Module:Citation/CS1/Identifiers');
metadata = require ('Module:Citation/CS1/COinS');
end
Line ᱓,᱕᱖᱑ ⟶ ᱓,᱕᱓᱕:
if v ~= '' then
if ('string' == type (k)) then
k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits); -- for enumerated parameters, translate 'local' digits to Western 0-9
end
if not validate( k, config.CitationClass ) then
Line ᱓,᱕᱗᱑ ⟶ ᱓,᱕᱔᱕:
end
elseif validate( k:lower(), config.CitationClass ) then
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
Line ᱓,᱕᱘᱓ ⟶ ᱓,᱕᱕᱗:
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
Line ᱓,᱖᱑᱗ ⟶ ᱓,᱕᱘᱗:
end
end
return
end
|