Module:StripTags
From JoJo's Bizarre Encyclopedia - JoJo Wiki
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 = {
["""] = '"',
["&"] = "&",
["<"] = "<",
[">"] = ">",
["'"] = "'",
["'"] = "'",
["“"] = '“',
["”"] = '”',
["‘"] = '‘',
["’"] = '’',
}
return text:gsub("(&#?[%w]+;)", entities)
end
local function stripWikiMarkup(text)
-- Remove [[ ]] wiki links, keep the display text
text = mw.ustring.gsub(text, '%[%[([^|%]]+)|([^%]]+)%]%]', '%2')
text = mw.ustring.gsub(text, '%[%[([^|%]]+)%]%]', '%1')
-- Remove '' for italics and ''' for bold
text = mw.ustring.gsub(text, "'''", "")
text = mw.ustring.gsub(text, "''", "")
return text
end
function p.stripTags(frame)
local text = frame.args[1]
-- Remove HTML tags
text = mw.ustring.gsub(text, '<[^>]->', '')
-- Decode HTML entities
text = decodeHtmlEntities(text)
-- Strip wiki markup
text = stripWikiMarkup(text)
return text
end
return p
- Manga ▾
- Media ▾
- Characters ▾
- World ▾
- Archives ▾
- Misc ▾
- Wiki ▾
Retrieved from "http://jojowiki.com/index.php?title=Module:StripTags&oldid=979012"