local yesno = require('Module:Yesno')local ordinal = require('Module:Ordinal')._ordinal
local p =
function p.style(pos, host) local style = (host and "border:3px solid red;" or ) if pos
'2' then style = style .. "background-color:silver;" elseif pos
'4' then style = style .. "background-color:#9ACDFF;" end return (style ~= and ('style="' .. style .. '" ') or )end
function p.filter_position(pos) -- Parse position string (`H`, `Q`, `.` or digits) local actual_pos, suffix = mw.ustring.match(pos, "^H?([QW%.])(.*)") if actual_pos
nil then actual_pos, suffix = pos, "" end return actual_pos, suffixend
function p.sort_value(pos) local n = if pos
'W' then n = 998 elseif pos
function p.content(pos) if tonumber(pos) then return ordinal(pos) elseif pos
'W' then return "" elseif pos
function p.cell(pos) local host = false if pos
'H' then host = true -- pos = mw.ustring.sub(pos, 2) end local actual_pos, suffix = p.filter_position(pos) return p.style(actual_pos, host) .. p.sort_value(actual_pos) .. '| ' .. p.content(actual_pos) .. suffixend
function p.appeared(pos) local actual_pos, suffix = p.filter_position(pos) return mw.ustring.sub(actual_pos, 1, 1)
function p.main(frame) -- If called via #invoke, use the args passed into the invoking template. if frame
return p