![]() |
مسابقه سال اسلامیکال |
همزمان با آغاز ماه رمضان، مسابقه سال اسلامیکال با هدف معرفی اسلامیکال و توسعه مقالات در زمینه اسلامی آغاز شدهاست. علاقهمندان به شرکت در این مسابقه میتوانند تا پایان ماه رمضان ۱۴۴۶ قمری برای آن نامنویسی کنند. فهرستی از مقالات پیشنهادی جهت ایجاد در اینجا وجود دارد |
پودمان:Footnotes
پرش به ناوبری
پرش به جستجو
توضیحات این پودمان میتواند در پودمان:Footnotes/توضیحات قرار گیرد.
-- این پودمان بهدقت بومیسازی شدهاست. هنگام بهروزرسانی دقت کنید
local num_con = require('Module:Numeral converter').convert
local getArgs = require('Module:Arguments').getArgs
f = {
args_default = {
bracket_left = '',
bracket_right = '',
bracket_year_left = '',
bracket_year_right = '',
postscript = '',
page = '',
pages = '',
location = '',
page_sep = 'ص.',
pages_sep = 'صص.',
ref = '',
P1 = '',
P2 = '',
P3 = '',
P4 = '',
P5 = '',
andOthers = 'و دیگران',
amp = 'و',
comma = '،',
}
}
function trim( str )
if str == nil then
return nil
end
return mw.ustring.match (str, '^%s*(.-)%s*$')
end
local function is_year (param)
return mw.ustring.match (param, '^%d%d%d%d?%l?$') or mw.ustring.match (param,'^n%.d%.%l?$') or mw.ustring.match (param,'^nd%l?$') or mw.ustring.match (param,'^c%. %d%d%d%d?%l?$')
end
function core( args )
local result
if args.P5 ~= '' then
if is_year (args.P5) then
result = table.concat({args.P1, ' ', args.andOthers, ' ', args.bracket_year_left, args.P5, args.bracket_year_right})
else
args.P5 = '' -- when P5 not a year don't include in anchor
result = table.concat ({args.P1, ' ', args.andOthers}) -- and don't render it
end
elseif args.P4 ~= '' then
if is_year (args.P4) then
result = table.concat ({args.P1, args.comma, ' ', args.P2, ' ', args.amp, ' ', args.P3, ' ', args.bracket_year_left, args.P4, args.bracket_year_right}) -- three names and a year
else
result = table.concat ({args.P1, ' ', args.andOthers}) -- four names
end
elseif args.P3 ~= '' then
if is_year (args.P3) then
result = table.concat ({args.P1, ' ', args.amp, ' ', args.P2, ' ', args.bracket_year_left, args.P3, args.bracket_year_right}) -- two names and a year
else
result = table.concat ({args.P1, args.comma, ' ', args.P2, ' ', args.amp, ' ', args.P3}) -- three names
end
elseif args.P2 ~= '' then
if is_year (args.P2) then
result = table.concat ({args.P1, ' ', args.bracket_year_left, args.P2, args.bracket_year_right}) -- one name and year
else
result = table.concat ({args.P1, ' ', args.amp, ' ', args.P2}) -- two names
end
else
result = args.P1 -- one name
end
if ('.' == result:sub(-1)) and ('' == args.page) and ('' == args.pages) and ('' == args.location) then
args.postscript = '' -- prevent double periods when date is 'n.d.'
end
if args.ref ~= 'none' then
if args.ref ~= '' then
result = '[[#' .. mw.uri.anchorEncode(num_con("en", args.ref)) .. '|' .. result .. ']]'
else
result = '[[#CITEREF' .. mw.uri.anchorEncode(num_con("en", args.P1) .. num_con("en", args.P2) .. num_con("en", args.P3) .. num_con("en", args.P4) .. num_con("en", args.P5)) .. '|' .. result .. ']]'
end
end
if args.page ~= '' then
result = result .. args.comma .. ' ' .. args.page_sep .. ' ' .. args.page
elseif args.pages ~= '' then
result = result .. args.comma .. ' ' .. args.pages_sep .. ' ' .. args.pages
end
if args.location ~= '' then
result = result .. args.comma .. ' ' .. args.location
end
result = args.bracket_left .. result .. args.bracket_right .. args.postscript
return result
end
function corefa( args )
local result
if args.P5 ~= '' then
if is_year (args.P5) then
result = table.concat({args.P1, ' ', args.andOthers, ' ', args.bracket_year_left, num_con("fa", args.P5), args.bracket_year_right})
else
args.P5 = '' -- when P5 not a year don't include in anchor
result = table.concat ({args.P1, ' ', args.andOthers}) -- and don't render it
end
elseif args.P4 ~= '' then
if is_year (args.P4) then
result = table.concat ({args.P1, args.comma, ' ', args.P2, ' ', args.amp, ' ', args.P3, ' ', args.bracket_year_left, num_con("fa", args.P4), args.bracket_year_right}) -- three names and a year
else
result = table.concat ({args.P1, ' ', args.andOthers}) -- four names
end
elseif args.P3 ~= '' then
if is_year (args.P3) then
result = table.concat ({args.P1, ' ', args.amp, ' ', args.P2, ' ', args.bracket_year_left, num_con("fa", args.P3), args.bracket_year_right}) -- two names and a year
else
result = table.concat ({args.P1, args.comma, ' ', args.P2, ' ', args.amp, ' ', args.P3}) -- three names
end
elseif args.P2 ~= '' then
if is_year (args.P2) then
result = table.concat ({args.P1, ' ', args.bracket_year_left, num_con("fa", args.P2), args.bracket_year_right}) -- one name and year
else
result = table.concat ({args.P1, ' ', args.amp, ' ', args.P2}) -- two names
end
else
result = args.P1 -- one name
end
if ('.' == result:sub(-1)) and ('' == args.page) and ('' == args.pages) and ('' == args.location) then
args.postscript = '' -- prevent double periods when date is 'n.d.'
end
if args.ref ~= 'none' then
if args.ref ~= '' then
result = '[[#' .. mw.uri.anchorEncode(num_con("en", args.ref)) .. '|' .. result .. ']]'
else
result = '[[#CITEREF' .. mw.uri.anchorEncode(num_con("en", args.P1) .. num_con("en", args.P2) .. num_con("en", args.P3) .. num_con("en", args.P4) .. num_con("en", args.P5)) .. '|' .. result .. ']]'
end
end
if args.page ~= '' then
result = result .. args.comma .. ' ' .. args.page_sep .. ' ' .. num_con("fa", args.page)
elseif args.pages ~= '' then
result = result .. args.comma .. ' ' .. args.pages_sep .. ' ' .. num_con("fa", args.pages)
end
if args.location ~= '' then
result = result .. args.comma .. ' ' .. args.location
end
result = args.bracket_left .. result .. args.bracket_right .. args.postscript
return result
end
function f.harvard_core( frame )
local args = {}
local pArgs = getArgs(frame)
args.bracket_left = pArgs.BracketLeft or ''
args.bracket_right = pArgs.BracketRight or ''
args.bracket_year_left = pArgs.BracketYearLeft or ''
args.bracket_year_right = pArgs.BracketYearRight or ''
args.postscript = pArgs.Postscript or ''
if 'none' == args.postscript then
args.postscript = ''
end
args.page = pArgs.p or pArgs.Page or pArgs.page or pArgs['ص'] or ''
args.pages = pArgs.pp or pArgs.Pages or pArgs.pages or pArgs['صص'] or ''
args.location = pArgs.Location or pArgs.loc or pArgs['محل'] or pArgs['مکان'] or pArgs['موقعیت'] or ''
args.page_sep = trim(pArgs.PageSep) or ''
args.pages_sep = trim( pArgs.PagesSep) or ''
args.ref = pArgs.REF or '{{{REF}}}'
args.P1 = trim( pArgs.P1 ) or ''
args.P2 = trim( pArgs.P2 ) or ''
args.P3 = trim( pArgs.P3 ) or ''
args.P4 = trim( pArgs.P4 ) or ''
args.P5 = trim( pArgs.P5 ) or ''
args.andOthers = trim( pArgs.AndOthers ) or 'و دیگران'
args.amp = trim( pArgs.amp ) or 'و'
args.comma = trim( pArgs.comma ) or '،'
return core( args )
end
--[[--------------------------< H Y P H E N _ T O _ D A S H >--------------------------------------------------
Converts a hyphen to a dash under certain conditions. The hyphen must separate
like items; unlike items are returned unmodified. These forms are modified:
letter - letter (A - B)
digit - digit (4-5)
digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
letterdigit - letterdigit (A1-A5) (an optional separator between letter and
digit is supported – a.1-a.5 or a-1-a-5)
digitletter - digitletter (5a - 5d) (an optional separator between letter and
digit is supported – 5.a-5.d or 5-a-5-d)
any other forms are returned unmodified.
str may be a comma- or semicolon-separated list
This code copied from Module:Citation/CS1. The only modification is to require Module:Citation/CS1/Utilities
so that it has access to the functions is_set() and has_accept_as_written()
]]
local function hyphen_to_dash( str )
local utilities = require ('پودمان:Citation/CS1/en/Utilities'); -- only modification so that this function has access to is_set() and has_accept_as_written()
if not utilities.is_set (str) then
return str;
end
local accept; -- Boolean
str = str:gsub ('&[nm]dash;', {['–'] = '–', ['—'] = '—'}); -- replace — and – entities with their characters; semicolon mucks up the text.split
str = str:gsub ('-', '-'); -- replace HTML numeric entity with hyphen character
str = str:gsub (' ', ' '); -- replace entity with generic keyboard space character
local out = {};
local list = mw.text.split (str, '%s*[,;]%s*'); -- split str at comma or semicolon separators if there are any
for _, item in ipairs (list) do -- for each item in the list
item, accept = utilities.has_accept_as_written (item); -- remove accept-this-as-written markup when it wraps all of item
if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then -- if a hyphenated range or has endash or emdash separators
if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or -- letterdigit hyphen letterdigit (optional separator between letter and digit)
item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or -- digitletter hyphen digitletter (optional separator between digit and letter)
item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or -- digit separator digit hyphen digit separator digit
item:match ('^%d+%s*%-%s*%d+$') or -- digit hyphen digit
item:match ('^%a+%s*%-%s*%a+$') then -- letter hyphen letter
item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2'); -- replace hyphen, remove extraneous space characters
else
item = mw.ustring.gsub (item, '%s*[–—]%s*', '–'); -- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
end
end
table.insert (out, item); -- add the (possibly modified) item to the output table
end
local temp_str = ''; -- concatenate the output table into a comma separated string
temp_str, accept = utilities.has_accept_as_written (table.concat (out, ', ')); -- remove accept-this-as-written markup when it wraps all of concatenated out
if accept then
temp_str = utilities.has_accept_as_written (str); -- when global markup removed, return original str; do it this way to suppress boolean second return value
return temp_str;
else
return temp_str; -- else, return assembled temp_str
end
end
--[[--------------------------< A R G S _ F E T C H >---------------------------------------------------------
Because all of the templates share a common set of parameters, a single common function to fetch those parameters
from frame and parent frame.
]]
local function args_fetch (frame, ps)
local args = args_default; -- create a copy of the default table
local pframe = frame:getParent(); -- point to the template's parameter table
for k, v in pairs (frame.args) do -- override defaults with values provided in the #invoke: if any
args[k] = v;
end
args.postscript = pframe.args.postscript or pframe.args.ps or ps;
if 'none' == args.postscript then
args.postscript = '';
end
args.page = pframe.args.p or pframe.args.page or '';
args.pages = pframe.args.pp or pframe.args.pages or '';
args.pages = ('' ~= args.pages) and hyphen_to_dash (args.pages) or '';
args.location = pframe.args.loc or '';
args.ref = pframe.args.ref or pframe.args.Ref or '';
args.ignore = ('yes' == pframe.args['ignore-false-positive']) or ('yes' == pframe.args['ignore-err']);
for i, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do -- loop through the five positional parameters and trim if set else empty string
args[v] = (pframe.args[i] and mw.text.trim (pframe.args[i])) or '';
end
if args.P5 and not is_year (args.P5, args) then
local i = 6; -- initialize the indexer to the sixth positional parameter
while pframe.args[i] do -- in case there are too many authors loop through the authors looking for a year
local v = mw.text.trim (pframe.args[i]); -- trim
if is_year (v, args) then -- if a year
args.P5 = v; -- overwrite whatever was in args.P5 with year
break; -- and abandon the search
end
i = i + 1; -- bump the indexer
end
end
return args;
end
function f.harvard_citation( frame )
local args = f.args_default
local pArgs = getArgs(frame)
args.bracket_left = '('
args.bracket_right = ')'
args.page = pArgs.p or pArgs.page or pArgs['ص'] or ''
args.pages = pArgs.pp or pArgs.pages or pArgs['صص'] or ''
args.location = pArgs.loc or pArgs['محل'] or pArgs['مکان'] or pArgs['موقعیت'] or ''
args.ref = pArgs.ref or pArgs.Ref or ''
args.P1 = trim( pArgs[1] ) or ''
args.P2 = trim( pArgs[2] ) or ''
args.P3 = trim( pArgs[3] ) or ''
args.P4 = trim( pArgs[4] ) or ''
args.P5 = trim( pArgs[5] ) or ''
args.andOthers = trim( pArgs.AndOthers ) or args.andOthers
args.amp = trim( pArgs.amp ) or args.amp
args.comma = trim( pArgs.comma ) or args.comma
args.page_sep = trim( pArgs.PageSep ) or args.page_sep
args.pages_sep = trim( pArgs.PagesSep ) or args.pages_sep
return core( args )
end
function f.harvard_citation_no_bracket( frame )
local args = f.args_default
local pArgs = getArgs(frame)
args.page = pArgs.p or pArgs.page or pArgs['ص'] or ''
args.pages = pArgs.pp or pArgs.pages or pArgs['صص'] or ''
args.location = pArgs.loc or pArgs['محل'] or pArgs['مکان'] or pArgs['موقعیت'] or ''
args.ref = pArgs.ref or pArgs.Ref or ''
args.P1 = trim( pArgs[1] ) or ''
args.P2 = trim( pArgs[2] ) or ''
args.P3 = trim( pArgs[3] ) or ''
args.P4 = trim( pArgs[4] ) or ''
args.P5 = trim( pArgs[5] ) or ''
args.andOthers = trim( pArgs.AndOthers ) or args.andOthers
args.amp = trim( pArgs.amp ) or args.amp
args.page_sep = trim( pArgs.PageSep ) or args.page_sep
args.pages_sep = trim( pArgs.PagesSep ) or args.pages_sep
args.comma = trim( pArgs.comma ) or args.comma
return core( args )
end
--[[--------------------------< S T R I P _ U R L >------------------------------------------------------------
used by sfn() and sfnm(). This function fixes an issue with reference tooltip gadget where the tooltip is not displayed
when an insource locator (|p=, |pp=, |loc=) has an external wikilink that contains a # character
strip uri-reserved characters from urls in |p=, |pp-, and |loc= parameters The researved characters are:
!#$&'()*+,/:;=?@[]
]]
local function strip_url (pages)
local escaped_uri;
if not pages or ('' == pages) then
return pages;
end
for uri in pages:gmatch ('%[(%a[%w%+%.%-]*://%S+)') do -- for each external link get the uri
escaped_uri = uri:gsub ("([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ); -- save a copy with lua pattern characters escaped
uri = uri:gsub ("[!#%$&'%(%)%*%+,/:;=%?@%[%]%.%%]", ''); -- remove reserved characters and '%' because '%20' (space character) is a lua 'invalid capture index'
pages = pages:gsub (escaped_uri, uri, 1); -- replace original uri with the stripped version
end
return pages;
end
function f.sfn( frame )
local args = f.args_default
local pArgs = getArgs(frame)
for k, v in pairs( frame.args ) do -- for {{sfnp}}, override default with values provided in the #invoke:
args[k] = v
end
args.postscript = pArgs.postscript or pArgs.ps or '.'
if 'none' == args.postscript then
args.postscript = ''
end
args.page = pArgs.p or pArgs.page or pArgs['ص'] or ''
args.pages = pArgs.pp or pArgs.pages or pArgs['صص'] or ''
args.location = pArgs.loc or pArgs['محل'] or pArgs['مکان'] or pArgs['موقعیت'] or ''
args.ref = pArgs.ref or pArgs.Ref or ''
args.P1 = trim( pArgs[1] ) or ''
args.P2 = trim( pArgs[2] ) or ''
args.P3 = trim( pArgs[3] ) or ''
args.P4 = trim( pArgs[4] ) or ''
args.P5 = trim( pArgs[5] ) or ''
args.andOthers = trim( pArgs.AndOthers ) or args.andOthers
args.amp = trim( pArgs.amp ) or args.amp
args.comma = trim( pArgs.comma ) or args.comma
args.page_sep = trim( pArgs.PageSep ) or args.page_sep
args.pages_sep = trim( pArgs.PagesSep ) or args.pages_sep
local result = core( args )
local name = 'FOOTNOTE' .. num_con("en", args.P1) .. num_con("en", args.P2) ..
num_con("en", args.P3) .. num_con("en", args.P4) .. num_con("en", args.P5) ..
num_con("en", args.page) .. num_con("en", args.pages) .. num_con("en", args.location)
result = frame:extensionTag{ name = 'ref', args = {name=name}, content=result }
return result
end
--[[--------------------------< S F N M >----------------------------------------------------------------------
common entry point for {{sfnm}} and {{sfnmp}}
Distinguishing features (brackets) are specified in this module's {{#invoke}} in the respective templates.
]]
function f.sfnm (frame)
local args = f.args_default -- create a copy of the default table
local pframe = frame:getParent(); -- point to the template's parameter table
local n = 1; -- index of source; this is the 'n' in na1, ny, etc
local first_pnum = 1; -- first of a pair of positional parameters
local second_pnum = 2; -- second of a pair of positional parameters
local last_ps = 0; -- index of the last source with |nps= set
local last_index = 0; -- index of the last source; these used to determine which of |ps= or |nps= will terminate the whole rendering
local out = {}; -- table to hold rendered sources
local footnote = {'FOOTNOTE'}; -- all author, date, insource location stuff becomes part of the reference's footnote id; added as we go
for k, v in pairs (frame.args) do -- override defaults with values provided in the #invoke: if any
args[k] = v;
end
while true do
if not pframe.args[table.concat ({n, 'a1'})] and not pframe.args[first_pnum] then
break; -- no na1 or matching positional parameter so done
end
if pframe.args[table.concat ({n, 'a1'})] then -- does this source use named parameters?
for _, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do -- initialize for this source
args[v] = '';
end
for i, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do -- extract author and year parameters for this source
args[v] = pframe.args[table.concat ({n, 'a', i})] or ''; -- attempt to assign author name
if '' == args[v] then -- when there wasn't an author name
args[v] = pframe.args[table.concat ({n, 'y'})] or ''; -- attempt to assign year
break; -- done with author/date for this source
end
end
else -- this source uses positional parameters
args.P1 = mw.text.trim (pframe.args[first_pnum]); -- yes, only one author supported
args.P2 = (pframe.args[second_pnum] and mw.text.trim (pframe.args[second_pnum])) or ''; -- when positional author, year must also be positional
for _, v in ipairs ({'P3', 'P4', 'P5'}) do -- blank the rest of these for this source
args[v] = '';
end
first_pnum = first_pnum + 2; -- source must use positional author and positional year
second_pnum = first_pnum + 1; -- bump these for possible next positional source
end
args.postscript = pframe.args[table.concat ({n, 'ps'})] or '';
if 'none' == args.postscript then -- this for compatibility with other footnote templates; does nothing
args.postscript = '';
end
args.ref = pframe.args[table.concat ({n, 'ref'})] or ''; -- alternate reference for this source
args.page = pframe.args[table.concat ({n, 'p'})] or ''; -- insource locations for this source
args.pages = pframe.args[table.concat ({n, 'pp'})] or '';
args.pages = ('' ~= args.pages) and hyphen_to_dash (args.pages) or '';
args.location = pframe.args[table.concat ({n, 'loc'})] or '';
args.ignore = ('yes' == pframe.args[table.concat ({n, 'ignore-false-positive'})]) or ('yes' == pframe.args[table.concat ({n, 'ignore-err'})]);
table.insert (out, core (args)); -- save the rendering of this source
for k, v in ipairs ({'P1', 'P2', 'P3', 'P4', 'P5'}) do -- create the FOOTNOTE id
if '' ~= args[v] then
table.insert (footnote, args[v]);
end
end
for k, v in ipairs ({'page', 'pages', 'location'}) do -- these done separately so that we can strip uri-reserved characters from extlinked page numbers
if '' ~= args[v] then
table.insert (footnote, strip_url (args[v]))
end
end
last_index = n; -- flags used to select terminal postscript from nps or from end_ps
if '' ~= args.postscript then
last_ps = n;
end
n = n+1; -- bump for the next one
end
local name = table.concat (footnote):gsub ('%s+', ' '); -- put the footnote together and strip redundant space
args.end_ps = pframe.args.postscript or pframe.args.ps or '.'; -- this is the postscript for the whole not for the individual sources
if 'none' == args.end_ps then -- not an original sfnm parameter value; added for compatibility with other footnote templates
args.end_ps = '';
end
local result = table.concat ({table.concat (out, '; '), (last_index == last_ps) and '' or args.end_ps});
return frame:extensionTag ({name='ref', args={name=name}, content=result});
end
--[[
The following function is idential to f.sfn with the exception that
it guarantees the output <ref> tag will have dir=ltr which is useful
for references copied from English Wikipedia
]]
function f.sfnltr( frame )
local args = f.args_default
local pArgs = getArgs(frame)
for k, v in pairs( frame.args ) do -- for {{sfnp}}, override default with values provided in the #invoke:
args[k] = v
end
args.postscript = pArgs.postscript or pArgs.ps or '.'
if 'none' == args.postscript then
args.postscript = ''
end
args.page = pArgs.p or pArgs.page or pArgs['ص'] or ''
args.pages = pArgs.pp or pArgs.pages or pArgs['صص'] or ''
args.location = pArgs.loc or pArgs['محل'] or pArgs['مکان'] or pArgs['موقعیت'] or ''
args.ref = pArgs.ref or pArgs.Ref or ''
args.P1 = trim( pArgs[1] ) or ''
args.P2 = trim( pArgs[2] ) or ''
args.P3 = trim( pArgs[3] ) or ''
args.P4 = trim( pArgs[4] ) or ''
args.P5 = trim( pArgs[5] ) or ''
args.andOthers = trim( pArgs.AndOthers ) or args.andOthers
args.amp = trim( pArgs.amp ) or args.amp
args.comma = trim( pArgs.comma ) or args.comma
args.page_sep = trim( pArgs.PageSep ) or args.page_sep
args.pages_sep = trim( pArgs.PagesSep ) or args.pages_sep
local result = core( args )
local name = 'FOOTNOTE' .. num_con("en", args.P1) .. num_con("en", args.P2) ..
num_con("en", args.P3) .. num_con("en", args.P4) .. num_con("en", args.P5) ..
num_con("en", args.page) .. num_con("en", args.pages) .. num_con("en", args.location)
result = num_con("en", result)
result = frame:extensionTag{ name = 'ref', args = {name=name,dir="ltr"}, content=result }
return result
end
function f.sfnfa( frame )
local args = f.args_default
local pArgs = getArgs(frame)
for k, v in pairs( frame.args ) do -- for {{sfnp}}, override default with values provided in the #invoke:
args[k] = v
end
args.postscript = pArgs.postscript or pArgs.ps or '.'
if 'none' == args.postscript then
args.postscript = ''
end
args.page = pArgs.p or pArgs.page or pArgs['ص'] or ''
args.pages = pArgs.pp or pArgs.pages or pArgs['صص'] or ''
args.location = pArgs.loc or pArgs['محل'] or pArgs['مکان'] or pArgs['موقعیت'] or ''
args.ref = pArgs.ref or pArgs.Ref or ''
args.P1 = trim( pArgs[1] ) or ''
args.P2 = trim( pArgs[2] ) or ''
args.P3 = trim( pArgs[3] ) or ''
args.P4 = trim( pArgs[4] ) or ''
args.P5 = trim( pArgs[5] ) or ''
args.andOthers = trim( pArgs.AndOthers ) or args.andOthers
args.amp = trim( pArgs.amp ) or args.amp
args.comma = trim( pArgs.comma ) or args.comma
args.page_sep = trim( pArgs.PageSep ) or args.page_sep
args.pages_sep = trim( pArgs.PagesSep ) or args.pages_sep
args.P1 = num_con("en", args.P1)
args.P2 = num_con("en", args.P2)
args.P3 = num_con("en", args.P3)
args.P4 = num_con("en", args.P4)
args.P5 = num_con("en", args.P5)
local result = corefa( args )
local name = 'FOOTNOTE' .. args.P1 .. args.P2 ..
args.P3 .. args.P4 .. args.P5 .. num_con("en", args.page) ..
num_con("en", args.pages) .. num_con("en", args.location)
result = frame:extensionTag{ name = 'ref', args = {name=name}, content=result }
return result
end
--[[--------------------------< S F N R E F >------------------------------------------------------------------
implements {{sfnref}}
]]
function f.sfnref (frame)
local args = getArgs(frame)
local out = {};
for i=1, 5 do -- get the first five args if there are five args
if args[i] then
out[i] = num_con("en", args[i]);
else
break; -- less than 5 args break out
end
end
if 5 == #out then -- when we have seen five args there may bemore
local i = 6; -- initialize the indexer to the sixth positional parameter
while args[i] do -- in case there are too many authors loop through the authors looking for a year
if is_year (args[i], args) then -- if a year
out[5] = num_con("en", args[i]); -- overwrite whatever was in args[5] with year
break; -- and abandon the search
end
i = i + 1; -- bump the indexer
end
end
return mw.uri.anchorEncode ('CITEREF' .. table.concat (out));
end
return f