Module:Tone superscript: Difference between revisions
Appearance
Content deleted Content added
Dabao qian (talk | contribs) // Edit via Wikiplus |
mNo edit summary |
||
Line 1: | Line 1: | ||
local p = { |
local p = {} |
||
main = main, |
|||
} |
|||
function p.main(frame) |
function p.main(frame) |
||
local root=mw.html.create() |
local root = mw.html.create() |
||
local arg=frame:getParent().args[1] |
local arg = frame:getParent().args[1] |
||
if not arg or arg:len()==0 then |
if not arg or arg:len() == 0 then |
||
root:tag('strong'):attr('class','error'):wikitext('Error: |
root:tag('strong'):attr('class','error'):wikitext('Error: No input.') |
||
return tostring(root) |
return tostring(root) |
||
end |
end |
||
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>") |
|||
x = x:gsub("</sup></sup>", "</sup>") |
|||
root:tag('span'):wikitext(x) |
root:tag('span'):wikitext(x) |
||
return tostring(root) |
return tostring(root) |
Revision as of 13:19, 19 March 2017
Implements {{Tone superscript}}
local p = {}
function p.main(frame)
local root = mw.html.create()
local arg = frame:getParent().args[1]
if not arg or arg:len() == 0 then
root:tag('strong'):attr('class','error'):wikitext('Error: No input.')
return tostring(root)
end
local x = arg:gsub("(%d)", "<sup>%1</sup>")
x = x:gsub("(%d)</sup>%*<sup>(%d)", "%1*%2")
x = x:gsub("<sup><sup>", "<sup>")
x = x:gsub("</sup></sup>", "</sup>")
root:tag('span'):wikitext(x)
return tostring(root)
end
return p