Module:MercuryQuote

--| MercuryQuote (v0.9.5) --- Fixes occassional incorrect rendering of quote templates (or templates --- designated as "quote" through template type) in the mercury mobile skin. --- This should be used in place of the desired quote template invocation. --by author: The JoTS

--

local templ, qtei, srci = "Quote", 1, 2 local ZEROWIDTH, ARGSEP = "&shy;", "|"

--- Designed to "re-generate" arguments for a template invocation. Parse order does not allow this to work as intended. function modifyStr(frame) local args = frame.args local qte, src = args[qtei], args[srci] local nqte, nsrc = #qte, #src local templArgs = {} -- Make quotation fix for mercury if nqte < nsrc then qte = qte .. frame:preprocess(ZEROWIDTH:rep(nsrc - nqte)) end -- Copy arguments into template invocation for i,v in pairs(args) do templArgs[i] = v end templArgs[qtei] = qte return table.concat(templArgs, ARGSEP) end

--- Merely bypasses mercury's conversions outright. function mercuryBypass(frame) local templArgs = {} -- Copy arguments into template invocation for i,v in pairs(frame.args) do templArgs[i] = v end return frame:expandTemplate{ title = templ, args = templArgs } end

return setmetatable({   hack = function(frame)        return modifyStr(frame)    end,    main = function(frame)        return mercuryBypass(frame)    end, }, {    __call = function(t, templ, q, s)        templ = templName        qtei = q or qtei        srci = s or srci        return t    end })