Module:Scripts/naqoo: Difference between revisions

From Annwan’s Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(37 intermediate revisions by the same user not shown)
Line 23: Line 23:
     ['j'] = {type = 'S', loff = {-10.0,-75.0}, roff = {30.0,-75.0}, eoff = {12.0,-3.0}, h = 100.0 ,path = 'v 25 c 0 6 6 12 12 12,  6 0 12 -6 12 -12,  0 -6 -6 -12 -12 -12,  -6 0 -12 6 -12 12 v 25c 0 12.5 12.5 25 25 25,  -12.5 0 -25 12.5 -25 25'},
     ['j'] = {type = 'S', loff = {-10.0,-75.0}, roff = {30.0,-75.0}, eoff = {12.0,-3.0}, h = 100.0 ,path = 'v 25 c 0 6 6 12 12 12,  6 0 12 -6 12 -12,  0 -6 -6 -12 -12 -12,  -6 0 -12 6 -12 12 v 25c 0 12.5 12.5 25 25 25,  -12.5 0 -25 12.5 -25 25'},
     ['k'] = {type = 'S', loff = {-30.0,-25.0}, roff = {15.0,-25.0}, eoff = {12.0,-2.0}, h = 50.0 ,path = 'c 0 7.5 -12.5 20 -25 20 m 30 -15 c 0 7.5 -12.5 20 -30 20,  12.5 0 30 7.5 30 20 m -30 -15 c 12.5 0 25 7.5 25 20 '},
     ['k'] = {type = 'S', loff = {-30.0,-25.0}, roff = {15.0,-25.0}, eoff = {12.0,-2.0}, h = 50.0 ,path = 'c 0 7.5 -12.5 20 -25 20 m 30 -15 c 0 7.5 -12.5 20 -30 20,  12.5 0 30 7.5 30 20 m -30 -15 c 12.5 0 25 7.5 25 20 '},
     ['l'] = {type = 'S', loff = {-30.0,-25.0}, roff = {0.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm -12.5 0 l 0 18.75 m 12.5 -18.75 c 0 12.5 -12.5 25 -25 25,  12.5 0 25 12.5 25 25'},
     ['l'] = {type = 'S', loff = {-30.0,-25.0}, roff = {0.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm -12.5 0 l 0 20 m 12.5 -20 c 0 12.5 -12.5 25 -25 25,  12.5 0 25 12.5 25 25'},
     ['n'] = {type = 'S', loff = {-30.0,-25.0}, roff = {0.0,-25.0}, eoff = {12.0,-3.0}, h = 60.0 ,path = 'm -12.5 5 h 25 m -25 5 h 25 m -12.5 -10 v 10 c 0 12.5 -12.5 25 -25 25,  12.5 0 25 12.5 25 25 '},
     ['n'] = {type = 'S', loff = {-30.0,-25.0}, roff = {0.0,-25.0}, eoff = {12.0,-3.0}, h = 60.0 ,path = 'm -12.5 5 h 25 m -25 5 h 25 m -12.5 -10 v 10 c 0 12.5 -12.5 25 -25 25,  12.5 0 25 12.5 25 25 '},
     ['o'] = {type = 'D', side = 'R', path = 'm 0 -6 l 12 12 m 0 -12 l -12 12m 0 -6'},
     ['o'] = {type = 'D', side = 'R', path = 'm 0 -6 l 12 12 m 0 -12 l -12 12m 0 -6'},
Line 34: Line 34:
     ['u'] = {type = 'D', side = 'R', path = 'm 6 -6 l -6 6 l 6 6 m -6 -6'},
     ['u'] = {type = 'D', side = 'R', path = 'm 6 -6 l -6 6 l 6 6 m -6 -6'},
     ['w'] = {type = 'S', loff = {-30.0,-25.0}, roff = {10.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'v 25 c 0 6 -6 12 -12 12,  -6 0 -12 -6 -12 -12,  0 -6 6 -12 12 -12,  6 0 12 6 12 12 v 25 '},
     ['w'] = {type = 'S', loff = {-30.0,-25.0}, roff = {10.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'v 25 c 0 6 -6 12 -12 12,  -6 0 -12 -6 -12 -12,  0 -6 6 -12 12 -12,  6 0 12 6 12 12 v 25 '},
     ['x'] = {type = 'S', loff = {-30.0,-25.0}, roff = {30.0,25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm 0 0 c 0 7.5 -12.5 22.5 -25 22.5 l 50 0 m -50 5 l 50 0 c -12.5 0 -25 7.5 -25 22.5 '},
     ['x'] = {type = 'S', loff = {-30.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm 0 0 c 0 7.5 -12.5 22.5 -25 22.5 l 50 0 m -50 5 l 50 0 c -12.5 0 -25 7.5 -25 22.5 '},
     ['y'] = {type = 'S', loff = {-10.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'v 25 c 0 6 6 12 12 12,  6 0 12 -6 12 -12,  0 -6 -6 -12 -12 -12,  -6 0 -12 6 -12 12 v 25 '},
     ['y'] = {type = 'S', loff = {-10.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'v 25 c 0 6 6 12 12 12,  6 0 12 -6 12 -12,  0 -6 -6 -12 -12 -12,  -6 0 -12 6 -12 12 v 25 '},
     ['Ā'] = {type = 'D', side = 'R', path = 'm 0 -6 v 12 m 12 -12 v 12 m -12 -6'},
     ['Ā'] = {type = 'D', side = 'R', path = 'm 0 -6 v 12 m 12 -12 v 12 m -12 -6'},
Line 41: Line 41:
     ['ē'] = {type = 'D', side = 'L', path = 'm 0 -12 l -12 12 l 12 12 m -12 0 l 12 -12 l -12 -12 m 12 12'},
     ['ē'] = {type = 'D', side = 'L', path = 'm 0 -12 l -12 12 l 12 12 m -12 0 l 12 -12 l -12 -12 m 12 12'},
     ['ħ'] = {type = 'S', loff = {-30.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm 0 0 c 0 7.5 -12.5 22.5 -25 22.5 l 50 0 m -12.5 -10 l -25 25 m -12.5 -10 l 50 0 c -12.5 0 -25 7.5 -25 22.5'},
     ['ħ'] = {type = 'S', loff = {-30.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm 0 0 c 0 7.5 -12.5 22.5 -25 22.5 l 50 0 m -12.5 -10 l -25 25 m -12.5 -10 l 50 0 c -12.5 0 -25 7.5 -25 22.5'},
     ['Ī'] = {type = 'D', side = 'L', path = 'm 0 -12 l -6 6 l 6 6 l -6 6 l 6 6 l 0 -12'},
     ['Ī'] = {type = 'D', side = 'L', path = 'm 0 -12 l -6 6 l 6 6 l -6 6 l 6 6 m 0 -12'},
     ['ī'] = {type = 'D', side = 'L', path = 'm -6 -12 l 6 6 l -6 6 l 6 6 l -6 6 m 6 -12'},
     ['ī'] = {type = 'D', side = 'L', path = 'm -6 -12 l 6 6 l -6 6 l 6 6 l -6 6 m 6 -12'},
     ['ń'] = {type = 'S', loff = {-30.0,-30.0}, roff = {15.0,-30.0}, eoff = {12.0,-3.0}, h = 60.0 ,path = 'm -12.5 5 h 25 m -25 5 h 25 m -12.5 -10 v 10 c 0 7.5 -12.5 20 -25 20 m 30 -12 c 0 7.5 -12.5 20 -30 20,  12.5 0 25 12.5 25 25 '},
     ['ń'] = {type = 'S', loff = {-30.0,-30.0}, roff = {15.0,-30.0}, eoff = {12.0,-3.0}, h = 60.0 ,path = 'm -12.5 5 h 25 m -25 5 h 25 m -12.5 -10 v 10 c 0 7.5 -12.5 20 -25 20 m 30 -12 c 0 7.5 -12.5 20 -30 20,  12.5 0 25 12.5 25 25 '},
Line 104: Line 104:
processLine = function(width, lno, l)
processLine = function(width, lno, l)
     local th = 0
     local th = 0
     local c = '<path d="m ' .. tostring(width - 50 - lno * 100) .. ' 10'
     local c = '<path class="script-naqoo-path" style="fill: none; stroke-width: 2.5px;" d="m ' .. tostring(width - 50 - lno * 100) .. ' 0'
     for w in ustring.gmatch(l, "[^%s]+") do
     for w in ustring.gmatch(l, "[^%s]+") do
         h, p = processWord(w)
         h, p = processWord(w)
Line 118: Line 118:


local process
local process
process = function(text)
process = function(text, addclass)
     local lines = {}
     local lines = {}
     for l in ustring.gmatch(text, "[^\n]+") do
     for l in ustring.gmatch(text, "[^\n]+") do
Line 134: Line 134:
         maxL = (maxL < l) and l or maxL
         maxL = (maxL < l) and l or maxL
     end
     end
     return [[<svg]] --[=[ width="]] .. tostring(w) .. [[" height="]] .. tostring(maxL + 20) .. [[" version="1.1" xmlns="http://www.w3.org/2000/svg"]=] .. [[>
     local x = mw.getCurrentFrame():extensionTag('svg', body, {
<style>
    class = "script-naqoo " .. addclass,
  path  {
    viewbox = "-10 -10 " .. tostring(10 + #lines * 100).. " " .. 10 + maxL,
     stroke: black;
    version="1.1",
     fill: none;
    preserveAspectRatio="xMinYMin meet",
    stroke-width: 2.5px;
    xmlns="http://www.w3.org/2000/svg"
    stroke-linecap: square;
     })
    stroke-linejoin: bevel;
     if not x then
  }
    mw.addWarning(body)
  @media (prefers-color-scheme: dark) {
    return "something went wrong"
    path {
     else return x end
      stroke="white";
     }
  }
</style>
]] .. body .. [[
</svg>]]
end
end


Line 177: Line 171:
text = ustring.gsub(text , "OO", "Ō")
text = ustring.gsub(text , "OO", "Ō")
text = ustring.gsub(text , "UU", "Ū")
text = ustring.gsub(text , "UU", "Ū")
return process(text)
if frame.args.float ~= "" then
return [[<div style="float:right">]] .. tostring(process(text, frame.args.addclass)) .. [[</div>]]
else
return process(text, frame.args.addclass)
end
end
end
}
}

Latest revision as of 21:53, 15 April 2025

Documentation for this module may be created at Module:Scripts/naqoo/doc

local ustring = mw.ustring

local script_data
script_data = {
    [' '] = {type = 'L', h = 25.0, path = 'm 0 25 '},
    [','] = {type = 'L', h = 10.0, path = 'm -10 0 v 10 m 20 -10 v 10 m -10 0 '},
    ['-'] = {type = 'D', side = 'E', path = 'c 0 3 3 6 6 6,   3 0 6 -3 6 -6,   0 -3 -3 -6 -6 -6,   -3 0 -6 3 -6 6'},
    ['.'] = {type = 'L', h = 20.0, path = 'm -10 0 v 10 m 20 -10 v 10 m -10 0 v 10 '},
    [':'] = {type = 'L', h = 10.0, path = 'm -10 0 l 10 10 l 10 -10 l -20 0 m 10 10 '},
    ['A'] = {type = 'D', side = 'R', path = 'm 0 -6 v 12 m 0 -6'},
    ['E'] = {type = 'D', side = 'L', path = 'h -12 m 12 0'},
    ['I'] = {type = 'D', side = 'L', path = 'm 0 -6 l -6 6 l 6 6 m 0 -6'},
    ['O'] = {type = 'D', side = 'R', path = 'h 12 m -12 0'},
    ['U'] = {type = 'D', side = 'R', path = 'm 0 6 l 6 -6 l -6 -6 m 0 6'},
    ['['] = {type = 'L', h = 10.0, path = 'm -30 20 v -20 h 60 v 20 m -30 -10 '},
    [']'] = {type = 'L', h = 10.0, path = 'm -30 -10 v 20 h 60 v -20 m -30 20 '},
    ['a'] = {type = 'D', side = 'L', path = 'm 0 -6 v 12 m 0 -6'},
    ['c'] = {type = 'S', loff = {-30.0,-25.0}, roff = {15.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'c 0 7.5 -12.5 20 -25 20 m 30 -12 c 0 7.5 -12.5 20 -30 20,   12.5 0 25 12.5 25 25 '},
    ['e'] = {type = 'D', side = 'L', path = 'm 0 -6 l -12 12 m 0 -12 l 12 12m 0 -6'},
    ['f'] = {type = 'S', loff = {-10.0,-25.0}, roff = {10.0,-75.0}, eoff = {12.0,-3.0}, h = 100.0 ,path = 'v 25 c 0 6 -6 12 -12 12,   -6 0 -12 -6 -12 -12,   0 -6 6 -12 12 -12,   6 0 12 6 12 12 v 25c 0 12.5 12.5 25 25 25,   -12.5 0 -25 12.5 -25 25'},
    ['h'] = {type = 'S', loff = {-30.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm -25 10 l 0 15 l 50 0 l 0 15 m -25 -40 l 0 50 '},
    ['i'] = {type = 'D', side = 'L', path = 'm -6 -6 l 6 6 l -6 6 m 6 -6'},
    ['j'] = {type = 'S', loff = {-10.0,-75.0}, roff = {30.0,-75.0}, eoff = {12.0,-3.0}, h = 100.0 ,path = 'v 25 c 0 6 6 12 12 12,   6 0 12 -6 12 -12,   0 -6 -6 -12 -12 -12,   -6 0 -12 6 -12 12 v 25c 0 12.5 12.5 25 25 25,   -12.5 0 -25 12.5 -25 25'},
    ['k'] = {type = 'S', loff = {-30.0,-25.0}, roff = {15.0,-25.0}, eoff = {12.0,-2.0}, h = 50.0 ,path = 'c 0 7.5 -12.5 20 -25 20 m 30 -15 c 0 7.5 -12.5 20 -30 20,   12.5 0 30 7.5 30 20 m -30 -15 c 12.5 0 25 7.5 25 20 '},
    ['l'] = {type = 'S', loff = {-30.0,-25.0}, roff = {0.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm -12.5 0 l 0 20 m 12.5 -20 c 0 12.5 -12.5 25 -25 25,   12.5 0 25 12.5 25 25'},
    ['n'] = {type = 'S', loff = {-30.0,-25.0}, roff = {0.0,-25.0}, eoff = {12.0,-3.0}, h = 60.0 ,path = 'm -12.5 5 h 25 m -25 5 h 25 m -12.5 -10 v 10 c 0 12.5 -12.5 25 -25 25,   12.5 0 25 12.5 25 25 '},
    ['o'] = {type = 'D', side = 'R', path = 'm 0 -6 l 12 12 m 0 -12 l -12 12m 0 -6'},
    ['p'] = {type = 'S', loff = {-30.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'l 0 25 c 0 6 6 12 12 12,   6 0 12 -6 12 -12,   0 -6 -6 -12 -12 -12,   -6 0 -12 6 -12 12,   0 6 -6 12 -12 12,   -6 0 -12 -6 -12 -12,   0 -6 6 -12 12 -12,   6 0 12 6 12 12 l 0 25 '},
    ['q'] = {type = 'S', loff = {-10.0,-25.0}, roff = {10.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm -5 0 h 10 m -5 0 v 50 m -5 0 h 10 m -5 0 '},
    ['qap-'] = {type = 'L', h = 76.0, path = 'm -25 10 h 50 m -25 -10 v 35 c 0 6 6 12 12 12,   6 0 12 -6 12 -12,   0 -6 -6 -12 -12 -12,   -6 0 -12 6 -12 12,  0 6 -6 12 -12 12,   -6 0 -12 -6 -12 -12,   0 -6 6 -12 12 -12,   6 0 12 6 12 12 v 35 c 0 3 3 6 6 6,   3 0 6 -3 6 -6,   0 -3 -3 -6 -6 -6,   -3 0 -6 3 -6 6 '},
    ['r'] = {type = 'S', loff = {-30.0,-37.5}, roff = {30.0,-37.5}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'v 25 c 0 6.25 6.25 12.5 12.5 12.5,   6.25 0 12.5 -6.25 12.5 -12.5,   0 -6.25 -6.25 -12.5 -12.5 -12.5 h -37.5 c 12.5 0 25 20 25 37.5 '},
    ['s'] = {type = 'S', loff = {-30.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'c 0 12.5 -12.5 25 -25 25 h 50 c -12.5 0 -25 12.5 -25 25 '},
    ['t'] = {type = 'S', loff = {-30.0,-25.0}, roff = {0.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'c 0 12.5 -12.5 25 -25 25,   12.5 0 25 12.5 25 25 '},
    ['u'] = {type = 'D', side = 'R', path = 'm 6 -6 l -6 6 l 6 6 m -6 -6'},
    ['w'] = {type = 'S', loff = {-30.0,-25.0}, roff = {10.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'v 25 c 0 6 -6 12 -12 12,   -6 0 -12 -6 -12 -12,   0 -6 6 -12 12 -12,   6 0 12 6 12 12 v 25 '},
    ['x'] = {type = 'S', loff = {-30.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm 0 0 c 0 7.5 -12.5 22.5 -25 22.5 l 50 0 m -50 5 l 50 0 c -12.5 0 -25 7.5 -25 22.5 '},
    ['y'] = {type = 'S', loff = {-10.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'v 25 c 0 6 6 12 12 12,   6 0 12 -6 12 -12,   0 -6 -6 -12 -12 -12,   -6 0 -12 6 -12 12 v 25 '},
    ['Ā'] = {type = 'D', side = 'R', path = 'm 0 -6 v 12 m 12 -12 v 12 m -12 -6'},
    ['ā'] = {type = 'D', side = 'L', path = 'm 0 -6 v 12 m -12 -12 v 12 m 12 -6'},
    ['Ē'] = {type = 'D', side = 'L', path = 'm 0 -6h -12 m 0 12 h 12 m 0 -6'},
    ['ē'] = {type = 'D', side = 'L', path = 'm 0 -12 l -12 12 l 12 12 m -12 0 l 12 -12 l -12 -12 m 12 12'},
    ['ħ'] = {type = 'S', loff = {-30.0,-25.0}, roff = {30.0,-25.0}, eoff = {12.0,-3.0}, h = 50.0 ,path = 'm 0 0 c 0 7.5 -12.5 22.5 -25 22.5 l 50 0 m -12.5 -10 l -25 25 m -12.5 -10 l 50 0 c -12.5 0 -25 7.5 -25 22.5'},
    ['Ī'] = {type = 'D', side = 'L', path = 'm 0 -12 l -6 6 l 6 6 l -6 6 l 6 6 m 0 -12'},
    ['ī'] = {type = 'D', side = 'L', path = 'm -6 -12 l 6 6 l -6 6 l 6 6 l -6 6 m 6 -12'},
    ['ń'] = {type = 'S', loff = {-30.0,-30.0}, roff = {15.0,-30.0}, eoff = {12.0,-3.0}, h = 60.0 ,path = 'm -12.5 5 h 25 m -25 5 h 25 m -12.5 -10 v 10 c 0 7.5 -12.5 20 -25 20 m 30 -12 c 0 7.5 -12.5 20 -30 20,   12.5 0 25 12.5 25 25 '},
    ['ŋ'] = {type = 'S', loff = {-30.0,-25.0}, roff = {15.0,-25.0}, eoff = {12.0,-2.0}, h = 60.0 ,path = 'm -12.5 5 h 25 m -25 5 h 25 m -12.5 -10 v 10 c 0 7.5 -12.5 20 -25 20 m 30 -15 c 0 7.5 -12.5 20 -30 20,   12.5 0 30 7.5 30 20 m -30 -15 c 12.5 0 25 7.5 25 20 '},
    ['Ō'] = {type = 'D', side = 'R', path = 'm 0 -6h 12 m 0 12 h -12 m 0 -6'},
    ['ō'] = {type = 'D', side = 'R', path = 'm 0 -6 l 12 12 l -12 12 m 12 0 l -12 -12 l 12 -12 m -12 6'},
    ['Ū'] = {type = 'D', side = 'R', path = 'm 0 -12 l 6 -6 l -6 6 l 6 -6 l -6 6 m 0 12'},
    ['ū'] = {type = 'D', side = 'R', path = 'm 6 -12 l -6 6 l 6 6 l -6 6 l 6 6 m -6 -12'},
}

local processWord
processWord = function(iw)
    local lastS, lastS_name = {}, ""
    local w = ustring.toNFC(iw)
    if script_data[w] then
        return script_data[w].h, script_data[w].path
    end
    local h = 0
    local p = ""
    for c in ustring.gmatch(w, ".") do
        local g = script_data[c]
        if not g then return nil, "Unknown character ` " .. c .. "'" end
        if g.type == "D" and lastS.eoff == nil then
    		h = h + script_data["q"].h
            p = p .. script_data["q"].path
            lastS.loff = script_data["q"].loff
            lastS.roff = script_data["q"].roff
            lastS.eoff = script_data["q"].eoff
            lastS_name = "q"
    	end
        if g.type == "S" then
            h = h + g.h
            p = p .. g.path
            lastS.loff = g.loff
            lastS.roff = g.roff
            lastS.eoff = g.eoff
            lastS_name = c
        elseif g.type == "L" then
            h = h + g.h
            p = p .. g.path
        elseif g.type == "D" and g.side == "E" then
            p = p ..
                "m " .. tostring(lastS.eoff[1]) .. " " .. tostring(lastS.eoff[2]) .." " ..
                g.path ..
                "m " .. tostring(-lastS.eoff[1]) .. " " .. tostring(-lastS.eoff[2]) .. " "
        elseif g.type == "D" and g.side == "R" then
            p = p ..
                "m " .. tostring(lastS.roff[1]) .. " " .. tostring(lastS.roff[2]) .." " ..
                g.path ..
                "m " .. tostring(-lastS.roff[1]) .. " " .. tostring(-lastS.roff[2]) .. " "
        elseif g.type == "D" and g.side == "L" then
            p = p ..
                "m " .. tostring(lastS.loff[1]) .. " " .. tostring(lastS.loff[2]) .." " ..
                g.path ..
                "m " .. tostring(-lastS.loff[1]) .. " " .. tostring(-lastS.loff[2]) .. " "
        end
    end
    return h, p
end

local processLine
processLine = function(width, lno, l)
    local th = 0
    local c = '<path class="script-naqoo-path" style="fill: none; stroke-width: 2.5px;" d="m ' .. tostring(width - 50 - lno * 100) .. ' 0'
    for w in ustring.gmatch(l, "[^%s]+") do
        h, p = processWord(w)
        if not h then
            return nil, p
        end
        c = c .. p .. "m 0 25 "
        th = th + h + 25
    end
    c = c .. '" />'
    return th, c
end

local process
process = function(text, addclass)
    local lines = {}
    for l in ustring.gmatch(text, "[^\n]+") do
        lines[#lines + 1] = l
    end
    local w = #lines * 100
    local body = ""
    local maxL = 0
    for no, l in ipairs(lines) do
        local l, p = processLine(w, no - 1, l)
        if not l then
            return nil, p
        end
        body = body .. p .. "\n"
        maxL = (maxL < l) and l or maxL
    end
    local x = mw.getCurrentFrame():extensionTag('svg', body, {
    	class = "script-naqoo " .. addclass,
    	viewbox = "-10 -10 " .. tostring(10 + #lines * 100).. " " .. 10 + maxL,
    	version="1.1",
    	preserveAspectRatio="xMinYMin meet",
    	xmlns="http://www.w3.org/2000/svg"
    })
    if not x then
    	mw.addWarning(body)
    	return "something went wrong"
    else return x end
end

return {
	render = function( frame )
		local text = frame.args[1]
		text = ustring.lower(text)
		text = ustring.gsub(text , "pp", "p-")
		text = ustring.gsub(text , "tt", "t-")
		text = ustring.gsub(text , "cc", "c-")
		text = ustring.gsub(text , "kk", "k-")
		text = ustring.gsub(text , "qq", "q-")
		text = ustring.gsub(text , "à", "A")
		text = ustring.gsub(text , "è", "E")
		text = ustring.gsub(text , "ì", "I")
		text = ustring.gsub(text , "ò", "O")
		text = ustring.gsub(text , "ù", "U")
		text = ustring.gsub(text , "aa", "ā")
		text = ustring.gsub(text , "ee", "ē")
		text = ustring.gsub(text , "ii", "ī")
		text = ustring.gsub(text , "oo", "ō")
		text = ustring.gsub(text , "uu", "ū")
		text = ustring.gsub(text , "AA", "Ā")
		text = ustring.gsub(text , "EE", "Ē")
		text = ustring.gsub(text , "II", "Ī")
		text = ustring.gsub(text , "OO", "Ō")
		text = ustring.gsub(text , "UU", "Ū")
		if frame.args.float ~= "" then
			return [[<div style="float:right">]] .. tostring(process(text, frame.args.addclass)) .. [[</div>]]
		else
			return process(text, frame.args.addclass)
		end
	end
}