mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-12-18 19:02:27 +00:00
Improve mw.text.nowiki, part 2
The following are now correctly escaped: * Blank lines (including those with only tabs) * ---- at the start of a line Bug: 53658 Change-Id: Ib000ff4f21f76c310741de89de0e0b66f6450344
This commit is contained in:
parent
32bb3e21f2
commit
a0a1b05b74
|
@ -106,6 +106,9 @@ local nowikiRepl2 = {
|
||||||
["\n:"] = "\n:", ["\r:"] = "\r:",
|
["\n:"] = "\n:", ["\r:"] = "\r:",
|
||||||
["\n;"] = "\n;", ["\r;"] = "\r;",
|
["\n;"] = "\n;", ["\r;"] = "\r;",
|
||||||
["\n "] = "\n ", ["\r "] = "\r ",
|
["\n "] = "\n ", ["\r "] = "\r ",
|
||||||
|
["\n\n"] = "\n ", ["\r\n"] = " \n",
|
||||||
|
["\n\r"] = "\n ", ["\r\r"] = "\r ",
|
||||||
|
["\n\t"] = "\n	", ["\r\t"] = "\r	",
|
||||||
}
|
}
|
||||||
|
|
||||||
local nowikiReplMagic = {}
|
local nowikiReplMagic = {}
|
||||||
|
@ -124,7 +127,10 @@ end
|
||||||
function mwtext.nowiki( s )
|
function mwtext.nowiki( s )
|
||||||
-- string.gsub is safe here, because we're only caring about ASCII chars
|
-- string.gsub is safe here, because we're only caring about ASCII chars
|
||||||
s = string.gsub( s, '["&\'<=>%[%]{|}]', nowikiRepl1 )
|
s = string.gsub( s, '["&\'<=>%[%]{|}]', nowikiRepl1 )
|
||||||
s = string.sub( string.gsub( '\n' .. s, '[\r\n][#*:; ]', nowikiRepl2 ), 2 )
|
s = '\n' .. s
|
||||||
|
s = string.gsub( s, '[\r\n][#*:; \n\r\t]', nowikiRepl2 )
|
||||||
|
s = string.gsub( s, '([\r\n])%-%-%-%-', '%1----' )
|
||||||
|
s = string.sub( s, 2 )
|
||||||
s = string.gsub( s, '__', '__' )
|
s = string.gsub( s, '__', '__' )
|
||||||
s = string.gsub( s, '://', '://' )
|
s = string.gsub( s, '://', '://' )
|
||||||
s = string.gsub( s, 'ISBN%s', nowikiReplMagic )
|
s = string.gsub( s, 'ISBN%s', nowikiReplMagic )
|
||||||
|
|
Loading…
Reference in a new issue