Jump to content

Module:Tone superscript: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
mNo edit summary
mNo edit summary
Line 6: Line 6:
local x = arg:gsub("(%d)", "<sup>%1</sup>")
local x = arg:gsub("(%d)", "<sup>%1</sup>")
x = x:gsub("(%d)</sup>%*<sup>(%d)", "%1*%2")
x = x:gsub("(%d)</sup>%*<sup>(%d)", "%1*%2")
x = x:gsub("<sup>(<sup>)+(.*)(</sup>)+</sup>", "<sup>%2</sup>")
x = x:gsub("<sup>(<sup>)+([%d%*]+)(</sup>)+</sup>", "<sup>%2</sup>")
root:tag('span'):wikitext(x)
root:tag('span'):wikitext(x)
return tostring(root)
return tostring(root)

Revision as of 01:48, 20 March 2017

local p = {}

function p.main(frame)
	local root = mw.html.create()
	local arg = frame:getParent().args[1] or ""
	local x = arg:gsub("(%d)", "<sup>%1</sup>")
	x = x:gsub("(%d)</sup>%*<sup>(%d)", "%1*%2")
	x = x:gsub("<sup>(<sup>)+([%d%*]+)(</sup>)+</sup>", "<sup>%2</sup>")
	root:tag('span'):wikitext(x)
	return tostring(root)
end

return p