Module:Classed heading
Appearance
Logic for {{classed heading}}.
--[=[
Module to implement the logic for [[Template:Plain heading]]
]=]
local getArgs = require('Module:Arguments').getArgs
local p = {} --p stands for package
--[=[
Primary entry point
]=]
function p.heading(frame)
local args = getArgs(frame)
local level = args['l'] or args['level'] or 2
-- explicit ID or fall back to the first line
local id = args['id'] or args[1]
-- top level <hX> tag
local tag = mw.html.create('h' .. level)
:addClass('wst-heading')
:addClass(args['class'])
:attr('id', id)
local line = 1
-- add a span for every given positional parameter
while true do
if not args[line] then
break
end
local line_span = tag:tag( 'span' )
:wikitext(args[line])
:addClass('wst-heading-line')
line = line + 1
end
return tag
end
return p