---- This module is supposed to apply Green-Armytage's standard for a "color alphabet" to letters in a string of input text. ---- for blank, ---- for colored letters local getArgs = require('Module:Arguments').getArgslocal p =
function p._main(text, lookupfile, nowiki, blank) local debuglog="" local lookup = lookup.file = lookupfile lookup.data = mw.loadData(lookup.file) debuglog = debuglog..tostring(lookup.data)..table.concat(lookup.data)..lookup.data[7] -- debug if not(lookup.data) then return "error: failed to open lookup file" .. tostring(lookup.file) end local x=0 repeat x=x+1 i=lookup.data[x*3-2] j=lookup.data[x*3-1] k=lookup.data[x*3] -- debuglog=debuglog..tostring(i)..tostring(j)..tostring(k) if not (i and j and k) then break end lookup[i]=j .. (blank or i) .. k -- create the lookup table of what letters are supposed to be transliterated to. If blank
' end if wikiend[position] then output=output.."" end output=output..(lookup[letter] or letter) -- unicode letters will never all be looked up, handle punctuation the same until false output='
'..output..'
' if nowiki then output=''..output..''; output=output..debuglog end return outputend
-- common code with all relevant argsfunction p.main(args, blank) local text = args[1] or "" local nowiki = args.nowiki or nil local lookupfile = args.lookup or "Module:Sandbox/Wnt/ColorAlphabet/lookup" return p._main(text, lookupfile, nowiki, blank)end -- entry for colorizing lettersfunction p.letter(frame) local args = getArgs(frame) return frame:preprocess(p.main(args, nil))end
-- entry for replacing letters with colored nonbreaking spacesfunction p.blank(frame) local args = getArgs(frame) return frame:preprocess(p.main(args, " "))end
return p