Module:Grind/html

From Fallen London Wiki

Documentation for this module may be created at Module:Grind/html/doc

local p = {}

-- == HTML formatting helpers ==
p.OL, p._OL = '<ol style="margin-left: 1em;">', '</ol>'
p.UL, p._UL = '<ul style="margin-left: 1em;">', '</ul>'
p.LI, p._LI = '<li>', '</li>'

-- These should be suitable for both dark and light modes.
p.red = '#ab2727'
p.orange = '#997312'
p.cyan = '#128aa2'

-- Puts the HTML text in a horizontally scrollable container.
function p.widebox(text)
	return '<div style="overflow-x: auto; white-space: nowrap;">'
		.. '<div style="width: fit-content;">'
		.. text
		.. '</div>'
		.. '</div>'
end

function p.span(text, colour, bold)
	bold = bold or false
	if bold then
		return '<span style="color: ' .. colour .. ';">'
			.. "'''" .. text .. "'''"
			.. '</span>'
	else
		return '<span style="color: ' .. colour .. ';">'
			.. text
			.. '</span>'
	end
end

return p