Module:Sandbox/Wnt/TextMarkup explained
---- This module accepts a piece of text or the name of a page ---- It acts on angle-bracket tags in the text to simulate an extension of the html/wiki markup set ---- Vaguely per, the tag is the first example, replaced with a number ---- that increases each count. You can set or reset the count and rate at any time by ---- where i=the number of that tag and j is the difference to succeeding tags.
local p=
function p.markup(frame) local args=frame.args local parent=frame.getParent(frame) or pargs=parent.args or local text=args.text or pargs.text local page=args.page or pargs.page if (not text and not page) then if not args[1] then return "" end if mw.ustring.match(args[1],"") then text=args[1] else page=args[1] end end if not text then page=mw.ustring.match(page,"%s*(.*%S)%s*") or "" if page
"" then title=mw.title.getCurrentTitle assert(title.getContent, "Bug: failed to get content of the current page") page=title.fullText else title=mw.title.new(page) assert(title.getContent, "Error: failed to get content of "..page) end -- one way or another, we have a working getContent method text=title.getContent(title) end -- (not text) -- now we have text local counter=0 -- set counter to zero before encountering an tag local increment=1 -- default increment local prowl=mw.ustring.gmatch(text,"") -- iterator function to get all the tags local output=text -- copy to do substitutions on repeat local inccontent=prowl if not inccontent then break end -- loop exit local n1,n2 = mw.ustring.match(text,"%D-(%d+)%D-(%d+)") if n2 then increment=tonumber(n2) end counter=counter+increment if n1 then counter=tonumber(n1) end output=mw.ustring.gsub(output,"",tostring(counter),1) -- change one instance according to the one instance found until false return outputend
return p