Documentation for this module may be created at Module:MarkdownToWikitext/doc
local p = {}
local html = mw.html
-- Helper to remove inline HTML tags (like iframes)
local function stripHTML(input)
if not input then return '' end
input = input:gsub('<iframe.-</iframe>', '')
input = input:gsub('<[^>]->', '') -- Strip other tags like <b>, <img>, etc.
return input
end
-- Helper to trim whitespace
local function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
-- Converts the raw JSON markdown-ish text into wikitext
local function convertToWikitext(data)
local output = {}
-- Title
if data.title then
table.insert(output, "== " .. data.title .. " ==")
end
-- Changes section
if data.changes then
local clean = stripHTML(data.changes)
table.insert(output, "=== Changes ===")
for line in clean:gmatch("[^\r\n]+") do
table.insert(output, "* " .. trim(line))
end
end
-- Bug Fixes section
if data.bug_fixes then
local clean = stripHTML(data.bug_fixes)
table.insert(output, "=== Bug Fixes ===")
for line in clean:gmatch("[^\r\n]+") do
table.insert(output, "* " .. trim(line))
end
end
return table.concat(output, "\n")
end
-- Main entry point
function p.main(frame)
local json = mw.ext.externalData.getJSON({
url = 'https://api.vaulthunters.gg/patch-notes?limit=1'
})
if not json or not json[1] then
return "Could not fetch patch notes."
end
local data = json[1]
return convertToWikitext(data)
end
return p