Modulo:Sandbox/Tino
Da Wikipedia, l'enciclopedia encyclopedia
local p = {}
function p.parse(frame) local str = frame.args.str local str2 = frame.args.str2
if (str2 ~= nil and str2 ~= ) -- two parameters, classical behaviour then return frame:expandTemplate{ title = 'Non firmato', args = { str2, str } } end
-- one parameter, parse the input local i, j local len = mw.ustring.len(str) -- string length local pattern = "%s*%d+:%d+, %d+ %a+ %d+\226\128\142*%s*" -- pattern for date in wiki format -- \226\128\142 is unicode representation for U+200E, an invisible char present in chronology after the date i, j = mw.ustring.find(str, pattern) local date = mw.ustring.sub(str, i, j) -- the date local name = mw.ustring.sub(str, j + 1, len) -- the rest of the string
return frame:expandTemplate{ title = 'Non firmato', args = { name, date } } end
return p