Module:CodeWrapper

From PKC
Revision as of 10:56, 16 May 2022 by Benkoo (talk | contribs) (Created page with " function p.returnHTMLText(a) pageContent = tostring(mw.getCurrentFrame().args[1]) local div = mw.html.create( 'syntaxhighlight' ) div :attr( 'lang', 'HTML' ) :wi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:CodeWrapper/doc

function p.returnHTMLText(a)
	pageContent = tostring(mw.getCurrentFrame().args[1])
	local div = mw.html.create( 'syntaxhighlight' )
	div
     :attr( 'lang', 'HTML' )
     :wikitext( pageContent )
	return a:preprocess(tostring( div ))
end

function p.returnNowkiText(a)
	pageContent = tostring(mw.getCurrentFrame().args[1])
	local div = mw.html.create( 'nowiki' )
	div
     :wikitext( pageContent )
	return a:preprocess(tostring( div ))
end

function p.luaSourceCodeText(a)
	pageContent = tostring(mw.getCurrentFrame().args[1])
	local div = mw.html.create( 'syntaxhighlight' )
	div
     :attr( 'lang', 'lua' )
     :wikitext( pageContent )
	return a:preprocess(tostring( div ))
end

function p.originalText(a)
	return mw.getCurrentFrame().args[1]
end

function p.reverseResult(a)
	str = mw.getCurrentFrame().args[1]
	text = string.reverse(str)
	return a:preprocess(text)
end

function p.reverse(a)
	str = mw.getCurrentFrame().args[1]
	text = string.reverse(str)
	return text
end

function p.greek_letter()
	cf = mw.getCurrentFrame()
	-- aString = "<math>\\" .. mw.allToString(cf.args[1]) .. "</math>"
	str = mw.getCurrentFrame().args[1]
	aString = cf:preprocess("<math>\\"..str.."</math>")
	return aString
end

function p.rawstring()
	cf = mw.getCurrentFrame()
	return mw.allToString(cf.args[1])
end