jenkins-bot has submitted this change and it was merged.

Change subject: The autoInsertedEnd flags need to go on the open tag (not the 
close tag).
......................................................................


The autoInsertedEnd flags need to go on the open tag (not the close tag).

Change-Id: I661d45dfc1e01f203ed152268cc6e24ac36d6aaf
---
M js/lib/ext.core.QuoteTransformer.js
M js/tests/parserTests-blacklist.js
M js/tests/parserTests.txt
3 files changed, 34 insertions(+), 41 deletions(-)

Approvals:
  Subramanya Sastry: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/js/lib/ext.core.QuoteTransformer.js 
b/js/lib/ext.core.QuoteTransformer.js
index 613bc04..3e3975e 100644
--- a/js/lib/ext.core.QuoteTransformer.js
+++ b/js/lib/ext.core.QuoteTransformer.js
@@ -27,10 +27,9 @@
        this.chunks = [];
        // The current chunk we're accumulating into.
        this.currentChunk = [];
-       // References to chunks in which the first token context / quote token
-       // should be converted to italic or bold tokens.
-       this.italics = [];
-       this.bolds = [];
+       // last italic / last bold open tag seen.  Used to add autoInserted 
flags
+       // where necessary.
+       this.last = Object.create(null);
 
        this.isActive = false;
 };
@@ -243,13 +242,16 @@
                state = 'bi';
        }
        if ( state === 'b' || state === 'ib' ) {
-               this.currentChunk.push( new EndTagTk( 'b', [], 
{autoInsertedEnd:1} ) );
+               this.currentChunk.push( new EndTagTk( 'b' ) );
+               this.last.b.dataAttribs.autoInsertedEnd = 1;
        }
        if ( state === 'i' || state === 'bi' || state === 'ib' ) {
-               this.currentChunk.push( new EndTagTk( 'i', [], 
{autoInsertedEnd:1} ) );
+               this.currentChunk.push( new EndTagTk( 'i' ) );
+               this.last.i.dataAttribs.autoInsertedEnd = 1;
        }
        if ( state === 'bi' ) {
-               this.currentChunk.push( new EndTagTk( 'b', [], 
{autoInsertedEnd:1} ) );
+               this.currentChunk.push( new EndTagTk( 'b' ) );
+               this.last.b.dataAttribs.autoInsertedEnd = 1;
        }
 
        // return all collected tokens including the newline
