Fandom Developers Wiki
No edit summary
m (...)
Line 1: Line 1:
--| MercuryQuote (v0.9.5)
+
--| MercuryQuote (v0.9.6)
 
--- Fixes occassional incorrect rendering of quote templates (or templates
 
--- Fixes occassional incorrect rendering of quote templates (or templates
 
--- designated as "quote" through template type) in the mercury mobile skin.
 
--- designated as "quote" through template type) in the mercury mobile skin.
Line 55: Line 55:
 
{
 
{
 
__call = function(t, templ, q, s)
 
__call = function(t, templ, q, s)
templ = templName
+
templName = templ
 
qtei = q or qtei
 
qtei = q or qtei
 
srci = s or srci
 
srci = s or srci

Revision as of 01:48, 15 April 2018

Documentation icon Module documentation

The documentation for this module is missing. Click here to create it.

--| MercuryQuote (v0.9.6)
--- 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

-- <nowiki>

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)
        templName = templ
        qtei = q or qtei
        srci = s or srci
        return t
    end
})