Candidate for deletion
This page has been nominated for removal from the wiki.
local p = {}
function p.getTemplateArgsFromRaw(rawContent, options)
options = options or {}
local templates = p._parseFormat(rawContent, options.only)
if options.only then
templates = templates[options.only] or {}
end
return templates
end
function p.getTemplateArgs(page, options)
options = options or {}
local rawContent = ''
if options.custom then
rawContent = page
else
local title = mw.title.makeTitle(options.namespace or '', page)
if title == nil then
return {}
end
rawContent = title:getContent()
if rawContent == nil or rawContent == '' then
return {}
end
end
rawContent = (rawContent:gsub('<!%-%-.-%-%->', '')) .. '\n'
-- remove strip markers (e.g., <ref></ref> )
if options.unstrip then
rawContent = mw.text.unstrip(rawContent)
end
local templates = p._parseFormat(rawContent, options.only)
-- return only specific template to simplify usage
if options.only then
templates = templates[options.only] or {}
end
-- return raw page content too for extra parsing
if options.pageContent then
templates.PAGECONTENT = rawContent
end
-- return parsed content
return templates
end
return p