Arlolra has uploaded a new change for review. https://gerrit.wikimedia.org/r/221985
Change subject: Scrub empty styles tags ...................................................................... Scrub empty styles tags * https://www.mediawiki.org/wiki/Talk:Parsoid/Normalizations#Empty_style_tags Change-Id: Ibdde0081c49df9d945ad0851a7aaf9d658c25075 --- M lib/wts.normalizeDOM.js M tests/parserTests.txt 2 files changed, 39 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid refs/changes/85/221985/1 diff --git a/lib/wts.normalizeDOM.js b/lib/wts.normalizeDOM.js index 50d2ab9..4b510f3 100644 --- a/lib/wts.normalizeDOM.js +++ b/lib/wts.normalizeDOM.js @@ -129,9 +129,10 @@ return node; } - // Empty headings are stripped - var emptyHeading = isHeading && DU.nodeEssentiallyEmpty(node); - if (emptyHeading) { + // Empty headings and style tags are stripped + var emptyTag = (isHeading || Consts.WTQuoteTags.has(node.nodeName)) && + DU.nodeEssentiallyEmpty(node); + if (emptyTag) { var next = node.nextSibling; node.parentNode.removeChild(node); node = next; diff --git a/tests/parserTests.txt b/tests/parserTests.txt index 7b63d94..4ec7fce 100644 --- a/tests/parserTests.txt +++ b/tests/parserTests.txt @@ -24646,6 +24646,41 @@ ==<nowiki/>== !! end +!! test +1. WT Quote Tags: suppress newly created empty style tags +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html +<i></i><b></b> +!! wikitext +!! end + +!! test +2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false +!! options +parsoid=html2wt +!! html +<i></i><b></b> +!! wikitext +''<nowiki/>'''''<nowiki/>''' +!! end + +!! test +3. WT Quote Tags: don't suppress existing empty style tags even if scrubWikitext is true +!! options +parsoid={ + "modes": ["html2wt"], + "scrubWikitext": true +} +!! html +<i data-parsoid='{}'></i><b data-parsoid='{}'></b> +!! wikitext +''<nowiki/>'''''<nowiki/>''' +!! end + # --------------------------------------------------- # End of tests spec'ing wikitext serialization norms | # --------------------------------------------------- -- To view, visit https://gerrit.wikimedia.org/r/221985 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibdde0081c49df9d945ad0851a7aaf9d658c25075 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Arlolra <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
