diff --git a/modules/parser/mediawiki.WikitextSerializer.js b/modules/parser/mediawiki.WikitextSerializer.js index f3fd08664f..d54c399b19 100644 --- a/modules/parser/mediawiki.WikitextSerializer.js +++ b/modules/parser/mediawiki.WikitextSerializer.js @@ -284,7 +284,7 @@ WSP.tagToWikitext = { // XXX: support indent variant instead by registering a newline handler? pre: { start: function( state, token ) { - state.textHandler = function( t ) { return t.replace( /\n/g, '\n ' ); }; + state.textHandler = function( t ) { return t.replace( /^/g, ' ' ); }; return ''; }, end: function( state, token) { state.textHandler = null; return ''; } diff --git a/tests/parser/parserTests-whitelist.js b/tests/parser/parserTests-whitelist.js index af35f2add0..851ec051b1 100644 --- a/tests/parser/parserTests-whitelist.js +++ b/tests/parser/parserTests-whitelist.js @@ -5,12 +5,10 @@ testWhiteList = {}; // Italic/link nesting is changed in this test, but the rendered result is the -// same. +// same. Currently the result is actually an improvement over the MediaWiki +// output. testWhiteList["Bug 2702: Mismatched , and tags are invalid"] = "

texttextSomething in italicSomething mixed, even boldNow both

"; -// Extra empty bold element. Needed for round-tripping? -testWhiteList["Unclosed and unmatched quotes"] = "

Bold italic text with bold deactivated in between.

Bold italic text with italic deactivated in between.

Bold text..

..spanning two paragraphs (should not work).

Bold tag left open

Italic tag left open

Normal text.

\nThis year's election should beat last year's.

Toms car is bigger than Susans.

"; - // The expected result for this test is really broken html. testWhiteList["Link containing double-single-quotes '' in text embedded in italics (bug 4598 sanity check)"] = "

Some pretty italics and stuff!

"; @@ -23,22 +21,25 @@ testWhiteList["5 quotes, code coverage +1 line"] = "

"; // supplies the old result without preformatting. testWhiteList["Bug 6200: Preformatted in
"] = "
\nBlah
"; - // empty table tags / with only a caption are legal in HTML5. testWhiteList["A table with no data."] = "
"; testWhiteList["A table with nothing but a caption"] = "
caption
"; testWhiteList["Fuzz testing: Parser22"] = "

http://===r:::https://b

"; +/** + * Small whitespace differences that we now start to care about for + * round-tripping + */ + // Very minor whitespace difference at end of cell (MediaWiki inserts a // newline before the close tag even if there was no trailing space in the cell) -testWhiteList["Table rowspan"] = "
Cell 1, row 1 Cell 2, row 1 (and 2) Cell 3, row 1
Cell 1, row 2 Cell 3, row 2
"; +//testWhiteList["Table rowspan"] = "
Cell 1, row 1 Cell 2, row 1 (and 2) Cell 3, row 1
Cell 1, row 2 Cell 3, row 2
"; // Inter-element whitespace only -testWhiteList["Indented table markup mixed with indented pre content (proposed in bug 6200)"] = " \n\n
\nText that should be rendered preformatted\n
"; +//testWhiteList["Indented table markup mixed with indented pre content (proposed in bug 6200)"] = " \n\n
\nText that should be rendered preformatted\n
"; - -/* Missing token transform functionality */ +/* Misc sanitizer / HTML5 differences */ // Single quotes are legal in HTML5 URIs. See // http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#url-manipulation-and-creation