Subramanya Sastry has uploaded a new change for review.
https://gerrit.wikimedia.org/r/80335
Change subject: (Bug 42803) Apply I/B minimization to incoming HTML
......................................................................
(Bug 42803) Apply I/B minimization to incoming HTML
* Minimizes I/B tags on incoming HTML.
* Added a bunch of parsoid-only html2wt tests with expectations
about this code (all tests pass).
Change-Id: I9dc00f6d05932bdfd8e7586323abe44addfc26ff
---
M js/lib/mediawiki.WikitextSerializer.js
M js/tests/parserTests.txt
2 files changed, 72 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/35/80335/1
diff --git a/js/lib/mediawiki.WikitextSerializer.js
b/js/lib/mediawiki.WikitextSerializer.js
index a5c9187..4789779 100644
--- a/js/lib/mediawiki.WikitextSerializer.js
+++ b/js/lib/mediawiki.WikitextSerializer.js
@@ -33,6 +33,7 @@
DU = require('./mediawiki.DOMUtils.js').DOMUtils,
pd = require('./mediawiki.parser.defines.js'),
Title = require('./mediawiki.Title.js').Title,
+ minimizeWTQuoteTags =
require('./dom.minimizeWTQuoteTags.js').minimizeWTQuoteTags,
SanitizerConstants =
require('./ext.core.Sanitizer.js').SanitizerConstants;
function isValidSep(sep) {
@@ -4084,6 +4085,9 @@
// collect tpl attr tags
this.extractTemplatedAttributes(body, state);
+ // Minimize I/B tags
+ minimizeWTQuoteTags(body);
+
// Don't serialize the DOM if debugging is disabled
if (this.debugging) {
this.trace(" DOM ==> \n", body.outerHTML);
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index 77523bf..33636df 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -17345,6 +17345,74 @@
>foo</p>
!! end
+#-----------------------------
+# I/B quote minimization tests
+#-----------------------------
+
+!! test
+1. I/B qoute minimization: wikitext-only tags should be combined
+!! options
+parsoid=html2wt
+!! input
+''AB''
+
+'''AB'''
+
+''A'''B'''''
+
+'''A''B'''''
+
+'''A''BC''D'''
+!! result
+<p><i>A</i><i>B</i></p>
+<p><b>A</b><b>B</b></p>
+<p><i>A</i><b><i>B</i></b></p>
+<p><b>A</b><i><b>B</b></i></p>
+<p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
+!! end
+
+!! test
+2. I/B qoute minimization: wikitext and html tags should not be combined
+!! options
+parsoid=html2wt
+!! input
+''A''<i>B</i>
+
+''A'''''<i>B</i>'''
+!! result
+<p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
+<p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
+!! end
+
+!! test
+3. I/B qoute minimization: templated content stops minimization
+!! options
+parsoid=html2wt
+!! input
+''A''{{echo|''B''}}
+
+''A''{{echo|'''''B'''''}}
+!! result
+<p><i>A</i><i about="#mwt1" typeof="mw:Transclusion"
data-mw='{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"''B''"}},"i":0}'>B</i>
+<p><i>A</i><b about="#mwt1" typeof="mw:Transclusion"
data-mw='{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"'''''B'''''"}},"i":0}'><i>B</i></b>
+!! end
+
+!! test
+4. I/B qoute minimization: new content should be mimimized with adjacent old
content
+!! options
+parsoid=html2wt
+!! input
+''AB''
+
+'''AB'''
+
+''A'''B'''''
+!! result
+<p><i>A</i><i data-parsoid='{}'>B</i></p>
+<p><b data-parsoid='{}'>A</b><b>B</b></p>
+<p><i>A</i><b data-parsoid='{}'><i data-parsoid='{}'>B</i></b></p>
+!! end
+
# -----------------------------------------------------------------
# End of section for Parsoid-only html2wt tests for serialization
# of new content
--
To view, visit https://gerrit.wikimedia.org/r/80335
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9dc00f6d05932bdfd8e7586323abe44addfc26ff
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits