Subramanya Sastry has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/181709

Change subject: Tweak nowiki stripping: pretend <br> is self-closing
......................................................................

Tweak nowiki stripping: pretend <br> is self-closing

* Seems common enough in rt-testing to be worth making
  an exception for <br>.

Change-Id: I92ee517d85378fc62afaeab757a7a7987fca1b7c
---
M lib/mediawiki.WikitextSerializer.js
M tests/parserTests.txt
2 files changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/09/181709/1

diff --git a/lib/mediawiki.WikitextSerializer.js 
b/lib/mediawiki.WikitextSerializer.js
index 5f26d96..8beafce 100644
--- a/lib/mediawiki.WikitextSerializer.js
+++ b/lib/mediawiki.WikitextSerializer.js
@@ -1296,8 +1296,12 @@
                                        nowiki_index = j;
                                }
                                continue;
-                       } else if (selfClose) {
-                               continue; // skip over self-closing tags
+                       } else if (selfClose || tag === "br") {
+                               // Skip over self-closing tags or what should 
have been self-closed.
+                               // ( While we could do this for all void tags 
defined in
+                               //   mediawiki.wikitext.constants.js, <br> is 
the most common
+                               //   culprit. )
+                               continue;
                        } else if (tag[0]==="'" && stack[stack.length-1]===tag) 
{
                                stack.pop();
                                quotesOnStack--;
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index f40e1b6..05bca66 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -21031,6 +21031,7 @@
 [[foo]] x'''[[bar]]''
 '''foo'' <ref>test</ref>
 '''foo'' <div title="name">test</div>
+'''foo'' and <br> bar
 !! html
 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
@@ -21038,6 +21039,7 @@
 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" 
rel="mw:WikiLink" title="Bar">bar</a></i>
 '<i>foo</i> <span class="reference" id="cite_ref-1-0" rel="dc:references" 
typeof="mw:Extension/ref" 
data-mw='{"name":"ref","body":{"html":"test"},"attrs":{}}'><a 
href="#cite_note-1">[1]</a></span>
 '<i>foo</i> <div title="name">test</div>
+'<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
 !! end
 
 !! test

-- 
To view, visit https://gerrit.wikimedia.org/r/181709
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I92ee517d85378fc62afaeab757a7a7987fca1b7c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <ssas...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to