Module:Xpd

-- Expansion demo, like Template:Xpd

local p = {} function p.f(frame,showwikitext,sep) local r='' local t={} pframe = frame:getParent for n,v in pframe:argumentPairs do    if type(n)==number then t[n-1]=v else t[n]=v end end local tplname local tplargs={} tplargs[1]='' for n,v in pairs(t) do  if n==1 then tplname=v else tplargs[n]=v end end table.remove (tplargs,1) local w='' r=r..' → ' local xpw=frame:preprocess (w) if showwikitext then r=r..sep..' → ' end r=r..sep..xpw return r end function p.s(frame) local sep='' return p.f(frame,false,sep) end

function p.p(frame) local sep='\n\n' return p.f(frame,false,sep) end function p.ws(frame) local sep='' return p.f(frame,true,sep) end

function p.wp(frame) local sep='\n\n' return p.f(frame,true,sep) end

function p.unexpand(w) local w1=w w1=string.gsub (w1, '{', 'lbrace') w1=string.gsub (w1, '}', 'rbrace') w1=string.gsub (w1, 'lbrace', '') w1=string.gsub (w1, 'rbrace', '') w1=string.gsub (w1, '|', '|') w1=string.gsub (w1, '=', '=') return w1 end function p.swt(w) local w1=w w1=string.gsub (w1, '&', '&amp;') w1=string.gsub (w1, '<', '&lt;') w1=string.gsub (w1, "%'", '&#39;') w1=string.gsub (w1, '%[', '&#91;') w1=string.gsub (w1, '%]', '&#93;') w1=string.gsub (w1, '\n', ' ') w1=string.gsub (w1, ' ', ' ') return w1 end function p.plain(frame,sep) local pframe = frame:getParent local w = pframe.args[1] local w1=p.swt(p.unexpand(w)) local r=' → ' r=r..sep..w return r end function p.plains(frame) return p.plain(frame,'') end

function p.plainp(frame) return p.plain(frame,'\n\n') end return p