Module:Plain
From Evolutionary
More actions
Turns wikitext into plain text, removing link markup, bold and italic marks, and HTML tags. Used by the infoboxes to build automatic short descriptions, so a homeworld written as [[Halcyon#Nereid|Nereid]] becomes just "Nereid".
{{#invoke:Plain|text|some [[linked]] text}} gives "some linked text".
-- Turns wikitext into plain text: [[Page|label]] -> label, [[Page]] -> Page,
-- and removes bold/italic marks and HTML tags.
-- Used by the infoboxes to build automatic short descriptions.
-- Usage: {{#invoke:Plain|text|some [[linked]] text}}
local p = {}
function p.text( frame )
local s = frame.args[ 1 ] or ''
s = s:gsub( '%[%[[^%]|]*|([^%]]*)%]%]', '%1' )
s = s:gsub( '%[%[([^%]]*)%]%]', '%1' )
s = s:gsub( "'''?", '' )
s = s:gsub( '<[^>]->', '' )
return mw.text.trim( s )
end
return p