Difference between revisions of "Module:Plain text"

From Nookipedia, the Animal Crossing wiki
(create module)
 
(fix)
Line 1: Line 1:
 
--converts text with wikilinks, e.g "[[foo|gah]] is [[bar]]" to "gah is bar"
 
--converts text with wikilinks, e.g "[[foo|gah]] is [[bar]]" to "gah is bar"
local p
+
local p = {}
 
function p.main(frame)
 
function p.main(frame)
 
text = frame.args[1]
 
text = frame.args[1]

Revision as of 10:15, April 13, 2018

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 5: too few arguments to mw.ustring.gsub.
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