Feed The Beast Wiki

Follow the Feed The Beast Wiki on Discord or Mastodon!

READ MORE

Feed The Beast Wiki
Advertisement
{{#invoke:Math templates|subst|math|arg1|arg2|...}}

Prints math inside math tags, with the arguments substituted in. Use ${n} to invoke substitution of parameter n, drawn from the arguments to #invoke.

For instance,

{{#invoke:Math templates|subst|${2} + ${3} = ${4}|a|b|c}}

expands to

<math>a + b = c</math>

display is special: it becomes the same-named attribute of the math tags.


local p = {}

function p.ROCSpeed(f)
    return f:preprocess("<math display=\"inline\">Time = " .. f.args[1] .. " - ".. f.args[2] .. " \\times \\log_{2}(x+1)</math>")
end

function p.subst(thisframe)
    local function replace(marker)
        local name = marker:sub(3, -2)
        name = tonumber(name) or name
        return thisframe.args[name] or marker
    end

    local str = "<math"
    if thisframe.args["display"] then
        str = str .. " display=\"" .. thisframe.args["display"] .. "\""
    end
    str = str .. ">" .. thisframe.args[1]:gsub('($%b{})', replace) .. "</math>"
    
    return thisframe:preprocess(str)
end

return p
Advertisement