--require "mw.text"--require "string"--require "table"localz={mw=require"Module:mw"}-- This splits a string of name="value" pairs into a table.-- The common use of this is to parse a single template argument that specifies HTML element attributes all in one lump.functionz.SplitHTMLElementParams(s)localparams={}forname,valueinstring.gmatch(s,"([%w_]+)=\"([^\"]*)\"%s*")doparams[name]=valueendreturnparamsend-- This returns a string quoted using quotation marks, using HTML character entities for embedded quotation marks and ampersands.functionz.quote(t)localchars={}fori=1,#tdolocalchar=t:sub(i,i)localbyte=char:byte()if(byte==34orbyte==38)thentable.insert(chars,"&#"..tostring(byte)..";")elsetable.insert(chars,char)endendreturn"\""..table.concat(chars).."\""endfunctionz.CombineHTMLElementParams(params)localattrs={}forn,vinpairs(params)dotable.insert(attrs,n.."="..z.quote(v))endreturntable.concat(attrs," ")endfunctionRawOpenHTMLTag(name,params)localattr=z.CombineHTMLElementParams(params)return"<"..name.." "..attr..">"endfunctionz.OpenHTMLTag(t)localname=t.nameor"!-- --"if("nowiki"==nameor"ref"==nameor"pre"==nameor"gallery"==nameor"poem"==nameor"references"==name)thenerror(name..": OpenHTMLTag is for non-extension tags only.")endreturnRawOpenHTMLTag(name,t.params)end-- This returns the canonical form of an editor-supplied time, for use in cleanup category names.functionz.canonicalcleanuptime(t)returnt-- FIXME: This isn't right.end-- This returns a list formatted into a (intended to be human-readable) comma-separated form.functionz.oxfordlist(args,separator,ampersand)localtext=""separator=separatoror","ampersand=ampersandor"and"forindex,arginipairs(args)doif(index<2)then-- Add nothing before the first item.elseif(args[index+1]~=nil)thentext=text..separator.." "elseif(index>2)thentext=text..separator.." "..ampersand.." "elsetext=text.." "..ampersand.." "endtext=text..argendreturntextend-- These return various CSS strings.functionz.columncountstyle(n)return"-moz-column-count:"..n.."; -webkit-column-count:"..n.."; column-count:"..n..";"endfunctionz.columnwidthstyle(n)return"-moz-column-width:"..n.."; -webkit-column-width:"..n.."; column-width:"..n..";"endfunctionz.liststyle(n)return"list-style-type:"..n..";"endreturnz