Module:Plain text

From Nookipedia, the Animal Crossing wiki
Revision as of 10:13, April 13, 2018 by wikipedia>Galobtter (create module)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Module documentation (view)


Usage

Developed for producing short descriptions from text that may have markup, or other stuff that needs removing from short descriptions.

Example

Code
'''[[foo|hah]]''' <span style="color:red">is</span> '''''[[gah]]'''''<nowiki>?</nowiki>
hah is gah?
Using module
{{#invoke:Plain text|main|1='''[[foo|hah]]''' <span style="color:red">is</span> '''''[[gah]]'''''<nowiki>?}}</nowiki>
Lua error at line 3: attempt to index local 'p' (a nil value).
Small Wikipedia Logo.svg This page uses content from Wikipedia (en). The original article was at Module:Plain text. The list of authors can be seen in the page history. As with Nookipedia, the text of Wikipedia is available under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
This page is fully-protected to prevent editing by non-administrator users

--converts text with wikilinks, e.g "[[foo|gah]] is [[bar]]" to "gah is bar"
local p
function p.main(frame)
	text = frame.args[1]
	text = mw.ustring.gsub('%[%[.*|', '') --strip out piped link text
	text = mw.ustring.gsub ('%[', '') --then strip out remaining [ and ]
	text = mw.ustring.gsub ('%]', '')
	return text
end
return p