Content deleted Content added
make function exportable; improve title linking; minor bugfix Tag: Reverted |
restoring to check line feed error |
||
Line 1:
-- Version:
local
require('Module:No globals')
Line 25:
-- we need three exceptions in English for 1st, 2nd, 3rd, 21st, .. 31st, etc.
-------------------------------------------------------------------------------
local card = tonumber(cardinal)
if not card then return cardinal end
Line 224:
end
return maxpos
end -- of local function makelink
--[=[-------------------------< G E T _ N A M E _ L I S T >----------------------------------------------------
Line 339:
end
function
local
local expand = '' -- when set to anything, causes {{cite q}} to render <code><nowiki>{{citation|...}}</nowiki></code>
for k, v in pairs(frame:getParent().args) do
if in_array (k, {'expand', '_debug'}) then
if is_set(v) then
expand = v -- record setting but don't pass |expand= to {{citation}}
end
else
if v ~= "" then citeq_args[k] = v end
end
end
for k, v in pairs(frame.args) do
if v ~= "" then citeq_args[k] = v end
end
-- parameters that don't get passed to Citation
local qid = citeq_args.qid
local wdl = citeq_args.wdl
local template = citeq_args.template
citeq_args.qid = nil
citeq_args.wdl = nil
citeq_args.template = nil
local titleforced = (citeq_args.title ~= nil)
Line 371 ⟶ 382:
citeq_args[name] = getValue( {data.id, fwd = "ALL", osd = "no", noicon = "true", qid = qid, maxvals = data.maxvals, linked = data.linked, rank = data.rank or "best", citeq_args[name] } )
if data.populate_from_journal then
citeq_args[name] =
end
if citeq_args[name] and citeq_args[name]:find('[[Category:Articles with missing Wikidata information]]', 1, true) then
Line 412 ⟶ 423:
citeq_args.url = getValue( {"P2699", ps = 1, qid = qid, maxvals = 0, citeq_args.url } ) -- try url
local slink = mw.wikibase.getSitelink(qid)
local label = mw.wikibase.getLabel(qid) or citeq_args.language and mw.wikibase.getLabelByLang(qid, citeq_args.language)
local slink_flag = false
local wrap_title = ''
if citeq_args.title then
citeq_args.url = nil
wrap_title = wrap_nowiki(citeq_args.title, titleforced)
slink_flag = true
else
end
else
if slink then
if slink:lower() == label:lower() then
citeq_args.title = '[[' .. slink .. ']]'
else
wrap_title = wrap_nowiki(slink:gsub("%s%(.+%)$", ""):gsub(",.+$", ""), titleforced)
end
else
citeq_args.title = wrap_nowiki(label, titleforced)
end
end
if slink_flag then
if slink == wrap_title then -- direct link
citeq_args.title = '[[' .. slink .. ']]'
else -- piped link
citeq_args.title = '[[' .. slink .. '|' .. wrap_title .. ']]'
end
end
Line 529 ⟶ 523:
-- change edition to ordinal if it's set and numeric
citeq_args.edition = citeq_args.edition and
-- code to make a guess what template to use from the supplied parameters
-- (first draft for proof-of-concept)
if citeq_args.isbn then
template =
elseif citeq_args.journal then
template =
elseif citeq_args.website then
template =
end
Line 564 ⟶ 558:
else
citeq_args.id = id;
end
-- if |expand=<anything>, write a nowiki'd version to see what the {{citation}} template call looks like
if is_set(expand) then
local expand_args = {
if expand == "self" then
citeq_args.id = old_id; -- restore original |id= parameter
expand_args = {
end
for p, v in pairs (citeq_args) do -- spin through citeq_args and
table.insert (expand_args, p .. '=' .. v); -- add parameter name = value
end
-- make the nowiki'd string and done
return
end
Line 595 ⟶ 584:
end
return citeq
|