[MediaWiki-commits] [Gerrit] Fix to makeSepIndentPreSafe: always safe when nested in an i... - change (mediawiki...parsoid)

2014-01-02 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Fix to makeSepIndentPreSafe: always safe when nested in an 
indentPre!
..


Fix to makeSepIndentPreSafe: always safe when nested in an indentPre!

* echo  ''a''\n  ''b'' | node parse --wt2wt was normalizing
  whitespace on the second line because makeSepIndentPreSafe was
  not checking if the separator came from a node that was nested
  inside an indentPre. A simple check for state.inIndentPre fixes
  this issue.

* Added a parser test to capture this which passes wt2wt mode.

* This eliminates dirty diffs seen in RT testing
  Ex: jawiki:ベルマン-フォード法

* Additional change: separator constraints were being destructively
  updated in --trace wts mode. Fixed this to prevent hair-tearing
  during debugging.

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

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



diff --git a/lib/mediawiki.WikitextSerializer.js 
b/lib/mediawiki.WikitextSerializer.js
index d0617c7..9cc5c0c 100644
--- a/lib/mediawiki.WikitextSerializer.js
+++ b/lib/mediawiki.WikitextSerializer.js
@@ -3880,7 +3880,7 @@
}
 
if (this.debugging) {
-   var constraints = nlConstraints;
+   var constraints = Util.clone(nlConstraints);
constraints.constraintInfo = undefined;
this.trace('makeSeparator', sep, origSep, minNls, sepNlCount, 
constraints);
}
@@ -4004,8 +4004,9 @@
// We also should test for onSOL state to deal with HTML like
// ul lifoo/li/ul
// and strip the leading space before non-indent-pre-safe tags
-   if (sep.match(/\n+ +(!--(?:[^\-]|-(?!-))*--[^\n]*)?$/g) || (
-   (constraintInfo.onSOL  sep.match(/ 
+(!--(?:[^\-]|-(?!-))*--[^\n]*)?$/g
+   if (!state.inIndentPre 
+   (sep.match(/\n+ +(!--(?:[^\-]|-(?!-))*--[^\n]*)?$/g) || (
+   (constraintInfo.onSOL  sep.match(/ 
+(!--(?:[^\-]|-(?!-))*--[^\n]*)?$/g)
{
// 'sep' is the separator before 'nodeB' and it has leading 
spaces on a newline.
// We have to decide whether that leading space will trigger 
indent-pres in wikitext.
@@ -4085,6 +4086,12 @@
}
}
 
+   if (this.debugging) {
+   var constraints = Util.clone(nlConstraints);
+   constraints.constraintInfo = undefined;
+   this.trace('makePreSafe  ', sep, constraints);
+   }
+
return sep;
 };
 
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 6f2f7de..a6b9e63 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -2284,6 +2284,18 @@
 /pre
 !! end
 
+!! test
+5c. White-space in indent-pre
+!! input
+ ''a''
+  ''b''
+   ''c''
+!! result
+preia/i
+ ib/i
+  ic/i
+/pre
+!! end
 
 !! test
 6. Pre-blocks should extend across lines with leading WS even when there is no 
wrappable content

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2cc2e79137637df191c2544982cc08b2a0777de4
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry ssas...@wikimedia.org
Gerrit-Reviewer: Arlolra abrea...@wikimedia.org
Gerrit-Reviewer: Cscott canan...@wikimedia.org
Gerrit-Reviewer: GWicke gwi...@wikimedia.org
Gerrit-Reviewer: Marcoil marc...@wikimedia.org
Gerrit-Reviewer: jenkins-bot

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


[MediaWiki-commits] [Gerrit] Fix to makeSepIndentPreSafe: always safe when nested in an i... - change (mediawiki...parsoid)

2013-12-31 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review.

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


Change subject: Fix to makeSepIndentPreSafe: always safe when nested in an 
indentPre!
..

Fix to makeSepIndentPreSafe: always safe when nested in an indentPre!

* echo  ''a''\n  ''b'' | node parse --wt2wt was normalizing
  whitespace on the second line because makeSepIndentPreSafe was
  not checking if the separator came from a node that was nested
  inside an indentPre. A simple check for state.inIndentPre fixes
  this issue.

* Added a parser test to capture this which passes wt2wt mode.

* This eliminates dirty diffs seen in RT testing
  Ex: jawiki:ベルマン-フォード法

* Additional change: separator constraints were being destructively
  updated in --trace wts mode. Fixed this to prevent hair-tearing
  during debugging.

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


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

diff --git a/lib/mediawiki.WikitextSerializer.js 
b/lib/mediawiki.WikitextSerializer.js
index d0617c7..186b519 100644
--- a/lib/mediawiki.WikitextSerializer.js
+++ b/lib/mediawiki.WikitextSerializer.js
@@ -3880,7 +3880,7 @@
}
 
if (this.debugging) {
-   var constraints = nlConstraints;
+   var constraints = Util.clone(nlConstraints);
constraints.constraintInfo = undefined;
this.trace('makeSeparator', sep, origSep, minNls, sepNlCount, 
constraints);
}
@@ -4004,8 +4004,9 @@
// We also should test for onSOL state to deal with HTML like
// ul lifoo/li/ul
// and strip the leading space before non-indent-pre-safe tags
-   if (sep.match(/\n+ +(!--(?:[^\-]|-(?!-))*--[^\n]*)?$/g) || (
-   (constraintInfo.onSOL  sep.match(/ 
+(!--(?:[^\-]|-(?!-))*--[^\n]*)?$/g
+   if (!state.inIndentPre 
+   (sep.match(/\n+ +(!--(?:[^\-]|-(?!-))*--[^\n]*)?$/g) || (
+   (constraintInfo.onSOL  sep.match(/ 
+(!--(?:[^\-]|-(?!-))*--[^\n]*)?$/g)
{
// 'sep' is the separator before 'nodeB' and it has leading 
spaces on a newline.
// We have to decide whether that leading space will trigger 
indent-pres in wikitext.
@@ -4085,6 +4086,12 @@
}
}
 
+   if (this.debugging) {
+   var constraints = nlConstraints;
+   constraints.constraintInfo = undefined;
+   this.trace('makePreSafe  ', sep, constraints);
+   }
+
return sep;
 };
 
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 6f2f7de..a6b9e63 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -2284,6 +2284,18 @@
 /pre
 !! end
 
+!! test
+5c. White-space in indent-pre
+!! input
+ ''a''
+  ''b''
+   ''c''
+!! result
+preia/i
+ ib/i
+  ic/i
+/pre
+!! end
 
 !! test
 6. Pre-blocks should extend across lines with leading WS even when there is no 
wrappable content

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cc2e79137637df191c2544982cc08b2a0777de4
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