remove all non-cs1 parameters in one place before rendering any output
This commit is contained in:
parent
dc7f9358db
commit
4724cd3c55
1 changed files with 23 additions and 23 deletions
|
|
@ -114,21 +114,23 @@ local function getStyledNames(names, style)
|
|||
end
|
||||
end
|
||||
|
||||
-- Concatenate up to the first four names, and the year, into a CITEREF and return it
|
||||
-- Concatenate up to the first four names (at least one name required), and the year (optional), into a CITEREF and return it; return nil else
|
||||
local function make_citeref(names, year)
|
||||
local refs = {}
|
||||
for i, v in ipairs(names) do
|
||||
local name = v.last or v.label or ''
|
||||
refs[i] = mw.text.trim(name)
|
||||
if i == 4 then break end
|
||||
local name = v.last or v.label;
|
||||
if not name then break end; -- no v.last or v.label? abandon the ipairs() loop
|
||||
refs[i] = mw.text.trim (name);
|
||||
if i == 4 then break end -- collect only four names
|
||||
end
|
||||
table.insert(refs, year)
|
||||
local id = table.concat(refs) or ''
|
||||
if id == '' then
|
||||
return ''
|
||||
else
|
||||
return "CITEREF" .. id
|
||||
|
||||
if 0 < #refs then -- don't add <year> when there are no names in <refs>; CITEREFYYYY is more-or-less meaningless
|
||||
table.insert (refs, year); -- add <year>
|
||||
table.insert (refs, 1, 'CITEREF'); -- and insert the 'CITEREF' prefix
|
||||
return table.concat (refs); -- concatenate and done
|
||||
end
|
||||
|
||||
return; -- no names so return nil
|
||||
end
|
||||
|
||||
-- function to fetch a value to display
|
||||
|
|
@ -913,13 +915,13 @@ local function _cite_q (citeq_args)
|
|||
local refnames
|
||||
if #names.authors > 0 then
|
||||
refnames = names.authors
|
||||
else
|
||||
elseif #names.editors > 0 then
|
||||
refnames = names.editors
|
||||
end
|
||||
local citeref = make_citeref(refnames, pubyear)
|
||||
if citeq_args.ref == citeref then
|
||||
citeq_args.ref = nil -- avoid CS1 maint: ref duplicates default
|
||||
else
|
||||
local citeref = refnames and make_citeref (refnames, pubyear) or nil; -- <refnames> nil when no authors and no editors
|
||||
if citeq_args.ref == citeref then -- CITEREF from wikidata authors / editors matches the value provided in |ref=
|
||||
citeq_args.ref = nil -- unset to avoid CS1 maint: ref duplicates default maintenance message / category
|
||||
elseif citeref then -- CITEREF from wikidata authors / editors is different from the value provided in |ref=
|
||||
tableset_add(opt_cat, cfg.i18n_t.trackingcats['supplied-ref'])
|
||||
local tpara = frame:expandTemplate{ title = 'para', args = {'ref', citeq_args.ref} }
|
||||
-- TODO: format and i18n this string
|
||||
|
|
@ -1009,9 +1011,13 @@ local function _cite_q (citeq_args)
|
|||
end
|
||||
retract = ' ' .. frame:expandTemplate{ title = "Retracted", args = retr_params }
|
||||
end
|
||||
-- remove non-CS1 retraction properties
|
||||
citeq_args.retracted_by = nil
|
||||
|
||||
citeq_args.retracted_by = nil -- remove non-CS1 parameters
|
||||
citeq_args['retracted-intentional'] = nil
|
||||
citeq_args['instance-of'] = nil
|
||||
if citeq_args['name-list-style'] and citeq_args['name-list-style'] == 'apa' then
|
||||
citeq_args['name-list-style'] = nil
|
||||
end
|
||||
|
||||
-- clean up any blank parameters
|
||||
for k, v in pairs(citeq_args) do
|
||||
|
|
@ -1103,12 +1109,6 @@ local function _cite_q (citeq_args)
|
|||
-- Disable CiteSeerX IDs for now
|
||||
citeq_args.citeseerx = nil
|
||||
|
||||
-- remove any remaining non-CS1 fields
|
||||
citeq_args['instance-of'] = nil
|
||||
if citeq_args['name-list-style'] and citeq_args['name-list-style'] == 'apa' then
|
||||
citeq_args['name-list-style'] = nil
|
||||
end
|
||||
|
||||
-- render the template
|
||||
local lc_template = template and template:lower() or "citation"
|
||||
local output
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue