Module:Sandbox/Luis150902/cleanup
< Module:Sandbox | Luis150902
Jump to navigation
Jump to search
![]() | This module is rated as pre-alpha. It is unfinished, and may or may not be in active development. It should not be used from article namespace pages. Modules remain pre-alpha until the original editor (or someone who takes one over if it is abandoned for some time) is satisfied with the basic structure. |
Usage
{{#invoke:Sandbox/Luis150902/cleanup|main|string}}
, where string is the string to be escaped. This eases the editing of wiki markup containing bidirectional text. Inserting =
(escaped form of =
) is displayed as ;61#&
between right-to-left characters.
- Test 1:
{{subst:#invoke:Sandbox/Luis150902/cleanup|main|A}}
returned A - Test 2:
{{subst:#invoke:Sandbox/Luis150902/cleanup|main|B}}
returned B - Test 3:
{{subst:#invoke:Sandbox/Luis150902/cleanup|main|א}}
returned א - Test 4:
{{subst:#invoke:Sandbox/Luis150902/cleanup|main|אתבש}}
returned אתבש (Atbash)
-- This module escapes Unicode characters >= U+0100.
local p = {}
function p._main(s)
local r = ""
local i = 1
local l = mw.ustring.len(s)
local e = ""
while i <= l do
if mw.ustring.codepoint(s, i) >= 256 then
e = mw.ustring.format("&#x%04x;", mw.ustring.codepoint(s, i))
else
e = mw.ustring.sub(s, i, i + 1)
end
r = r .. e
i = i + 1
end
return r
end
function p.main(frame)
return p._main(frame.args[1])
end
return p