Module:Lore

-- local p = {}

local data = require("Module:Lore/Data") local all_lore = data.lore

function p.Lore(frame) local name = frame.args[1] or mw.title.getCurrentTitle.text local desc = all_lore[name].Desc desc = desc:gsub("^\r?\n", ""):gsub("^%s*(.-)%s*$", "%1"):gsub("", ""):gsub("<\/style>", " "):gsub("(==+)", " %1 "):gsub("(%-%-+)", " %1 "):gsub("\u(%x%x%x%x)", function(s) return mw.ustring.char(tonumber(s, 16)) end) local pre = mw.html.create("pre"):addClass("lore"):wikitext(desc) return pre:done end

function p.AllLore(frame) local all = {} for name, lore in pairs(all_lore) do   lore.Name = name table.insert(all, lore) end table.sort(all, function(a, b) return a.Name < b.Name end) local list = "" local pre for i, lore in ipairs(all) do   desc = lore.Desc:gsub("^\r?\n", ""):gsub("^%s*(.-)%s*$", "%1"):gsub("", ""):gsub("<\/style>", " "):gsub("(==+)", " %1 "):gsub("(%-%-+)", " %1 "):gsub("\u(%x%x%x%x)", function(s) return mw.ustring.char(tonumber(s, 16)) end) pre = mw.html.create("pre"):addClass("lore"):wikitext(desc) list = list .. "" .. lore.Name .. " \r\n" .. tostring(pre) .. " \r\n" end return list end

return p --