Module:Pt

local p = {}

local styles=mw.loadData("Module:Pt/styles")

function p.table(frame) -- attribute1 | value1 | ... | ... | attributeN | valueN local c = frame.args[1] or "" local attributes = {} local rv = "" local x = 2 while frame.args[x] do attributes[frame.args[x]] = frame.args[x+1] x = x + 2 end attributes.style=(attributes.style or "") rv=mw.text.tag('table',attributes,tostring(c)) return rv end

function p.tr(frame) -- attribute1 | value1 | ... | ... | attributeN | valueN local c = frame.args[1] or "" local attributes = {} local rv = "" local x = 2 while frame.args[x] do attributes[frame.args[x]] = frame.args[x+1] x = x + 2 end attributes.style=(attributes.style or "") rv=mw.text.tag('tr',attributes,tostring(c)) return rv end

function p.th(frame) -- attribute1 | value1 | ... | ... | attributeN | valueN local c = frame.args[1] or "" local attributes = {} local rv = "" local x = 2 while frame.args[x] do attributes[frame.args[x]] = frame.args[x+1] x = x + 2 end attributes.style=(attributes.style or "") rv=mw.text.tag('th',attributes,tostring(c)) return rv end

function p.td(frame) -- attribute1 | value1 | ... | ... | attributeN | valueN local c = frame.args[1] or "" local attributes = {} local rv = "" local x = 2 while frame.args[x] do attributes[frame.args[x]] = frame.args[x+1] x = x + 2 end attributes.style=(attributes.style or "") rv=mw.text.tag('td',attributes,tostring(c)) return rv end

function p.sup(frame) -- attribute1 | value1 | ... | ... | attributeN | valueN local c = frame.args[1] or "" local attributes = {} local rv = "" local x = 2 while frame.args[x] do attributes[frame.args[x]] = frame.args[x+1] x = x + 2 end attributes.style=(attributes.style or "") rv=mw.text.tag('sup',attributes,tostring(c)) return rv end

function p.br(frame) -- local attributes = {} local rv = "" rv=mw.text.tag('br',attributes,nil) return rv end

function p.hr(frame) -- value1 | ... | ... | attributeN | valueN local attributes = {} local rv = "" local x = 1 while frame.args[x] do attributes[frame.args[x]] = frame.args[x+1] x = x + 2 end attributes.style=(attributes.style or "") rv=mw.text.tag('hr',attributes,nil) return rv end

function p.ib(frame) -- contents | attribute1 | value1 | ... | ... | attributeN | valueN local k = frame.args[1] local c = frame.args[2] local attributes = {} local rv = "" local x = 3 while frame.args[x] do attributes[frame.args[x]] = frame.args[x+1] x = x + 2 end attributes.style=(attributes.style or "") if ( ( (not k) or (k=='') ) or (mw.ustring.lower(k)=='script')) then rv="" elseif (k=='LT') then attributes.style=styles.LT rv = mw.text.tag('td',attributes,'') elseif (k=='LM') then attributes.style=styles.LM rv = mw.text.tag('td',attributes,'') elseif (k=='LB') then attributes.style=styles.LB rv = mw.text.tag('td',attributes,'') elseif (k=='CT') then attributes.style=styles.CT rv = mw.text.tag('td',attributes,'') elseif (k=='CM') then attributes.style= (attributes.style or "") .. styles.CM rv = mw.text.tag('td',attributes,tostring(c)) elseif (k=='CB') then attributes.style=styles.CB rv = mw.text.tag('td',attributes,'') elseif (k=='RT') then attributes.style=styles.RT rv = mw.text.tag('td',attributes,'') elseif (k=='RM') then attributes.style=styles.RM rv = mw.text.tag('td',attributes,'') elseif (k=='RB') then attributes.style=styles.RB rv = mw.text.tag('td',attributes,'') elseif (c=='/') then rv=mw.text.tag(k,attributes,nil) else rv=mw.text.tag(k,attributes,tostring(c)) end return rv end

function p.star(frame) -- max | full_star | empty_star local v = tonumber(frame.args[1]) or 0 local m = tonumber(frame.args[2]) or 10 local f = frame.args[3] local e = frame.args[4] local sc = {"",""} local rv = "" if (v < 0) then v = 0 end if (m < 1) then m = 10 end if (not f) then f = "&#9733;" end if (not e) then e = "&#9734;" end for c = 1, m do if (c <= v) then table.insert(sc,f) else table.insert(sc,e) end end rv = table.concat(sc) return rv end

function p.o(frame) -- return frame:preprocess('') end -- o

return p