:css('-radius', getParam(args, 'title--radius') or '0')
return toOpenTagString(tag)
end  
local function boxHeaderTopLinks(args)
local style = {
float = '',
['margin-bottom'] = '.1em',
['font-size'] = getParam(args, 'font-size') or '80%',
color = getParam(args, 'titleforeground') or '#000'
}
local tag = mw.html.create('div', {selfClosing = true})
:addClass('plainlinks noprint' )
:css(style)
return toOpenTagString(tag)
end  
local function boxHeaderEditLink(args)
local page = getParam(args, 'editpage')
if not page or page == '}'
then
return ''
end
local style = {
color = getParam(args, 'titleforeground') or '#000'
}
local tag = mw.html.create('span')
:css(style)
:wikitext('தொகு')
local linktext = tostring(tag)
local linktarget = tostring(mw.uri.fullUrl(page, {action='edit', section=getParam(args, 'section')}))
return '[' .. linktarget .. ' ' .. linktext .. ']&nbsp;'
end  
local function boxHeaderViewLink(args)
local style = {
color = getParam(args, 'titleforeground') or '#000'
}
local tag = mw.html.create('span')
:css(style)
:wikitext('பார்')
local linktext = tostring(tag)
local linktarget = ':' .. getParam(args, 'viewpage')
return "<b>·</b>&nbsp;' .. linktext .. '&nbsp;'
end  
local function boxHeaderTitle(args)
local baseStyle = {
['font-family'] = getParam(args, 'title-font-family') or 'sans-serif',
['font-size'] = getParam(args, 'title-font-size') or '100%',
['font-weight'] = getParam(args, 'title-font-weight') or 'bold',
= '',
margin = '0',
padding = '0',
color = getParam(args, 'titleforeground') or '#000';
}
local tagName = getParam(args, 'SPAN') and 'span' or 'h2'
local tag = mw.html.create(tagName)
:css(baseStyle)
:css('padding-bottom', '.1em')
:wikitext(getParam(args, 'title'))
if getParam(args, 'extra') then
local rules = mw.text.split(getParam(args, 'extra'), ';', true)
for _, rule in pairs(rules) do
local parts = mw.text.split(rule, ':', true)
local prop = parts[1]
local val = parts[2]
if prop and val then
tag:css(prop, val)
end
end
end
return tostring(tag)
end  
local function boxBody(args)
local baseStyle = {
['box-sizing'] = '-box',
= ( getParam(args, '-width') or '1' ) .. 'px solid ' .. ( getParam(args, '') or '#ababab'),
['vertical-align'] = 'top';
background = getParam(args, 'background') or '#fefeef',
opacity = getParam(args, 'background-opacity') or '1',
color = getParam(args, 'foreground') or '#000',
['text-align'] = getParam(args, 'text-align') or '',
margin = '0 0 ',
padding = getParam(args, 'padding') or '1em',
}
local tag = mw.html.create('div', {selfClosing = true})
:css(baseStyle)
:css('-top-width', ( getParam(args, '-top') or '1' ) .. 'px')
:css('padding-top', getParam(args, 'padding-top') or '.3em')
:css('-radius', getParam(args, '-radius') or '0')
return toOpenTagString(tag)
end  
local function contrastCategories(args)
local cats = ''  
local titleText = nameToHexTriplet(getParam(args, 'titleforeground')) or normaliseHexTriplet(getParam(args, 'titleforeground')) or '#000000'
local titleBackground = nameToHexTriplet(getParam(args, 'titlebackground')) or normaliseHexTriplet(getParam(args, 'titlebackground')) or '#bcbcbc'
local titleContrast = colourContrastModule._ratio({titleBackground, titleText})
local insufficientTitleContrast = type(titleContrast) == 'number' and ( titleContrast < min_contrast_ratio_large_text )  
local bodyText = nameToHexTriplet(getParam(args, 'foreground')) or normaliseHexTriplet(getParam(args, 'foreground')) or '#000000'
local bodyBackground = nameToHexTriplet(getParam(args, 'background')) or normaliseHexTriplet(getParam(args, 'background')) or '#fefeef'
local bodyContrast = colourContrastModule._ratio({bodyBackground, bodyText})
local insufficientBodyContrast = type(bodyContrast) == 'number' and ( bodyContrast < min_contrast_ratio_normal_text )  
if insufficientTitleContrast and insufficientBodyContrast then
return ''
elseif insufficientTitleContrast then
return ''
elseif insufficientBodyContrast then
return ''
else
return ''
end
end  
---------- Main functions / entry points ----------  
-- Entry point for templates (manually-specified colours)
function p.boxHeader
local args = getArgs
local page = args.editpage
if not args.editpage or args.editpage == '' then
page = mw.title.getCurrentTitle.prefixedText
end
local output = p._boxHeader(args, page)
if mw.ustring.find(output, '{') then
return :preprocess(output)
end
return output
end  
-- Entry point for modules (manually-specified colours)
function p._boxHeader(_args, page)
local args = setCleanArgs(_args)
if page and not args.editpage then
args.editpage = page
end
if not args.title then
args.title = '}'
end
local output = {}
table.insert(output, boxHeaderOuter(args))
if not getParam(args, 'EDITLINK') then
table.insert(output, boxHeaderTopLinks(args))
if not getParam(args, 'noedit') then
table.insert(output, boxHeaderEditLink(args))
end
if getParam(args, 'viewpage') then
table.insert(output, boxHeaderViewLink(args))
end
if getParam(args, 'top') then
table.insert(output, getParam(args, 'top') .. '&nbsp;')
end
table.insert(output, '</div>')
end
table.insert(output, boxHeaderTitle(args))
table.insert(output, '</div>')
table.insert(output, boxBody(args))
if not getParam(args, 'TOC') then
table.insert(output, '__NOTOC__')
end
if not getParam(args, 'EDIT') then
table.insert(output, '__NOEDITSECTION__')
end
table.insert(output, contrastCategories(args))  
return table.concat(output)
end  
-- Entry point for templates (automatically calculated colours)
function p.autoColour
local args = getArgs
local colourParam = getParam(args, 'colour')
local generatedColour = nil
if not colourParam or colourParam == '' then
-- convert the root page name into a number and use that
local root = mw.title.getCurrentTitle.rootPageTitle.prefixedText
local rootStart = mw.ustring.sub(root, 1, 12)
local digitsFromRootStart = mw.ustring.gsub(rootStart, ".", function(s) return math.fmod(string.byte(s, 2) or string.byte(s, 1), 10) end)
local numberFromRoot = tonumber(digitsFromRootStart, 10)
generatedColour = math.fmod(numberFromRoot, 360)
end
local output = p._autoColour(args, generatedColour)
if mw.ustring.find(output, '{') then
return :preprocess(output)
end
return output
end  
-- Entry point for modules (automatically calculated colours)
function p._autoColour(_args, generatedColour)
local args = setCleanArgs(_args)
local hue = generatedColour or findHue(getParam(args, 'colour'))
local mode = normaliseMode(getParam(args, 'mode'))
local , titleForeground, titleBackground, contentForeground, contentBackground = makeColours(hue, mode)
local boxTemplateArgs = mergeTables(args, {
title = getParam(args, '1') or '}',
editpage = getParam(args, '2') or '',
noedit = getParam(args, '2') and '' or 'yes',
= ,
titleforeground = titleForeground,
titlebackground = titleBackground,
foreground = contentForeground,
background = contentBackground
})
return p._boxHeader(boxTemplateArgs)
end  
return p