2023年政策修订增补工作正在进行中,欢迎参与!
Module:Sandbox/红石小蝈/LaTeX
< Module:Sandbox | 红石小蝈
local ret = {}
local function convert(tex, it)
if (mw.ustring.sub(tex, it.it, it.it) ~= '{') then
local res = mw.ustring.sub(tex, it.it, it.it)
it.it = it.it + 1
return res
end
it.it = it.it + 1
local part = ""
while(true) do
local char = mw.ustring.sub(tex, it.it, it.it)
it.it = it.it + 1
if (char == '_') then
part = part.."<sub>"..convert(tex, it).."</sub>"
elseif (char == '^') then
part = part.."<sup>"..convert(tex, it).."</sup>"
elseif (char == '}') then
return part
else
part = part..char
end
end
end
function ret.conv(frame)
return convert('{'..frame.args[1]..'}',{it = 1})
end
return ret