local p = local getArgs = require('Module:Arguments').getArgs
local UTF8_char = "[%z\1-\127\194-\244][\128-\191]*"
local framelocal sum = 0local wordSum = 0
local rightToLeft =
local greekTable =
local arabicTable =
local hebrewTable =
local langTable =
local function processLetter(lang, chr) local function formatLetter(c) return frame:expandTemplate end local function formatTransliteration(c) if langTable[lang].transliterate then return frame:expandTemplate end end
local function formatNumber(c) indexC = string.ulower(c) if langTable[lang].lookupTable[indexC] then local value = langTable[lang].lookupTable[indexC].value wordSum = wordSum + value return value end return ' ' end
local div = mw.html.create("div") :addClass("letter") local p1 = div:tag("p"):wikitext(formatLetter(chr)) local p2 = div:tag("p"):wikitext(formatTransliteration(chr)) local p3 = div:tag("p"):wikitext(formatNumber(chr)) return divend
local function processWord(lang, word) local html = "" wordSum = 0 for i, c in ipairs(word) do if (i ~= 1) then html = html .. '
+
' end if langTable[lang] then html = html .. tostring(processLetter(lang, c)) else html = html .. c end end sum = sum + wordSum html = '
' .. '
(
' .. html .. '
)
' .. '
' .. '
' .. wordSum .. '
' return mw.html.create("div") :addClass("word") :wikitext(html)end
function parseStrToTable(str) local wordsTable = for word in str:gmatch("[^%s]+") do local wordTable = for letter in word:gmatch(UTF8_char) do table.insert(wordTable, letter) end table.insert(wordsTable, wordTable) end return wordsTableend
function ReverseTable(myTable) if myTable and #myTable > 1 then local temp = nil for n = 1,math.floor(#myTable/2) do temp = myTable[n] myTable[n] = myTable[#myTable-(n-1)] myTable[#myTable-(n-1)] = temp end endend
function p.isopsephy(frameArg) frame = frameArg local args = getArgs(frame,) str = args[1]
local html = "" sum = 0 if args.lang and str then local words = parseStrToTable(str) if rightToLeft[args.lang] then ReverseTable(words) for i, word in ipairs(words) do ReverseTable(word) end end for i, word in ipairs(words) do if (i ~= 1) then html = html .. '
+
' end html = html .. tostring(processWord(args.lang, word)) end html = html .. '
=
' .. '
' .. sum .. '
' end return tostring(mw.html.create("div") :addClass("isopsephy") :wikitext(html) )end
return p