https://wiki.conworkshop.com/w/Module:Plain_text/history?feed=atom&Module:Plain text - Revision history2024-03-28T16:03:15ZRevision history for this page on the wikiMediaWiki 1.37.1https://wiki.conworkshop.com/index.php?title=Module:Plain_text&diff=44323&oldid=prevAlynnidalar: 1 revision imported2021-01-22T01:43:15Z<p>1 revision imported</p>
<p><b>New page</b></p><div>--converts text with wikilinks to plain text, e.g "[[foo|gah]] is [[bar]]" to "gah is bar"<br />
--removes anything enclosed in tags that isn't nested, mediawiki strip markers (references etc), files, italic and bold markup<br />
local p = {}<br />
<br />
function p.main(frame)<br />
local text = frame.args[1]<br />
return p._main(text)<br />
end<br />
<br />
function p._main(text)<br />
if not text then return end<br />
text = mw.text.killMarkers(text)<br />
:gsub('&nbsp;', ' ') --replace nbsp spaces with regular spaces<br />
:gsub('<br ?/?>', ', ') --replace br with commas<br />
:gsub('<span.->(.-)</span>', '%1') --remove spans while keeping text inside<br />
:gsub('<i.->(.-)</i>', '%1') --remove italics while keeping text inside<br />
:gsub('<.->.-<.->', '') --strip out remaining tags and the text inside<br />
:gsub('<.->', '') --remove any other tag markup<br />
:gsub('%[%[%s*[Ff]ile%s*:.-%]%]', '') --strip out files<br />
:gsub('%[%[%s*[Ii]mage%s*:.-%]%]', '') --strip out use of image:<br />
:gsub('%[%[%s*[Cc]ategory%s*:.-%]%]', '') --strip out categories<br />
:gsub('%[%[[^%]]-|', '') --strip out piped link text<br />
:gsub('[%[%]]', '') --then strip out remaining [ and ]<br />
:gsub("'''''", "") --strip out bold italic markup<br />
:gsub("'''?", "") --not stripping out '''' gives correct output for bolded text in quotes<br />
:gsub('----', '') --remove ---- lines<br />
:gsub("^%s+", "") --strip leading<br />
:gsub("%s+$", "") --and trailing spaces<br />
:gsub("%s+", " ") --strip redundant spaces<br />
return text<br />
end<br />
<br />
return p</div>Alynnidalar