Module:Vertical header/sandbox
Appearance
This is the module sandbox page for Module:Vertical header (diff). |
require('strict')
local p = {}
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local function _vertical_header_cell(args)
local text = args[1] or args.text
local width = 0
if args.maxWidth then
width = args.maxWidth
else
local rows = 1
for eachMatch in text:gmatch('<[bB][rR] */? *>') do
rows = rows + 1
end
width = rows .. 'em'
end
local vertAlign = args.vertAlign and 'is-valign-' .. args.vertAlign
local noBold = yesno(args.noBold) and 'is-normal'
local cellDiv = mw.html.create('div')
:addClass('nowrap ts-vertical-header')
:addClass(vertAlign)
:addClass(noBold)
:addClass(args.class)
:css({
['width'] = width ~= '1em' and width,
['max-width'] = width ~= '1em' and width,
['style'] = args.cellstyle
})
:wikitext(args.text)
local stylesheet = mw.getCurrentFrame():extensionTag{
name = 'templatestyles',
args = {src = 'Module:Vertical header/styles.css'}
}
return stylesheet .. tostring(cellDiv)
end
function p.cell(frame)
return _vertical_header_cell(getArgs(frame))
end
return p