diff --git a/module_citeq.lua b/module_citeq.lua index f3a51ed..41c17d5 100644 --- a/module_citeq.lua +++ b/module_citeq.lua @@ -109,7 +109,8 @@ end local function make_citeref(names, year) local refs = {} for i, v in ipairs(names) do - refs[i] = mw.text.trim(v.last) or mw.text.trim(v.label) or '' + local name = v.last or v.label or '' + refs[i] = mw.text.trim(name) if i == 4 then break end end table.insert(refs, year) @@ -825,7 +826,7 @@ local function _cite_q (citeq_args) local missing_names = {} for i, author in pairs(names.authors or {}) do -- mw.logObject(author) - if not author.last and i <= (citeq_args['display-authors'] or author_count) then + if not author.last and i <= (tonumber (citeq_args['display-authors']) or tonumber (author_count)) then if author.qid then -- ignore anonymous if author.qid ~= 'Q4233718' then @@ -837,7 +838,7 @@ local function _cite_q (citeq_args) end end for i, editor in pairs(names.editors or {}) do - if not editor.last and i <= (citeq_args['display-editors'] or editor_count) then + if not editor.last and i <= (tonumber (citeq_args['display-editors']) or tonumber (editor_count)) then if editor.qid then -- ignore anonymous if editor.qid ~= 'Q4233718' then @@ -866,7 +867,7 @@ local function _cite_q (citeq_args) if #missing_names > 0 and not string.find(opt_cat, name_cat, 1, true) then opt_cat = opt_cat .. name_cat -- TODO: format and i18n this string - opt_cat = opt_cat .. ' {{[[Template:Cite Q|Cite Q]]}}: Missing first/last names in Wikidata for ' .. table.concat(missing_names, ', ') .. ' ([[Template:Cite Q#Error messages|help]]) ' + opt_cat = opt_cat .. ' {{[[Template:Cite Q|Cite Q]]}}: Missing first/last names in Wikidata for ' .. table.concat(missing_names, ', ') .. ' ([[Template:Cite Q#Error messages|help]]) ' end -- change edition to ordinal if it's set and numeric @@ -874,14 +875,14 @@ local function _cite_q (citeq_args) -- handle supplied {{para|ref}} for readable ID, avoid CS1 duplicate default error local pubyear = yearFromDate(citeq_args['publication-date']) - if citeq_args.ref then + if citeq_args.ref and 'none' ~= citeq_args.ref then local citeref = make_citeref(names.authors or names.editors, pubyear) if citeq_args.ref == citeref then citeq_args.ref = nil -- avoid CS1 maint: ref duplicates default else local tpara = frame:expandTemplate{ title = 'para', args = {'ref', citeq_args.ref} } -- TODO: format and i18n this string - opt_cat = opt_cat .. ' {{[[Template:Cite Q|Cite Q]]}}: supplied ' .. tpara .. ' does not match value generated from Wikidata: ' .. citeref .. ' ([[Template:Cite Q#Error messages|help]]) ' + opt_cat = opt_cat .. ' {{[[Template:Cite Q|Cite Q]]}}: supplied ' .. tpara .. ' does not match value generated from Wikidata: ' .. citeref .. ' ([[Template:Cite Q#Error messages|help]]) ' end end