Module:How Mercury mangles pre tags

--

-- Scribunto allows you to write non-escaping tags, in addition to the -- wikitext version with leading spaces. -- -- @see How Mercury mangles pre tags -- @see Module:Code blocks

local p = {}

local lines = { mw.html.create(nil):wikitext(       "text (no wrapper)"    ), mw.html.create("span"):wikitext(mw.text.nowiki( "text " )),   mw.html.create(nil):wikitext(        "text (triple quotes)"    ), mw.html.create("b"):wikitext(mw.text.nowiki( "text ()" )),   mw.html.create("strong"):wikitext(mw.text.nowiki( "text " )),   mw.html.create("span"):css("font-weight", "bold"):wikitext(mw.text.nowiki( "text ()" )), }

local separators = { ["\n"] = mw.html.create(nil):newline, ["br"] = mw.html.create("br"), }

local fns = { one = { wrapper = mw.html.create("p"), separator = "\n", },   two = { wrapper = mw.html.create("p"), separator = "br", },   three = { wrapper = mw.html.create("pre"), separator = "\n", },   four = { wrapper = mw.html.create("pre"), separator = "br", },   five = { wrapper = mw.html.create("pre"):css("white-space", "pre"), separator = "\n", },   six = { wrapper = mw.html.create("pre"):css("white-space", "pre"), separator = "br", },   seven = { wrapper = mw.html.create("pre"):tag("span"), separator = "\n", },   eight = { wrapper = mw.html.create("pre"):tag("span"), separator = "br", },   nine = { wrapper = mw.html.create("pre"):tag("code"), separator = "\n", },   ten = { wrapper = mw.html.create("pre"):tag("code"), separator = "br", }, }

for fn, data in pairs(fns) do   local wrapper = data.wrapper local separator = separators[data.separator]

p[fn] = function for i, line in ipairs(lines) do           if i > 1 then wrapper:node(separator) end

wrapper:node(line) end

return wrapper:allDone end end

return p