@@ -300,15 +302,19 @@
        var startpos = tsr ? tsr[0] : null, endpos = tsr ? tsr[1] : null;
        for (var i=0; i<tags.length; i++) {
                if (tsr) {
-                       if ( ( i===0 || i===2) && ignoreBogusTwo ) {
-                               tags[i].dataAttribs.tsr = [ startpos, startpos 
];
+                       if ( i===0 && ignoreBogusTwo ) {
+                               
this.last[tags[i].name].dataAttribs.autoInsertedEnd = 1;
+                       } else if ( i === 2 && ignoreBogusTwo ) {
+                               tags[i].dataAttribs.autoInsertedStart = 1;
                        } else if (tags[i].name === 'b') {
                                tags[i].dataAttribs.tsr = [ startpos, startpos 
+ 3 ];
+                               startpos = tags[i].dataAttribs.tsr[1];
                        } else if (tags[i].name === 'i') {
                                tags[i].dataAttribs.tsr = [ startpos, startpos 
+ 2 ];
+                               startpos = tags[i].dataAttribs.tsr[1];
                        } else { console.assert(false); }
-                       startpos = tags[i].dataAttribs.tsr[1];
                }
+               this.last[tags[i].name] = (tags[i].constructor === EndTagTk) ? 
null : tags[i];
                result.push(tags[i]);
        }
        if (tsr) { console.assert(startpos === endpos, startpos, endpos); }
diff --git a/js/tests/parserTests-blacklist.js 
b/js/tests/parserTests-blacklist.js
index ec1090e..7514c3a 100644
--- a/js/tests/parserTests-blacklist.js
+++ b/js/tests/parserTests-blacklist.js
@@ -380,7 +380,6 @@
 add("wt2html", "Section extraction, <pre> around bogus header (bug 10309)");
 add("wt2html", "Section replacement, <pre> around bogus header (bug 10309)");
 add("wt2html", "Handling of &#x0A; in URLs");
-add("wt2html", "5 quotes, code coverage +1 line (parsoid)");
 add("wt2html", "Special:Search page linking.");
 add("wt2html", "Say the magic word");
 add("wt2html", "Gallery");
@@ -544,7 +543,7 @@
 add("wt2wt", "Italics and bold: 5-quote opening sequence: (5,2)");
 add("wt2wt", "Italics and bold: 5-quote opening sequence: (5,3)");
 add("wt2wt", "Italics and bold: 5-quote opening sequence: (5,4)");
-add("wt2wt", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid)");
+add("wt2wt", "Italics and bold: multiple quote sequences: (2,4,2)");
 add("wt2wt", "Italics and bold: multiple quote sequences: (2,4,3)");
 add("wt2wt", "Italics and bold: multiple quote sequences: (2,4,4)");
 add("wt2wt", "Italics and bold: multiple quote sequences: (3,4,2) (parsoid)");
@@ -724,7 +723,6 @@
 add("html2html", "Italics and bold: 3-quote opening sequence: (3,5) 
(parsoid)");
 add("html2html", "Italics and bold: 4-quote opening sequence: (4,5) 
(parsoid)");
 add("html2html", "Italics and bold: 5-quote opening sequence: (5,2)");
-add("html2html", "Italics and bold: multiple quote sequences: (2,4,2) 
(parsoid)");
 add("html2html", "Italics and bold: multiple quote sequences: (3,4,2) 
(parsoid)");
 add("html2html", "Italics and bold: multiple quote sequences: (3,4,3) 
(parsoid)");
 add("html2html", "Italics and bold: other quote tests: (3,2,3,2)");
@@ -1231,7 +1229,7 @@
 add("html2wt", "Italics and bold: 5-quote opening sequence: (5,2)");
 add("html2wt", "Italics and bold: 5-quote opening sequence: (5,3)");
 add("html2wt", "Italics and bold: 5-quote opening sequence: (5,4)");
-add("html2wt", "Italics and bold: multiple quote sequences: (2,4,2) 
(parsoid)");
+add("html2wt", "Italics and bold: multiple quote sequences: (2,4,2)");
 add("html2wt", "Italics and bold: multiple quote sequences: (2,4,3)");
 add("html2wt", "Italics and bold: multiple quote sequences: (2,4,4)");
 add("html2wt", "Italics and bold: multiple quote sequences: (3,4,2) 
(parsoid)");
@@ -2309,18 +2307,18 @@
 add("selser", "Italics and bold: 5-quote opening sequence: (5,4) [[1]]");
 add("selser", "Italics and bold: 5-quote opening sequence: (5,4) [[[2]]]");
 add("selser", "Italics and bold: 5-quote opening sequence: (5,4) [[[[4]]]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[1]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[[0,[3]],1]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[2,3]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[1,2]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[2]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[2,1]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[[0,[2]],2]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[[0,[2]],0]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[[2,0],4]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[0,1]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[1,1]]");
-add("selser", "Italics and bold: multiple quote sequences: (2,4,2) (parsoid) 
[[[0,[3]],0]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) [[2]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) [[1]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) [[[2,0]]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) [[[2,2]]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) 
[[[0,[3]]]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) [1]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) [2]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) 
[[[2,[4]]]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) [[[3,2]]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) 
[[[0,[2]]]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) 
[[[3,[2]]]]");
+add("selser", "Italics and bold: multiple quote sequences: (2,4,2) [[[0,2]]]");
 add("selser", "Italics and bold: multiple quote sequences: (2,4,3) [1]");
 add("selser", "Italics and bold: multiple quote sequences: (2,4,3) [[[3,0]]]");
 add("selser", "Italics and bold: multiple quote sequences: (2,4,3) [[2]]");
@@ -3469,7 +3467,9 @@
 add("selser", "Handling of &#x0A; in URLs [[[1]]]");
 add("selser", "Handling of &#x0A; in URLs [[1]]");
 add("selser", "5 quotes, code coverage +1 line (parsoid) [2]");
+add("selser", "5 quotes, code coverage +1 line (parsoid) [[1]]");
 add("selser", "5 quotes, code coverage +1 line (parsoid) [1]");
+add("selser", "5 quotes, code coverage +1 line (parsoid) [[[2]]]");
 add("selser", "5 quotes, code coverage +1 line (parsoid) [[2]]");
 add("selser", "Say the magic word 
[[0,0,4,0,[4,0],0,0,0,3,4,1,0,[3],3,0,3,[3],4,1,4,0,0,[4],0,4,4,0,0,1,0,[3,0],2,[4,0],0,[3,0],0,3,0,4,3,1,0,1]]");
 add("selser", "Say the magic word 
[[0,0,[3,0],3,[3,0],0,[2,0],0,[4],4,3,3,0,0,[3],0,0,4,[3],2,2,4,3,2,0,3,0,0,[4,0],3,[3,0],3,1,4,4,3,2,2,[4,0],2,[2],3,0]]");
diff --git a/js/tests/parserTests.txt b/js/tests/parserTests.txt
index fd1102e..0958217 100644
--- a/js/tests/parserTests.txt
+++ b/js/tests/parserTests.txt
@@ -696,24 +696,11 @@
 ### multiple quote sequences in a line
 ###
 !! test
-Italics and bold: multiple quote sequences: (2,4,2) (php)
-!! options
-php
+Italics and bold: multiple quote sequences: (2,4,2)
 !! input
 ''foo''''bar''
 !! result
 <p><i>foo'<b>bar</b></i>
-</p>
-!!end
-# The PHP parser strips the empty tags out for giggles; parsoid doesn't.
-!! test
-Italics and bold: multiple quote sequences: (2,4,2) (parsoid)
-!! options
-parsoid
-!! input
-''foo''''bar''
-!! result
-<p><i>foo'<b>bar</b></i><b></b>
 </p>
 !!end
 
@@ -12802,7 +12789,7 @@
 !! input
 '''''
 !! result
-<p><i><b></b></i></p>
+<p><b><i></i></b></p>
 !! end
 
 !! test

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I661d45dfc1e01f203ed152268cc6e24ac36d6aaf
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
Gerrit-Reviewer: GWicke <[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

Reply via email to