2023年政策修订增补工作正在进行中,欢迎参与!
  • Moegirl.ICU:萌娘百科流亡社群 581077156(QQ),欢迎对萌娘百科运营感到失望的编辑者加入
  • Moegirl.ICU:账号认领正在试运行,有意者请参照账号认领流程

Module:Sandbox/红石小蝈/LaTeX

萌娘百科,万物皆可萌的百科全书!转载请标注来源页面的网页链接,并声明引自萌娘百科。内容不可商用。
跳转到导航 跳转到搜索
Template-info.svg 模块文档  [创建] [刷新]
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