Module:Font
Creates a span with given font styles.
See Template:Font for documentation.
local getArgs = require('Module:Arguments').getArgs
local p = {}
function _font(args)
local html_size = {
["0"] = "xx-small",
["1"] = "x-small",
["2"] = "small",
["3"] = "medium",
["4"] = "large",
["5"] = "x-large",
["6"] = "xx-large",
["7"] = "xxx-large"
}
local font_family = args["font"] or args["family"] or args["face"]
local font_size = html_size[args["size"]] or args["size"] or "100%"
local font_weight = args["weight"] or "normal"
local color = args["color"] or "black"
local background_color = args["bgcolor"] or args["background"] or "transparent"
local style = args["css"] or args["style"] or nil
local lang = args["lang"] or nil
local title = args["title"] or nil
local text = args["text"] or args[1] or ''
local span = mw.html.create('span')
span
:css('font-family', font_family)
:css('font-size', font_size)
:css('font-weight', font_weight)
:css('color', color)
:css('background-color', background_color)
:cssText(style)
:attr('lang', lang)
:attr('title', title)
:wikitext(text)
return tostring(span)
end
function p.font(frame)
return _font(getArgs(frame))
end
return p