Module:head: Difference between revisions

ਕੋਈ ਸੋਧ ਸਾਰ ਨਹੀਂ
No edit summary
No edit summary
Line 3: Line 3:


function export.show(frame)
function export.show(frame)
local function make_head(head)
if not string.find(head, " ") then
return head
end
local pieces = {}
for piece in string.gmatch(head, "%S+") do
table.insert(pieces, "[[" .. piece .. "]]")
end
return table.concat(pieces, " ")
end
local args = (frame:getParent() and frame:getParent().args) or frame.args
local args = (frame:getParent() and frame:getParent().args) or frame.args
local language = get_by_code(args[1])
local language = get_by_code(args[1])
Line 9: Line 20:
error("Part of speech must be supplied")
error("Part of speech must be supplied")
end
end
local head = args["head"] or mw.title.getCurrentTitle().text
local head = args["head"] or make_head(mw.title.getCurrentTitle().text)
return "'''" .. head .. "'''[[Category:" .. language.name .. " " .. pos .. "s]]"
return "'''" .. head .. "'''[[Category:" .. language.name .. " " .. pos .. "s]]"
end
end


return export
return export