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 4: Line 4:
local root = mw.html.create()
local root = mw.html.create()
local arg = frame:getParent().args[1] or ""
local arg = frame:getParent().args[1] or ""
local x = arg:gsub("(%d)", "<sup>%1</sup>")
local x = arg:gsub("(%d)", "<sup>%1</sup>"):gsub("(%d)</sup>%*<sup>(%d)", "%1*%2"):gsub("<sup><sup>([%d%*]+)</sup></sup>", "<sup>%1</sup>")
x = x:gsub("(%d)</sup>%*<sup>(%d)", "%1*%2")
x = x:gsub("<sup><sup>([%d%*]+)</sup></sup>", "<sup>%1</sup>")
root:tag('span'):wikitext(x)
root:tag('span'):wikitext(x)
local tracking = ''
local tracking = ''

Revision as of 09:10, 24 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>"):gsub("(%d)</sup>%*<sup>(%d)", "%1*%2"):gsub("<sup><sup>([%d%*]+)</sup></sup>", "<sup>%1</sup>")
	root:tag('span'):wikitext(x)
	local tracking = ''
	if string.match(arg, "</?sup>") then tracking = '[[Category:Pages using Tone superscript with sup tags]]' end
	return tostring(root)..tracking
end

return p