Module:Char

-- This function can substitute some critical leading characters -- by their decimal numeric character references -- to avoid their interpretion as wiki syntax

local ncr = {}

-- global=args[1] / local=frame function ncr.substitute ( frame ) local args = frame.args local char = '' if args then char = args[1] else char = frame end if mw.ustring.sub ( char, 1, 1 ) == '#' then return '&#35;' .. mw.ustring.sub( char, 2, #char ); elseif mw.ustring.sub ( char, 1, 1 ) == '*' then return '&#42;' .. mw.ustring.sub( char, 2, #char ); elseif mw.ustring.sub ( char, 1, 1 ) == ':' then return '&#58;' .. mw.ustring.sub( char, 2, #char ); elseif mw.ustring.sub ( char, 1, 1 ) == ';' then return '&#59;' .. mw.ustring.sub( char, 2, #char ); else return char; end end

-- alias function name (abbreviation) function  ncr.subst      ( frame ) local args = frame.args local str  = args[1] return ncr.substitute ( str ) end

return ncr;