jenkins-bot has submitted this change and it was merged.
Change subject: T95730: Scrub empty anchors
......................................................................
T95730: Scrub empty anchors
* Instead of producing [[Test|<nowiki/>]]
Change-Id: I1288e03282d35ba7f4460afe86d40b1003c93a72
---
M lib/wts.normalizeDOM.js
M tests/parserTests.txt
2 files changed, 64 insertions(+), 0 deletions(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/wts.normalizeDOM.js b/lib/wts.normalizeDOM.js
index c3b3752..00662f6 100644
--- a/lib/wts.normalizeDOM.js
+++ b/lib/wts.normalizeDOM.js
@@ -144,6 +144,9 @@
// Anchors
} else if (node.nodeName === 'A') {
var next = node.nextSibling;
+ if (stripIfEmpty(node) !== node) {
+ return next;
+ }
var last = node.lastChild;
var endsInSpace = DU.isText(last) &&
last.nodeValue.match(/\s+$/);
// Move trailing spaces out of links
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 79982c2..263c8ea 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -25172,6 +25172,67 @@
''<nowiki/>'''''<nowiki/>'''
!! end
+# This can be re-enabled once https://gerrit.wikimedia.org/r/#/c/229563
+# is merged.
+#
+# !! test
+# 3. WT Quote Tags: suppress empty style tags on edits
+# !! options
+# parsoid={
+# "modes": ["selser"],
+# "scrubWikitext": true,
+# "changes": [
+# [ "#x", "remove"]
+# ]
+# }
+# !! wikitext
+# '''<span id="x">foo</span>'''
+# !! wikitext/edited
+# !! end
+
+!! test
+1. Anchors: suppress newly created empty anchors
+!! options
+parsoid={
+ "modes": ["html2wt"],
+ "scrubWikitext": true
+}
+!! html/parsoid
+<a rel="mw:WikiLink" href="./Test" title="Test"></a>
+!! wikitext
+!! end
+
+!! test
+2. Anchors: don't suppress empty anchors if scrubWikitext is false
+!! options
+parsoid={
+ "modes": ["html2wt"],
+ "scrubWikitext": false
+}
+!! html/parsoid
+<a rel="mw:WikiLink" href="./Test" title="Test"></a>
+!! wikitext
+[[Test|<nowiki/>]]
+!! end
+
+# This can be re-enabled once https://gerrit.wikimedia.org/r/#/c/229563
+# is merged.
+#
+# !! test
+# 3. Anchors: suppress empty anchors on edits
+# !! options
+# parsoid={
+# "modes": ["selser"],
+# "scrubWikitext": true,
+# "changes": [
+# [ "#x", "remove"]
+# ]
+# }
+# !! wikitext
+# [[Test|<span id="x">foo</span>]]
+# !! wikitext/edited
+# !! end
+
!! test
1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
!! options
--
To view, visit https://gerrit.wikimedia.org/r/229597
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1288e03282d35ba7f4460afe86d40b1003c93a72
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits