Module:User:Surjection/UPA

local export = {}

local function get_stylesheet return require("Module:TemplateStyles")("Module:User:Surjection/UPA/style.css") end

function export.format_UPA(lang, item, nostyles) local pron, phonetic if type(item) == "table" then pron, phonetic = item.pron, item.phonetic else pron, phonetic = item.pron, true end return '' .. pron .. ' ' .. (nostyles and '' or get_stylesheet) end

function export.format_UPA_multiple(lang, items, separator, nostyles) local categories = {} separator = separator or ', '

local bits = {} for _, item in ipairs(items) do		local bit = export.format_UPA(lang, item, nostyles) if item.pretext then bit = item.pretext .. bit end if item.posttext then bit = bit .. item.posttext end if item.qualifiers and item.qualifiers[1] then bit = require("Module:qualifier").format_qualifier(item.qualifiers) .. " " .. bit end

if item.refs or item.note then local refspecs = item.refs local refs = {} if #refspecs > 0 then for _, refspec in ipairs(refspecs) do					if type(refspec) ~= "table" then refspec = {text = refspec} end local refargs if refspec.name or refspec.group then refargs = {name = refspec.name, group = refspec.group} end table.insert(refs, mw.getCurrentFrame:extensionTag("ref", refspec.text, refargs)) end bit = bit .. table.concat(refs) end end

table.insert(bits, bit) end

return table.concat(bits, separator) end

function export.format_UPA_full(lang, items) local prefix = 'UPA (SUT ):&#32;' local UPAs = export.format_UPA_multiple(lang, items, nil, true) return prefix .. UPAs .. get_stylesheet end

return export