Module:StripTags

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 03:37, 24 July 2024 by Paisley Park (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:StripTags/doc

local p = {}

local function decodeHtmlEntities(text)
    local entities = {
        ["""] = '"',
        ["&"] = "&",
        ["&lt;"] = "<",
        ["&gt;"] = ">",
        ["&#39;"] = "'",
        ["&apos;"] = "'"
    }
    return text:gsub("(&#?[%w]+;)", entities)
end

function p.stripTags(frame)
    local text = frame.args[1]
    -- Remove HTML tags
    text = mw.ustring.gsub(text, '<[^>]->', '')
    -- Decode HTML entities
    text = decodeHtmlEntities(text)
    return text
end

return p