diff --git a/module_citeq.lua b/module_citeq.lua index 985a482..219353c 100644 --- a/module_citeq.lua +++ b/module_citeq.lua @@ -80,7 +80,7 @@ local function accept_value( param_val, wd_val ) return val end --- Split string of comma-separated first names into table of initials +-- Split string of comma-separated first names into a table of initials local function getInitials(str) local initials = {} for _, word in pairs(mw.text.split(str, ' ', true)) do @@ -92,13 +92,14 @@ local function getInitials(str) return initials end --- Return initials given a style (e.g. Vancouver or APA) +-- Return initials given a first name string and a name-list-style value +-- (e.g. 'vanc' for Vancouver, or APA) local function getStyledNames(names, style) - if style == 'Vancouver' then - return table.concat(getInitials(names)) - elseif style == 'APA' then + -- Vancouver style (vanc) is handled by CS1: Doe JQ + if style == 'apa' then -- APA: Doe, J. Q. return table.concat(getInitials(names), '. ') .. '.' else + -- Otherwise, just remove any trailing commas from names return mw.text.trim(names:gsub(', ', ' ')) end end @@ -305,7 +306,7 @@ local function get_name_list (nl_type, args, qid, wdl) if props and props[1] then for k, v in pairs(props) do if 'deprecated' ~= v.rank then -- ignore deprecated names - maxpos = makelink(v, out, link, maxpos, wdl, args.namestyle) + maxpos = makelink(v, out, link, maxpos, wdl, args['name-list-style']) end end end @@ -313,7 +314,7 @@ local function get_name_list (nl_type, args, qid, wdl) -- second properties for k, v in pairs(fallback) do if 'deprecated' ~= v.rank then -- ignore deprecated names - maxpos = makelink(v, out, link, maxpos, wdl, args.namestyle) + maxpos = makelink(v, out, link, maxpos, wdl, args['name-list-style']) end end end @@ -538,7 +539,6 @@ local function _cite_q (citeq_args) citeq_args.qid = nil citeq_args.wdl = nil citeq_args.template = nil - citeq_args.namestyle = citeq_args.namestyle or citeq_args['name-style'] or nil -- if title supplied, flag to not read html title local titleforced = (citeq_args.title ~= nil) @@ -993,8 +993,9 @@ local function _cite_q (citeq_args) -- remove any remaining non-CS1 fields citeq_args['instance-of'] = nil - citeq_args.namestyle = nil - citeq_args['name-style'] = 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"