Module:Parse
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Parse/doc
local p = {}
local util = require("Module:Util")
local coromon = require("Module:Coromon")
local tags = mw.loadData("Module:Parse/Tags")
function p.parseGameText (f)
return f:preprocess(p.toDisplayText(f.args[1]))
end
function p.toDisplayText (str)
for k, t in pairs(tags) do
str = string.gsub(str, '%[' .. k .. '%]', t)
end
local match = str:match("%<color TEXT_HP%>(.-)%</color%>")
local matches = 0
while match ~= nil and matches < 10 do
str = string.gsub(str, '%<color TEXT_HP%>' .. match .. '%</color%>', '{{Color|HP|' .. match .. (util.endsWith(match,'%') and '%' or '') .. "}}" )
match = str:match("<color TEXT_HP>(.-)</color>")
matches = matches + 1
end
match = str:match("%[(.-)%]")
matches = 0
while match ~= nil and matches < 10 do
if util.startsWith(match, "monster") then
str = string.gsub(str, '%[' .. match .. '%]', coromon.getCoromon(string.gsub(match, "monster ", "")).name)
elseif util.startsWith(match, "map") then
str = string.gsub(str, '%[' .. match .. '%]', string.gsub(match, 'map ', ''))
end
match = str:match("%[(.-)%]")
matches = matches + 1
end
return str
end
return p