[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: WIP: Display count of linter errors in the main namespace

2018-01-19 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405327 )

Change subject: WIP: Display count of linter errors in the main namespace
..

WIP: Display count of linter errors in the main namespace

* This gives wikis a better sense of scope of work to be ready
  for Tidy replacement.

Bug: T173943
Change-Id: I80da94f3bf903d9144c542d9836b6d06ba03ec65
---
M i18n/en.json
M i18n/qqq.json
M includes/ApiQueryLinterStats.php
M includes/RecordLintJob.php
M includes/SpecialLintErrors.php
M includes/TotalsLookup.php
6 files changed, 41 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/27/405327/1

diff --git a/i18n/en.json b/i18n/en.json
index 2ef9756..cb22c80 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -61,6 +61,7 @@
"linter-category-misc-tidy-replacement-issues": "Miscellaneous Tidy 
replacement issues",
"linter-category-misc-tidy-replacement-issues-desc": "These pages have 
other issues that affect rendering when Tidy is replaced",
"linter-numerrors": "($1 {{PLURAL:$1|error|errors}})",
+   "linter-ns0-numerrors": "($1 {{PLURAL:$1|error|errors}} in Main 
namespace)",
"linter-page-title-edit": "$1 ($2)",
"linter-page-edit": "edit",
"linter-page-viewsource": "view source",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index a650798..2db23e4 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -64,6 +64,7 @@
"linter-category-multiline-html-table-in-list-desc": "Description of 
category",
"linter-category-misc-tidy-replacement-issues": "Name of lint error 
category. See [[:mw:Help:Extension:Linter/misc-tidy-replacement-issues]]",
"linter-category-misc-tidy-replacement-issues-desc": "Description of 
category",
+   "linter-ns0-numerrors": "Shown after a category link to indicate how 
many errors are in that category in the Main namespace. $1 is the number of 
errors, and can be used for PLURAL.\n{{Identical|Error}}",
"linter-numerrors": "Shown after a category link to indicate how many 
errors are in that category. $1 is the number of errors, and can be used for 
PLURAL.\n{{Identical|Error}}",
"linter-page-title-edit": "Used in a table cell. $1 is a link to the 
page, $2 is pipe separated links to the edit and history pages, the link text 
is {{msg-mw|linter-page-edit}} and {{msg-mw|linter-page-history}}",
"linter-page-edit": "Link text for edit link in 
{{msg-mw|linter-page-title-edit}}\n{{Identical|Edit}}",
diff --git a/includes/ApiQueryLinterStats.php b/includes/ApiQueryLinterStats.php
index 6f716ed..560e625 100644
--- a/includes/ApiQueryLinterStats.php
+++ b/includes/ApiQueryLinterStats.php
@@ -38,7 +38,7 @@

MediaWikiServices::getInstance()->getMainWANObjectCache()
);
 
-   $totals = $totalsLookup->getTotals();
+   $totals = $totalsLookup->getTotals( null );
ApiResult::setArrayType( $totals, 'assoc' );
$this->getResult()->addValue( [ 'query', 'linterstats' ], 
'totals', $totals );
}
diff --git a/includes/RecordLintJob.php b/includes/RecordLintJob.php
index 7063169..d484c10 100644
--- a/includes/RecordLintJob.php
+++ b/includes/RecordLintJob.php
@@ -107,7 +107,7 @@
return;
}
 
-   $totals = $lintDb->getTotals();
+   $totals = $lintDb->getTotals( null );
$wiki = wfWikiID();
 
$stats = $mwServices->getStatsdDataFactory();
diff --git a/includes/SpecialLintErrors.php b/includes/SpecialLintErrors.php
index 2f33fab..4ac0ff5 100644
--- a/includes/SpecialLintErrors.php
+++ b/includes/SpecialLintErrors.php
@@ -87,11 +87,11 @@
 * @param int[] $totals name => count
 * @param string[] $categories
 */
-   private function displayList( $priority, $totals, array $categories ) {
+   private function displayList( $priority, $totals, $ns0Totals, array 
$categories ) {
$out = $this->getOutput();
$msgName = 'linter-heading-' . $priority . '-priority';
$out->addHTML( Html::element( 'h2', [], $this->msg( $msgName 
)->text() ) );
-   $out->addHTML( $this->buildCategoryList( $categories, $totals ) 
);
+   $out->addHTML( $this->buildCategoryList( $categories, $totals, 
$ns0Totals ) );
}
 
private function showCategoryListings( CategoryManager $catManager ) {
@@ -99,12 +99,13 @@
$catManager,

MediaWikiServices::getInstance()->getMainWANObjectCache()
);
-   $totals = $lookup->getTotals();
+   $totals = $lookup->getTotals( null );
+   $ns0Totals = $lookup->getTotals( 0 );
 
// Display lint issues by priority
-   $this->displayList(

[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: Update linter stats for commonswiki less frequently

2018-01-14 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404233 )

Change subject: Update linter stats for commonswiki less frequently
..

Update linter stats for commonswiki less frequently

Bug: T184280
Change-Id: I64667a1932696ff4418ad05a72455d6a7e1b875e
---
M wmf-config/InitialiseSettings.php
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/33/404233/1

diff --git a/wmf-config/InitialiseSettings.php 
b/wmf-config/InitialiseSettings.php
index a16e30c..81d0699 100644
--- a/wmf-config/InitialiseSettings.php
+++ b/wmf-config/InitialiseSettings.php
@@ -14611,6 +14611,7 @@
 
 'wgLinterStatsdSampleFactor' => [
'default' => 1000,
+   'commonswiki' => 5000, // T184280
'small' => 50,
'medium' => 100,
 ],

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64667a1932696ff4418ad05a72455d6a7e1b875e
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: WIP: Suppress low-priority categories for commons for now

2018-01-10 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403581 )

Change subject: WIP: Suppress low-priority categories for commons for now
..

WIP: Suppress low-priority categories for commons for now

* Don't process any low priority lint error updates
* Don't display low priority lint error categories

Change-Id: If0037f6d3cb30050a1c6a2c551284d650fa77828
---
M includes/ApiRecordLint.php
M includes/CategoryManager.php
M includes/RecordLintJob.php
M includes/SpecialLintErrors.php
4 files changed, 33 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/81/403581/1

diff --git a/includes/ApiRecordLint.php b/includes/ApiRecordLint.php
index 26f2853..56fc598 100644
--- a/includes/ApiRecordLint.php
+++ b/includes/ApiRecordLint.php
@@ -78,7 +78,7 @@
$errors[] = $info;
}
 
-   $job = new RecordLintJob( $title, [
+   $job = new RecordLintJob( $catgoryMgr, $title, [
'errors' => $errors,
'revision' => $params['revision'],
] );
diff --git a/includes/CategoryManager.php b/includes/CategoryManager.php
index d08b887..44d06d6 100644
--- a/includes/CategoryManager.php
+++ b/includes/CategoryManager.php
@@ -175,4 +175,20 @@
 
throw new MissingCategoryException( "Cannot find id for 
'$name'" );
}
+
+   /**
+* Check if a category id is a low priority category
+*
+* @param int $id
+* @return bool
+*/
+   public function isLowPriorityCategory( $id ) {
+   foreach ( $this->categories[self::LOW] as $name ) {
+   if ( $id == $this->getCategoryId( $name ) ) {
+   return true;
+   }
+   }
+
+   return false;
+   }
 }
diff --git a/includes/RecordLintJob.php b/includes/RecordLintJob.php
index 7063169..2e0a005 100644
--- a/includes/RecordLintJob.php
+++ b/includes/RecordLintJob.php
@@ -25,13 +25,16 @@
 use Title;
 
 class RecordLintJob extends Job {
+   private $catMgr;
+
/**
 * RecordLintJob constructor.
 * @param Title $title
 * @param array $params
 */
-   public function __construct( Title $title, array $params ) {
+   public function __construct( CategoryManager $catMgr, Title $title, 
array $params ) {
parent::__construct( 'RecordLintJob', $title, $params );
+   $this->catMgr = $catMgr;
}
 
public function run() {
@@ -39,6 +42,9 @@
// Outdated now, let a later job handle it
return true;
}
+
+   // T184280: Drop low priority categories from commons for now
+   $dropLowPriority = wfWikiID() == "commonswiki" ? true : false;
 
// [ 'category' => [ 'id' => LintError ] ]
$errors = [];
@@ -55,6 +61,9 @@
$lintDb = new Database( $this->title->getArticleID() );
$toSet = [];
foreach ( $errors as $category => $catErrors ) {
+   if ( $dropLowPriority && 
$catMgr->isLowPriorityCategory( $category ) ) {
+   $catErrors = [];
+   }
// If there are too many errors for a category, trim 
some of them.
if ( count( $catErrors ) > $lintDb::MAX_PER_CAT ) {
$catErrors = array_slice( $catErrors, 0, 
$lintDb::MAX_PER_CAT );
diff --git a/includes/SpecialLintErrors.php b/includes/SpecialLintErrors.php
index 2f33fab..0a62f28 100644
--- a/includes/SpecialLintErrors.php
+++ b/includes/SpecialLintErrors.php
@@ -28,9 +28,12 @@
 class SpecialLintErrors extends SpecialPage {
 
private $category;
+   private $suppressLowPriority;
 
public function __construct() {
parent::__construct( 'LintErrors' );
+   // T184280: Suppress low priority categories from commons for 
now
+   $suppressLowPriority = wfWikiID() == "commonswiki" ? true : 
false;
}
 
protected function showNamespaceFilterForm( $ns ) {
@@ -104,7 +107,9 @@
// Display lint issues by priority
$this->displayList( 'high', $totals, 
$catManager->getHighPriority() );
$this->displayList( 'medium', $totals, 
$catManager->getMediumPriority() );
-   $this->displayList( 'low', $totals, 
$catManager->getLowPriority() );
+   if ( !$this->suppressLowPriority ) {
+   $this->displayList( 'low', $totals, 
$catManager->getLowPriority() );
+   }
}
 
/**

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

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Improve handling of section-wrapping and extcontent boundary...

2018-01-09 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403314 )

Change subject: Improve handling of section-wrapping and extcontent boundary 
conflicts
..

Improve handling of section-wrapping and extcontent boundary conflicts

1. We mistakenly assumed presence of dataMW.body.extsrc for all
   extensions.

2. Expanding template source to include toplevel content was not
   the right thing to do for all extensions -- it might be okay for
   the translate extension which was the primary source of these
   conflicts according to 5c4f0f5b.

Deal with both scenarios properly by adding additional prefix/suffix
properties to data-mw.body for section tags that swallow other content
surrounding extension content and get extension markers added to them.

This required updating html2wt to handle the prefix/suffix text
properly - otherwise, those will be lost in html2wt (since the content
could have been marked extension affected).
Ex: https://fr.wikisource.org/wiki/Clair_de_lune_(Leopold_von_Sacher-Masoch)

Change-Id: I9cef92966fb9acd8262237884ae8ec7acfe9cdcc
---
M lib/html2wt/DOMHandlers.js
M lib/wt2html/pp/processors/wrapSections.js
2 files changed, 7 insertions(+), 2 deletions(-)


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

diff --git a/lib/html2wt/DOMHandlers.js b/lib/html2wt/DOMHandlers.js
index d6984a4..927ab0c 100644
--- a/lib/html2wt/DOMHandlers.js
+++ b/lib/html2wt/DOMHandlers.js
@@ -1493,6 +1493,10 @@
}
return p.then(function(s) {
state.singleLineContext.disable();
+   // FIXME: Ugh!
+   if ((dataMw.extPrefix || dataMw.extSuffix)) {
+   s = (dataMw.extPrefix || '') + s + 
(dataMw.extSuffix || '');
+   }
self.emitWikitext(handleListPrefix(node, state) 
+ s, node);
state.singleLineContext.pop();
return DU.skipOverEncapsulatedContent(node);
diff --git a/lib/wt2html/pp/processors/wrapSections.js 
b/lib/wt2html/pp/processors/wrapSections.js
index 2f5d315..7a07bf3 100644
--- a/lib/wt2html/pp/processors/wrapSections.js
+++ b/lib/wt2html/pp/processors/wrapSections.js
@@ -230,7 +230,7 @@
if 
(/mw:Transclusion/.test(tplInfo.first.getAttribute('typeof'))) {

dmw.parts.push(state.getSrc(tplEndOffset, newTplEndOffset));
} else { /* Extension */
-   dmw.body.extsrc += 
state.getSrc(tplEndOffset, newTplEndOffset);
+   dmw.extSuffix = 
state.getSrc(tplEndOffset, newTplEndOffset);
}
// Update DSR
tplDsr[1] = newTplEndOffset;
@@ -281,7 +281,8 @@
// the transclusion and eliminates dirty-diffs.
DU.setDataParsoid(newS1, { pi: tplDP.pi, dsr: [ 
dsr1, dsr2 ] });
} else { /* extension */
-   dmw.body.extsrc = state.getSrc(dsr1, tplDsr[0]) 
+ dmw.body.extsrc + state.getSrc(tplDsr[1], dsr2);
+   dmw.extPrefix = state.getSrc(dsr1, tplDsr[0]);
+   dmw.extSuffix = state.getSrc(tplDsr[1], dsr2);
DU.setDataMw(newS1, dmw);
newS1.setAttribute('typeof', 
tplInfo.first.getAttribute('typeof'));
DU.setDataParsoid(newS1, { dsr: [ dsr1, dsr2 ] 
});

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9cef92966fb9acd8262237884ae8ec7acfe9cdcc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Fix crasher in Cite - don't assume well-formedness

2018-01-08 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403063 )

Change subject: Linter: Fix crasher in Cite - don't assume well-formedness
..

Linter: Fix crasher in Cite - don't assume well-formedness

Change-Id: Ie5da61934b91f115b0eea995e05de6c231d77bdb
---
M lib/ext/Cite/index.js
1 file changed, 5 insertions(+), 2 deletions(-)


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

diff --git a/lib/ext/Cite/index.js b/lib/ext/Cite/index.js
index d7f8f02..6e177d3 100644
--- a/lib/ext/Cite/index.js
+++ b/lib/ext/Cite/index.js
@@ -183,8 +183,11 @@
 
 Ref.prototype.lintHandler = function(ref, env, tplInfo, domLinter) {
var linkBackId = ref.firstChild.getAttribute('href').replace(/[^#]*#/, 
'');
-   var refContent = ref.ownerDocument.getElementById(linkBackId).lastChild;
-   domLinter(refContent, env, tplInfo.isTemplated ? tplInfo : null);
+   var refNode = ref.ownerDocument.getElementById(linkBackId)
+   if (refNode) {
+   // Ex: Buggy input wikitext without ref content
+   domLinter(refNode.lastChild, env, tplInfo.isTemplated ? tplInfo 
: null);
+   }
return ref.nextNode;
 };
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5da61934b91f115b0eea995e05de6c231d77bdb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Don't emit missing-end-tag warnings for builder-inserted tags

2018-01-04 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402094 )

Change subject: Don't emit missing-end-tag warnings for builder-inserted tags
..

Don't emit missing-end-tag warnings for builder-inserted tags

* These have both auto-inserted start and end set. There is no
  useful information conveyed to editors by these lint errors.

  This also has the benefit of suppressing the false positive
  multiple-unclosed-formatting-tags errors without more state.

Change-Id: I5e5b77af8b7e2b3d2fc41f56d9a32c41c32f9568
---
M lib/wt2html/pp/processors/linter.js
1 file changed, 2 insertions(+), 5 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/linter.js 
b/lib/wt2html/pp/processors/linter.js
index 1394fab..8339b4c 100644
--- a/lib/wt2html/pp/processors/linter.js
+++ b/lib/wt2html/pp/processors/linter.js
@@ -351,11 +351,8 @@
}
adjDp.tmp.linted = true;
env.log('lint/misnested-tag', lintObj);
-   } else if (!endTagOptional(c)) {
+   } else if (!endTagOptional(c) && 
!dp.autoInsertedStart) {
lintObj.params.inTable = 
DU.hasAncestorOfName(c, 'TABLE');
-   if (dp.autoInsertedStart) {
-   lintObj.params.aiStart = true;
-   }
env.log('lint/missing-end-tag', 
lintObj);
if 
(Consts.HTML.FormattingTags.has(c.nodeName) && matchedOpenTagPairExists(c, dp)) 
{

env.log('lint/multiple-unclosed-formatting-tags', lintObj);
@@ -762,7 +759,7 @@
var multiUnclosedTagName = null;
lints.find(function(item) {
// Unclosed tags in tables don't leak out of the table
-   if (item.type === 'missing-end-tag' && !item.params.aiStart && 
!item.params.inTable) {
+   if (item.type === 'missing-end-tag' && !item.params.inTable) {
if (item.params.name === 'small' || item.params.name 
=== 'big') {
var tagName = item.params.name;
if (!firstUnclosedTag[tagName]) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e5b77af8b7e2b3d2fc41f56d9a32c41c32f9568
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Don't crash while detecting fostered content

2018-01-02 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401588 )

Change subject: Linter: Don't crash while detecting fostered content
..

Linter: Don't crash while detecting fostered content

* Discovered while testing the linter-reparse script on
  pages in the fostered linter category on itwiki.

Change-Id: I8ca6c9c966876cb3b14f7442244533f84a8e0aeb
---
M lib/wt2html/pp/processors/linter.js
1 file changed, 4 insertions(+), 0 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/linter.js 
b/lib/wt2html/pp/processors/linter.js
index 90c21c2..1394fab 100644
--- a/lib/wt2html/pp/processors/linter.js
+++ b/lib/wt2html/pp/processors/linter.js
@@ -387,6 +387,10 @@
maybeTable = maybeTable.nextSibling;
}
 
+   if (!maybeTable) {
+   return null;
+   }
+
// In pathological cases, we might walk past fostered nodes
// that carry templating information. This then triggers
// other errors downstream. So, walk back to that first node

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ca6c9c966876cb3b14f7442244533f84a8e0aeb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Fix mocha tests

2018-01-02 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401514 )

Change subject: Linter: Fix mocha tests
..

Linter: Fix mocha tests

Change-Id: Ia9066a9b6eb2982ea21b46f5be88a24a4fc43b55
---
M tests/mocha/linter.js
1 file changed, 3 insertions(+), 3 deletions(-)


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

diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index afe4183..c90047a 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -792,7 +792,7 @@
});
});
it('should ignore unclosed small tags in tables', function() {
-   noLintsOfThisType('{|\n|a\n|b\n|}', 
"multiple-unclosed-formatting-tags");
+   return 
noLintsOfThisType('{|\n|a\n|b\n|}', 
"multiple-unclosed-formatting-tags");
});
it('should ignore unclosed small tags in tables but detect 
those outside it', function() {
return 
parseWT('x\n{|\n|a\n|b\n|}\ny').then(function(result)
 {
@@ -813,10 +813,10 @@
});
});
it("should not flag Tidy's smart auto-fixup of paired unclosed 
formatting tags where Tidy won't do it", function() {
-   noLintsOfThisType('foo \nfoo x 
', "multiple-unclosed-formatting-tags");
+   return noLintsOfThisType('foo \nfoo 
x ', "multiple-unclosed-formatting-tags");
});
it("should not flag Tidy's smart auto-fixup of paired unclosed 
tags for non-formatting tags", function() {
-   noLintsOfThisType('foo\nfoo 
x bar', "multiple-unclosed-formatting-tags");
+   return noLintsOfThisType('foo\nfoo 
x bar', "multiple-unclosed-formatting-tags");
});
});
describe('UNCLOSED WIKITEXT I/B tags in headings', function() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia9066a9b6eb2982ea21b46f5be88a24a4fc43b55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: T183893: Linter: Suppress multiple-unclosed-formatting-tags ...

2018-01-02 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401515 )

Change subject: T183893: Linter: Suppress multiple-unclosed-formatting-tags 
false positives
..

T183893: Linter: Suppress multiple-unclosed-formatting-tags false positives

Change-Id: Ia9eb0db638d76855b81cafab7afe81b59182e8d3
---
M lib/wt2html/pp/processors/linter.js
M tests/mocha/linter.js
2 files changed, 7 insertions(+), 1 deletion(-)


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

diff --git a/lib/wt2html/pp/processors/linter.js 
b/lib/wt2html/pp/processors/linter.js
index aa2a945..90c21c2 100644
--- a/lib/wt2html/pp/processors/linter.js
+++ b/lib/wt2html/pp/processors/linter.js
@@ -353,6 +353,9 @@
env.log('lint/misnested-tag', lintObj);
} else if (!endTagOptional(c)) {
lintObj.params.inTable = 
DU.hasAncestorOfName(c, 'TABLE');
+   if (dp.autoInsertedStart) {
+   lintObj.params.aiStart = true;
+   }
env.log('lint/missing-end-tag', 
lintObj);
if 
(Consts.HTML.FormattingTags.has(c.nodeName) && matchedOpenTagPairExists(c, dp)) 
{

env.log('lint/multiple-unclosed-formatting-tags', lintObj);
@@ -755,7 +758,7 @@
var multiUnclosedTagName = null;
lints.find(function(item) {
// Unclosed tags in tables don't leak out of the table
-   if (item.type === 'missing-end-tag' && !item.params.inTable) {
+   if (item.type === 'missing-end-tag' && !item.params.aiStart && 
!item.params.inTable) {
if (item.params.name === 'small' || item.params.name 
=== 'big') {
var tagName = item.params.name;
if (!firstUnclosedTag[tagName]) {
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index c90047a..8889a11 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -801,6 +801,9 @@
result[4].params.should.have.a.property("name", 
"small");
});
});
+   it('should not flag undetected misnesting of formatting tags as 
multiple unclosed formatting tags', function() {
+   return noLintsOfThisType('{{1x|\n*item 
1\n}}', "multiple-unclosed-formatting-tags");
+   });
it("should detect Tidy's smart auto-fixup of paired unclosed 
formatting tags", function() {
return parseWT('foo\nfoo x 
bar').then(function(result) {
result.should.have.length(6);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia9eb0db638d76855b81cafab7afe81b59182e8d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to 28d7734f for deploy

2018-01-01 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401425 )

Change subject: Bump src to 28d7734f for deploy
..

Bump src to 28d7734f for deploy

Change-Id: Ia9c0cf587f7135fc8220f8fef34dc8d673981e32
---
M src
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/25/401425/1

diff --git a/src b/src
index 439abf7..28d7734 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit 439abf76ce434ae814f625bac57dabb12671c6dd
+Subproject commit 28d7734fa2385a8fa599e3ce1bfbcd8582c05bc4

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia9c0cf587f7135fc8220f8fef34dc8d673981e32
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Simplify logic a bit for readability + fix file comment

2018-01-01 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401424 )

Change subject: Linter: Simplify logic a bit for readability + fix file comment
..

Linter: Simplify logic a bit for readability + fix file comment

Change-Id: I2e9d578474ca73928634f55517106bc82aed23f4
---
M lib/wt2html/pp/processors/linter.js
1 file changed, 9 insertions(+), 25 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/linter.js 
b/lib/wt2html/pp/processors/linter.js
index f705cab..aa2a945 100644
--- a/lib/wt2html/pp/processors/linter.js
+++ b/lib/wt2html/pp/processors/linter.js
@@ -1,14 +1,6 @@
 /*
- * DOM pass that walks the DOM tree and places a call to logger
- * with logtype 'lint/*' to log the following scenarios:
- *
- * 1. Treebuilder fixups
- * 2. Fostered content
- * 3. Ignored table attributes
- * 4. Multi-template blocks
- * 5. Mixed content in template markup
- * 6. Obsolete HTML tags
- * 7. Self-closed HTML tags
+ * DOM pass that walks the DOM tree, detects specific wikitext patterns,
+ * and emits them as linter events via the lint/* logger type.
  */
 
 'use strict';
@@ -897,23 +889,15 @@
};
}
 
-   // Let native extensions lint their content
var nextNode;
-   var done = false;
+   var nativeExt;
var match = (nodeTypeOf || '').match(/\bmw:Extension\/(.+?)\b/);
-   if (match) {
-   var extTag = match[1];
-   var nativeExt = env.conf.wiki.extensionTags.get(extTag);
-   if (nativeExt && nativeExt.lintHandler) {
-   nextNode = nativeExt.lintHandler(node, env, 
tplInfo, findLints);
-   done = true;
-   }
-   }
-
-   // Default node handler
-   // Don't rely on the presence or well-behavedness of the native 
lint handler
-   // That is the reason for if (!done) instead of if (!nextNode)
-   if (!done) {
+   if (match &&
+   (nativeExt = env.conf.wiki.extensionTags.get(match[1])) 
&&
+   nativeExt.lintHandler
+   ) { // Let native extensions lint their content
+   nextNode = nativeExt.lintHandler(node, env, tplInfo, 
findLints);
+   } else { // Default node handler
// Lint this node
nextNode = logWikitextFixups(node, env, tplInfo);
if (tplInfo && tplInfo.clear) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e9d578474ca73928634f55517106bc82aed23f4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Bump RemexHTML version to 1.0.2

2018-01-01 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401414 )

Change subject: Bump RemexHTML version to 1.0.2
..

Bump RemexHTML version to 1.0.2

Change-Id: I25bfac2c71b50db8d64f29f4b84af0a2732f245b
---
M composer.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/14/401414/1

diff --git a/composer.json b/composer.json
index 35783f2..8b8697e 100644
--- a/composer.json
+++ b/composer.json
@@ -39,7 +39,7 @@
"wikimedia/php-session-serializer": "1.0.4",
"wikimedia/purtle": "1.0.6",
"wikimedia/relpath": "2.0.0",
-   "wikimedia/remex-html": "1.0.1",
+   "wikimedia/remex-html": "1.0.2",
"wikimedia/running-stat": "1.1.0",
"wikimedia/scoped-callback": "1.0.0",
"wikimedia/utfnormal": "1.1.0",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25bfac2c71b50db8d64f29f4b84af0a2732f245b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...RemexHtml[master]: Add test case for T183379

2018-01-01 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/401412 )

Change subject: Add test case for T183379
..

Add test case for T183379

Bug: T183379
Change-Id: Ic2f15df04b3fe52bb586c91e58a9517ed93d7b6d
---
M tests/local/tree-construction/remex01.dat
1 file changed, 20 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/libs/RemexHtml 
refs/changes/12/401412/1

diff --git a/tests/local/tree-construction/remex01.dat 
b/tests/local/tree-construction/remex01.dat
index 4dabfe2..fc404bc 100644
--- a/tests/local/tree-construction/remex01.dat
+++ b/tests/local/tree-construction/remex01.dat
@@ -51,3 +51,23 @@
 | id="2"
 | 
 |   id="3"
+
+#data
+foofoo
+#errors
+#document
+| 
+| 
+|   
+|   
+| 
+|   
+| 
+|   "foo"
+|   
+|   
+| 
+|   
+| 
+|   
+| "foo"

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2f15df04b3fe52bb586c91e58a9517ed93d7b6d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/libs/RemexHtml
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...RemexHtml[master]: Some variable / class member renames for clarity

2017-12-21 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399759 )

Change subject: Some variable / class member renames for clarity
..

Some variable / class member renames for clarity

Change-Id: Ib0db7596195089469524f6f52515ee2c205348aa
---
M RemexHtml/TreeBuilder/CachingStack.php
M RemexHtml/TreeBuilder/Element.php
2 files changed, 36 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/libs/RemexHtml 
refs/changes/59/399759/1

diff --git a/RemexHtml/TreeBuilder/CachingStack.php 
b/RemexHtml/TreeBuilder/CachingStack.php
index 74112e1..4be4449 100644
--- a/RemexHtml/TreeBuilder/CachingStack.php
+++ b/RemexHtml/TreeBuilder/CachingStack.php
@@ -16,9 +16,9 @@
const SCOPE_TABLE = 3;
const SCOPE_SELECT = 4;
 
-   private static $tableScopes = [ self::SCOPE_DEFAULT, self::SCOPE_LIST, 
self::SCOPE_BUTTON,
+   private static $allScopes = [ self::SCOPE_DEFAULT, self::SCOPE_LIST, 
self::SCOPE_BUTTON,
self::SCOPE_TABLE, self::SCOPE_SELECT ];
-   private static $regularScopes = [ self::SCOPE_DEFAULT, 
self::SCOPE_LIST, self::SCOPE_BUTTON,
+   private static $nonTableScopes = [ self::SCOPE_DEFAULT, 
self::SCOPE_LIST, self::SCOPE_BUTTON,
self::SCOPE_SELECT ];
private static $listScopes = [ self::SCOPE_LIST, self::SCOPE_SELECT ];
private static $buttonScopes = [ self::SCOPE_BUTTON, self::SCOPE_SELECT 
];
@@ -127,7 +127,7 @@
 * A cache of the elements which are currently in a given scope.
 * The first key is the scope ID, the second key is the element name, 
and the
 * value is the first Element in a singly-linked list of Element 
objects,
-* linked by $element->nextScope.
+* linked by $element->nextEltInScope.
 *
 * @todo Benchmark time and memory compared to an array stack instead 
of an
 * SLL. The SLL here is maybe not quite so well justified as some other
@@ -165,16 +165,17 @@
private $templateCount;
 
/**
-* Get the list of scopes that are broken for a given namespace and
-* element name.
+* For a given namespace and element name, get the list of scopes
+* for which a new scope should be created and the old one needs to
+* be pushed onto the scope stack.
 */
-   private function getBrokenScopes( $ns, $name ) {
+   private function getScopeTypesToStack( $ns, $name ) {
if ( $ns === HTMLData::NS_HTML ) {
switch ( $name ) {
case 'html':
case 'table':
case 'template':
-   return self::$tableScopes;
+   return self::$allScopes;
 
case 'applet':
case 'caption':
@@ -182,7 +183,7 @@
case 'th':
case 'marquee':
case 'object':
-   return self::$regularScopes;
+   return self::$nonTableScopes;
 
case 'ol':
case 'ul':
@@ -200,13 +201,13 @@
}
} elseif ( $ns === HTMLData::NS_MATHML ) {
if ( isset( self::$mathBreakers[$name] ) ) {
-   return self::$regularScopes;
+   return self::$nonTableScopes;
} else {
return self::$selectOnly;
}
} elseif ( $ns === HTMLData::NS_SVG ) {
if ( isset( self::$svgBreakers[$name] ) ) {
-   return self::$regularScopes;
+   return self::$nonTableScopes;
} else {
return self::$selectOnly;
}
@@ -225,14 +226,14 @@
// Update the scope cache
$ns = $elt->namespace;
$name = $elt->name;
-   foreach ( $this->getBrokenScopes( $ns, $name ) as $scope ) {
-   $this->scopeStacks[$scope][] = $this->scopes[$scope];
-   $this->scopes[$scope] = [];
+   foreach ( $this->getScopeTypesToStack( $ns, $name ) as $type ) {
+   $this->scopeStacks[$type][] = $this->scopes[$type];
+   $this->scopes[$type] = [];
}
if ( $ns === HTMLData::NS_HTML && isset( 
self::$predicateMap[$name] ) ) {
-   $scopeId = self::$predicateMap[$name];
-   $scope =& $this->scopes[$scopeId];
-   $elt->nextScope = isset( $scope[$name] ) ? 
$scope[$name] : null;
+   $type = self::$predicateMap[$name];

[MediaWiki-commits] [Gerrit] mediawiki...RemexHtml[master]: Fix linked list manipulation in CachedScopeStack

2017-12-21 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399760 )

Change subject: Fix linked list manipulation in CachedScopeStack
..

Fix linked list manipulation in CachedScopeStack

Bug: T183379
Change-Id: Ia01386cd39376bbb5f05533d584063c8ab14b633
---
M RemexHtml/TreeBuilder/CachingStack.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/libs/RemexHtml 
refs/changes/60/399760/1

diff --git a/RemexHtml/TreeBuilder/CachingStack.php 
b/RemexHtml/TreeBuilder/CachingStack.php
index 4be4449..a67cfdc 100644
--- a/RemexHtml/TreeBuilder/CachingStack.php
+++ b/RemexHtml/TreeBuilder/CachingStack.php
@@ -295,7 +295,7 @@
if ( $nextElt === $oldElt ) {
$scopeElt->nextEltInScope = 
$elt;
$elt->nextEltInScope = 
$nextElt->nextEltInScope;
-   $scopeElt->nextEltInScope = 
null;
+   $nextElt->nextEltInScope = null;
break;
}
$scopeElt = $scopeElt->nextEltInScope;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia01386cd39376bbb5f05533d584063c8ab14b633
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/libs/RemexHtml
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Delete commented out lints + mocha tests

2017-12-18 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398902 )

Change subject: Linter: Delete commented out lints + mocha tests
..

Linter: Delete commented out lints + mocha tests

Change-Id: Iac8460ac7a39c941d6ad560814a950b457d37c41
---
M lib/wt2html/pp/processors/linter.js
M tests/mocha/linter.js
2 files changed, 0 insertions(+), 133 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/linter.js 
b/lib/wt2html/pp/processors/linter.js
index 32cc7c5..4d466e1 100644
--- a/lib/wt2html/pp/processors/linter.js
+++ b/lib/wt2html/pp/processors/linter.js
@@ -74,33 +74,6 @@
return tagsWithChangedMisnestingBehavior;
 }
 
-/*
- * Log Transclusion with more than one parts
- * Ex - {{table-start}}
- *  {{cell|unused value|key=used value}}
- *  |-
- *  {{cell|unused value|key=used value}}
- *  |-
- *  |1+1
- *  |}
- * 
https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Transclusion_content
- */
-/*
-function logTransclusions(env, node, dp, tplInfo) {
-   var parts = DU.getDataMw(node).parts;
-   if (!Array.isArray(parts) || parts.length < 2) { return; }
-
-   var type = 'multi-template';
-   parts.forEach(function(a) {
-   if (typeof a === 'string') {
-   type = 'mixed-content';
-   }
-   });
-
-   env.log('lint/' + type, { dsr: tplInfo.dsr });
-}
-*/
-
 var getNextMatchingNode, leftMostDescendent;
 
 leftMostDescendent = function(node, match) {
@@ -395,64 +368,8 @@
}
}
}
-
-   /* TODO: not sure if this is useful / valid at all. Suppress 
for now.
-   if (DU.hasLiteralHTMLMarker(dp) &&
-   dp.autoInsertedStart === true &&
-   (tplInfo ||  dsr[3] > 0)) {
-   lintObj = {
-   dsr: dsr,
-   templateInfo: templateInfo,
-   };
-   env.log('lint/missing-start-tag', lintObj);
-   }
-   */
}
 }
-
-/*
- * Log ignored table attributes.
- * This handles cases like:
- *
- * {|
- * |- foo
- * | bar
- * |}
- *
- * Here foo gets ignored and is found in the data-parsoid of  tags.
- */
-
-/* --
- * Comment out this whole thing to satisfy eslint
- *
-function logIgnoredTableAttr(env, node, dp, tplInfo) {
-   if (!node.nodeName === 'TABLE') {
-   return;
-   }
-
-   var tbody = DU.firstNonSepChildNode(node);
-   var c = tbody.firstChild;
-   while (c) {
-   if (c.nodeName === 'TR') {
-   dp = DU.getDataParsoid(c);
-   if (dp.sa) {
-   // Discard attributes that are only whitespace 
and comments
-   for (var key in dp.sa) {
-   var re = 
/^\s*$|^([ \t]|)*$/;
-   if (!re.test(key) || 
!re.test(dp.sa[key])) {
-   // FIXME: This is incorrect.
-   // We need to check if the key 
is absent in dp.a / in the node's attribute
-   var templateInfo = 
findEnclosingTemplateName(env, tplInfo);
-   var lintObj = { dsr: 
findLintDSR(templateInfo, tplInfo, dp.dsr), templateInfo: templateInfo };
-   
env.log('lint/ignored-table-attr', lintObj);
-   }
-   }
-   }
-   }
-   c = c.nextSibling;
-   }
-}
-*/
 
 /*
  * Log fostered content marked by markFosteredContent.js
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index 47dfdcc..afe4183 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -230,37 +230,6 @@
});
});
 
-   /*
-   describe('IGNORED TABLE ATTRIBUTES', function() {
-   it('should lint ignored table attributes correctly', function() 
{
-   return parseWT('{|\n|- 
foo\n|bar\n|}').then(function(result) {
-   result.should.have.length(1);
-   result[0].should.have.a.property("type", 
"ignored-table-attr");
-   result[0].dsr.should.deep.equal([ 3, 14, 6, 0 
]);
-   });
-   });
-   it('should lint ignored table attributes found in transclusions 
correctly', function() {
-   return parseWT('{{1x|\n{{{!}}\n{{!}}- foo\n{{!}} 
bar\n{{!}}}\n}}').then(function(resu

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Use extension mechanism to provide ext-specific lint...

2017-12-18 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398895 )

Change subject: Linter: Use extension mechanism to provide ext-specific lint 
handers
..

Linter: Use extension mechanism to provide ext-specific lint handers

* Refactoring of previous patch.
* Move cite-specific lint handling code to the Cite extension.

Change-Id: Ib57f0303605a73408333e133f8051be0b8d45d69
---
M lib/ext/Cite/index.js
M lib/wt2html/pp/processors/linter.js
2 files changed, 44 insertions(+), 35 deletions(-)


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

diff --git a/lib/ext/Cite/index.js b/lib/ext/Cite/index.js
index ced0b51..6f7265a 100644
--- a/lib/ext/Cite/index.js
+++ b/lib/ext/Cite/index.js
@@ -168,6 +168,12 @@
}),
 };
 
+Ref.prototype.lintHandler = function(ref, env, tplInfo, domLinter) {
+   var linkBackId = ref.firstChild.getAttribute('href').replace(/[^#]*#/, 
'');
+   var refContent = ref.ownerDocument.getElementById(linkBackId).lastChild;
+   domLinter(refContent, env, tplInfo.isTemplated ? tplInfo : null);
+};
+
 /**
  * Helper class used by  implementation
  */
@@ -664,6 +670,22 @@
},
 };
 
+References.prototype.lintHandler = function(ref, env, tplInfo, domLinter) {
+   // Nothing to do
+   //
+   // FIXME: Not entirely true for scenarios where the  tags
+   // are defined in the references section that is itself templated.
+   //
+   // {{1x|\nfoo\n}}
+   //
+   // In this example, the references tag has the right tplInfo and
+   // when the  tag is processed in the body of the article where
+   // it is accessed, there is no relevant template or dsr info available.
+   //
+   // Ignoring for now.
+   return;
+};
+
 /* 
  * This handles wikitext like this:
  *
@@ -766,10 +788,12 @@
name: 'ref',
tokenHandler: 
this.ref.tokenHandler.bind(this.ref),
serialHandler: this.ref.serialHandler,
+   lintHandler: this.ref.lintHandler,
}, {
name: 'references',
tokenHandler: 
this.references.tokenHandler.bind(this.references),
serialHandler: this.references.serialHandler,
+   lintHandler: this.references.lintHandler,
},
],
styles: [
diff --git a/lib/wt2html/pp/processors/linter.js 
b/lib/wt2html/pp/processors/linter.js
index f84fd86..32cc7c5 100644
--- a/lib/wt2html/pp/processors/linter.js
+++ b/lib/wt2html/pp/processors/linter.js
@@ -957,8 +957,6 @@
}
 }
 
-var lintRef, lintReferences;
-
 function findLints(root, env, tplInfo) {
var node = root.firstChild;
while (node !== null) {
@@ -967,26 +965,35 @@
continue;
}
 
-   var nextNode;
+   var nodeTypeOf = null;
 
+   // !tplInfo check is to protect against templated content in
+   // extensions which might in turn be nested in templated 
content.
if (!tplInfo && DU.isFirstEncapsulationWrapperNode(node)) {
-   var about = node.getAttribute("about");
+   nodeTypeOf = node.getAttribute('typeof');
tplInfo = {
first: node,
-   last: 
JSUtils.lastItem(DU.getAboutSiblings(node, about)),
+   last: 
JSUtils.lastItem(DU.getAboutSiblings(node, node.getAttribute("about"))),
dsr: DU.getDataParsoid(node).dsr,
-   isTemplated: 
/\bmw:Transclusion\b/.test(node.getAttribute('typeof')),
+   isTemplated: 
/\bmw:Transclusion\b/.test(nodeTypeOf),
clear: false,
};
}
 
-   // FIXME: Special hack for Cite extension.
-   // In a later patch, make this an extension hook.
-   if 
(/\bmw:Extension\/references\b/.test(node.getAttribute('typeof'))) {
-   lintReferences(node, env, tplInfo);
-   } else if 
(/\bmw:Extension\/ref\b/.test(node.getAttribute('typeof'))) {
-   lintRef(node, env, tplInfo);
-   } else {
+   // Let native extensions lint their content
+   var done = false;
+   if (/\bmw:Extension\/\b/.test(nodeTypeOf)) {
+   var extTag = nodeTypeOf.replace(/^.*\bmw:Extension\/([^ 
]+).*$/, '$1');
+   var nativeExt = env.conf.wiki.extensionTags.get(extTag);
+   if (nativeExt && nati

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Properly attribute lint issues in cite extension

2017-12-18 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398876 )

Change subject: Linter: Properly attribute lint issues in cite extension
..

Linter: Properly attribute lint issues in cite extension

*  content ends up in references section. The original 
  site only has a backlink to that references section.

* Given this, when the references tag itself comes from a template,
  this throws off the linter attribution code. It assigns the
  references template's DSR to the lints from the  tags.

* A clean way of dealing with this would be to treat extension
  content as its own independent document (which we are already doing
  currently in our wt2html code path) and asking the extension to process
  its content while giving it the handler for linting an individual node.

  In this patch, I implement that by adding special handlers for
   and  content. Ideally, extensions would register
  their own lint handlers for their content failing which the default
  mechanism of using the existing handler would apply.

  This hook mechanism is left for a followup patch since there is more
  work to be done there.

* New mocha tests spec this behavior.

Change-Id: Ie823e5afcef88628149e8ffe1e4a3f348cdc6c32
---
M lib/wt2html/pp/processors/linter.js
M tests/mocha/linter.js
2 files changed, 96 insertions(+), 14 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/linter.js 
b/lib/wt2html/pp/processors/linter.js
index ee75a99..4463cd9 100644
--- a/lib/wt2html/pp/processors/linter.js
+++ b/lib/wt2html/pp/processors/linter.js
@@ -957,6 +957,28 @@
}
 }
 
+function lintReferences(refs, env, tplInfo) {
+   // Nothing to do
+   //
+   // FIXME: Not entirely true for scenarios where the  tags
+   // are defined in the references section that is itself templated.
+   //
+   // {{1x|\nfoo\n}}
+   //
+   // In this example, the references tag has the right tplInfo and
+   // when the  tag is processed in the body of the article where
+   // it is accessed, there is no relevant template or dsr info available.
+   //
+   // Ignoring for now.
+   return;
+}
+
+function lintRef(ref, env, tplInfo) {
+   var linkBackId = ref.firstChild.getAttribute('href').replace(/[^#]*#/, 
'');
+   var refContent = ref.ownerDocument.getElementById(linkBackId).lastChild;
+   findLints(refContent, env, tplInfo.isTemplated ? tplInfo : null);
+}
+
 function findLints(root, env, tplInfo) {
var node = root.firstChild;
while (node !== null) {
@@ -965,37 +987,41 @@
continue;
}
 
-   // Identify the first template/extension node.
-   // You'd think the !tplInfo check isn't necessary since
-   // we don't have nested transclusions, however, you can
-   // get extensions in transclusions.
if (!tplInfo && DU.isFirstEncapsulationWrapperNode(node)) {
var about = node.getAttribute("about");
tplInfo = {
first: node,
last: 
JSUtils.lastItem(DU.getAboutSiblings(node, about)),
dsr: DU.getDataParsoid(node).dsr,
+   isTemplated: 
/\bmw:Transclusion\b/.test(node.getAttribute('typeof')),
clear: false,
};
}
 
-   // Lint this node
-   var nextNode = logWikitextFixups(node, env, tplInfo);
-   if (tplInfo && tplInfo.clear) {
-   tplInfo = null;
-   }
+   // FIXME: Special hack for Cite extension.
+   // In a later patch, make this an extension hook.
+   if 
(/\bmw:Extension\/references\b/.test(node.getAttribute('typeof'))) {
+   lintReferences(node, env, tplInfo);
+   } else if 
(/\bmw:Extension\/ref\b/.test(node.getAttribute('typeof'))) {
+   lintRef(node, env, tplInfo);
+   } else {
+   // Lint this node
+   var nextNode = logWikitextFixups(node, env, tplInfo);
+   if (tplInfo && tplInfo.clear) {
+   tplInfo = null;
+   }
 
-   // Lint subtree
-   if (!nextNode) {
-   findLints(node, env, tplInfo);
-   nextNode = node.nextSibling;
+   // Lint subtree
+   if (!nextNode) {
+   findLints(node, env, tplInfo);
+   }
}
 
if (tplInfo && tplInfo.last === node) {
tplInfo = null;
 

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: WIP: Linter: Properly attribute lint issues in cite extension

2017-12-16 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398676 )

Change subject: WIP: Linter: Properly attribute lint issues in cite extension
..

WIP: Linter: Properly attribute lint issues in cite extension

* ref content ends up in references section and when references
  is templated, this throws off the linter attribution code.

* mocha tests added.

Change-Id: Ic84f6fa26e1c4b63f744587ff13c44e5e61bdd3c
---
M lib/wt2html/pp/processors/linter.js
M tests/mocha/linter.js
2 files changed, 67 insertions(+), 17 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/linter.js 
b/lib/wt2html/pp/processors/linter.js
index 47bb13c..71b73bf 100644
--- a/lib/wt2html/pp/processors/linter.js
+++ b/lib/wt2html/pp/processors/linter.js
@@ -957,7 +957,7 @@
}
 }
 
-function findLints(root, env, tplInfo) {
+function findLints(root, env, tplInfoStack) {
var node = root.firstChild;
while (node !== null) {
if (!DU.isElt(node)) {
@@ -965,37 +965,52 @@
continue;
}
 
-   // Identify the first template/extension node.
-   // You'd think the !tplInfo check isn't necessary since
-   // we don't have nested transclusions, however, you can
-   // get extensions in transclusions.
-   if (!tplInfo && DU.isFirstEncapsulationWrapperNode(node)) {
+   // Maintain a stack of templated info because extensions
+   // can templated and those extensions can, in turn, use 
templates.
+   //
+   //foo {{1x|x}}
+   //{{1x|  }}
+   //
+   var currTplInfo = JSUtils.lastItem(tplInfoStack);
+   if (DU.isFirstEncapsulationWrapperNode(node)) {
var about = node.getAttribute("about");
-   tplInfo = {
+   currTplInfo = {
first: node,
last: 
JSUtils.lastItem(DU.getAboutSiblings(node, about)),
dsr: DU.getDataParsoid(node).dsr,
clear: false,
+   typeof: node.getAttribute('typeof'),
};
+   tplInfoStack.push(currTplInfo);
+   }
+
+   // FIXME: Special hack for Cite extension
+   if (currTplInfo && 
/\bmw:Extension\/references\b/.test(currTplInfo.typeof)) {
+   var dp = DU.getDataParsoid(node);
+   // FIXME: fiwiki: Aspartaami crashes here because 
currTplInfo.dsr is null!
+   if (dp.dsr && dp.dsr[1] <= currTplInfo.dsr[0]) {
+   currTplInfo = null;
+   }
}
 
// Lint this node
-   var nextNode = logWikitextFixups(node, env, tplInfo);
-   if (tplInfo && tplInfo.clear) {
-   tplInfo = null;
+   var nextNode = logWikitextFixups(node, env, currTplInfo);
+   if (currTplInfo && currTplInfo.clear) {
+   tplInfoStack.pop();
}
 
// Lint subtree
-   if (!nextNode) {
-   findLints(node, env, tplInfo);
-   nextNode = node.nextSibling;
+   // FIXME: Special optimization for Cite extension
+   // (Skip  linkbacks since they are Parsoid-generated)
+   if (!nextNode && (!currTplInfo || 
!/\bmw:Extension\/ref\b/.test(currTplInfo.typeof))) {
+   findLints(node, env, tplInfoStack);
}
 
-   if (tplInfo && tplInfo.last === node) {
-   tplInfo = null;
+   if (currTplInfo && currTplInfo.last === node) {
+   tplInfoStack.pop();
}
 
-   node = nextNode;
+   node = nextNode || node.nextSibling;
}
 }
 
@@ -1006,7 +1021,7 @@
return;
}
 
-   findLints(body, env);
+   findLints(body, env, []);
postProcessLints(env.lintLogger.buffer);
 }
 
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index 55e1019..8f2eb81 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -937,4 +937,39 @@
return expectEmptyResults("a 
\nb\n ");
});
});
+   describe('LINT ISSUES IN  TAGS', function() {
+   it('should attribute linter issues to the ref tag', function() {
+   return parseWT('a x 
').then(function(result) {
+   result.should.have.length(1);
+   result[0].should.have.a.property("type", 
"mis

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Move linting pass to the very end

2017-12-16 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398674 )

Change subject: Move linting pass to the very end
..

Move linting pass to the very end

* This requires marker meta stripping to be moved to the end as well.

Change-Id: I74e8351065203ebc76aae505da91f6da3bc63816
---
M lib/wt2html/DOMPostProcessor.js
1 file changed, 21 insertions(+), 21 deletions(-)


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

diff --git a/lib/wt2html/DOMPostProcessor.js b/lib/wt2html/DOMPostProcessor.js
index 113073f..e0df1b6 100644
--- a/lib/wt2html/DOMPostProcessor.js
+++ b/lib/wt2html/DOMPostProcessor.js
@@ -177,31 +177,27 @@
domVisitor.addHandler(null, CleanUp.handleEmptyElements);
addPP('handleEmptyElts', domVisitor.traverse.bind(domVisitor));
 
+   domVisitor = new DOMTraverser(env);
+   var tableFixer = new TableFixups(env);
+   // 1. Deal with -hack and move trailing categories in s out of 
the list
+   domVisitor.addHandler('li', liFixups.handleLIHack);
+   domVisitor.addHandler('li', liFixups.migrateTrailingCategories);
+   // 2. Fix up issues from templated table cells and table cell attributes
+   domVisitor.addHandler('td', tableFixer.stripDoubleTDs.bind(tableFixer));
+   domVisitor.addHandler('td', 
tableFixer.handleTableCellTemplates.bind(tableFixer));
+   domVisitor.addHandler('th', 
tableFixer.handleTableCellTemplates.bind(tableFixer));
+   // 3. Add heading anchors
+   domVisitor.addHandler(null, headings.genAnchors);
+   addPP('(li+table)Fixups+headings', 
domVisitor.traverse.bind(domVisitor));
+
+   // Add  wrappers around sections
+   addPP('wrapSections', wrapSections);
+
if (env.conf.parsoid.linting) {
domVisitor = new DOMTraverser(env);
domVisitor.addHandler(null, linter.logWikitextFixups);
addPP('linter', domVisitor.traverse.bind(domVisitor));
}
-
-   domVisitor = new DOMTraverser(env);
-   var tableFixer = new TableFixups(env);
-   // 1. Strip marker metas -- removes left over marker metas (ex: metas
-   //nested in expanded tpl/extension output).
-   domVisitor.addHandler('meta',
-   CleanUp.stripMarkerMetas.bind(null, 
env.conf.parsoid.rtTestMode));
-   // 2. Deal with -hack and move trailing categories in s out of 
the list
-   domVisitor.addHandler('li', liFixups.handleLIHack);
-   domVisitor.addHandler('li', liFixups.migrateTrailingCategories);
-   // 3. Fix up issues from templated table cells and table cell attributes
-   domVisitor.addHandler('td', tableFixer.stripDoubleTDs.bind(tableFixer));
-   domVisitor.addHandler('td', 
tableFixer.handleTableCellTemplates.bind(tableFixer));
-   domVisitor.addHandler('th', 
tableFixer.handleTableCellTemplates.bind(tableFixer));
-   // 4. Add heading anchors
-   domVisitor.addHandler(null, headings.genAnchors);
-   addPP('stripMarkers+(li+table)Fixups+headings', 
domVisitor.traverse.bind(domVisitor));
-
-   // Add  wrappers around sections
-   addPP('wrapSections', wrapSections);
 
// Make heading IDs unique
domVisitor = new DOMTraverser(env);
@@ -240,7 +236,11 @@
}
return true;
});
-   addPP('heading id uniqueness', domVisitor.traverse.bind(domVisitor));
+   // Strip marker metas -- removes left over marker metas (ex: metas
+   // nested in expanded tpl/extension output).
+   domVisitor.addHandler('meta',
+   CleanUp.stripMarkerMetas.bind(null, 
env.conf.parsoid.rtTestMode));
+   addPP('heading id uniqueness + stripMarkerMetas', 
domVisitor.traverse.bind(domVisitor));
 
// Save data.parsoid into data-parsoid html attribute.
// Make this its own thing so that any changes to the DOM

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I74e8351065203ebc76aae505da91f6da3bc63816
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Make linter its own self-contained DOM pass

2017-12-16 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398675 )

Change subject: Make linter its own self-contained DOM pass
..

Make linter its own self-contained DOM pass

* This gives it more control over how to process the DOM and
  also how to handle template / extension information.

* A followup patch will leverage this to process references content
  differently for improved lint information for ref tags. Currently,
  when the references tag comes from a template, all lint errors in
  ref tags on the page are attributed to the template that generate
  the references tag which mightily confusing and useless.

Change-Id: I48f8e19e61752a0b37a801d3ce4cddfed6e802c4
---
M lib/wt2html/DOMPostProcessor.js
R lib/wt2html/pp/processors/linter.js
2 files changed, 60 insertions(+), 23 deletions(-)


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

diff --git a/lib/wt2html/DOMPostProcessor.js b/lib/wt2html/DOMPostProcessor.js
index e0df1b6..47e5df3 100644
--- a/lib/wt2html/DOMPostProcessor.js
+++ b/lib/wt2html/DOMPostProcessor.js
@@ -1,4 +1,4 @@
-/* Perform post-processing steps on an already-built HTML DOM. */
+/;* Perform post-processing steps on an already-built HTML DOM. */
 
 'use strict';
 
@@ -18,6 +18,7 @@
 };
 var markFosteredContent = requireProcessor('markFosteredContent');
 var handleUnbalancedTables = requireProcessor('handleUnbalancedTables');
+var linter = requireProcessor('linter');
 var markTreeBuilderFixups = requireProcessor('markTreeBuilderFixups');
 var normalize = requireProcessor('normalize');
 var cleanupFormattingTagFixup = requireProcessor('cleanupFormattingTagFixup');
@@ -33,7 +34,6 @@
return require('./pp/handlers/' + file + '.js');
 };
 
-var linter = requireHandlers('linter');
 var CleanUp = requireHandlers('cleanup');
 var headings = requireHandlers('headings');
 var unpackDOMFragments = 
requireHandlers('unpackDOMFragments').unpackDOMFragments;
@@ -194,9 +194,7 @@
addPP('wrapSections', wrapSections);
 
if (env.conf.parsoid.linting) {
-   domVisitor = new DOMTraverser(env);
-   domVisitor.addHandler(null, linter.logWikitextFixups);
-   addPP('linter', domVisitor.traverse.bind(domVisitor));
+   addPP('linter', linter);
}
 
// Make heading IDs unique
@@ -535,9 +533,6 @@
}
if (psd.dumpFlags && psd.dumpFlags.has('wt2html:limits')) {
env.printParserResourceUsage({ 'HTML Size': 
document.outerHTML.length });
-   }
-   if (env.conf.parsoid.linting) {
-   linter.postProcessLints(env.lintLogger.buffer);
}
}
 
diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/processors/linter.js
similarity index 95%
rename from lib/wt2html/pp/handlers/linter.js
rename to lib/wt2html/pp/processors/linter.js
index c414d87..47bb13c 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/processors/linter.js
@@ -15,6 +15,7 @@
 
 var DU = require('../../../utils/DOMUtils.js').DOMUtils;
 var Util = require('../../../utils/Util.js').Util;
+var JSUtils = require('../../../utils/jsutils.js').JSUtils;
 var Consts = require('../../../config/WikitextConstants.js').WikitextConstants;
 
 /* 
--
@@ -915,18 +916,7 @@
env.log('lint/multiline-html-table-in-list', lintObj);
 }
 
-function logWikitextFixups(node, env, atTopLevel, tplInfo) {
-   // For now, don't run linter in subpipelines.
-   // Only on the final DOM for the top-level page.
-   if (!atTopLevel || !DU.isElt(node)) {
-   return true;
-   }
-
-   // Skip linting if we cannot lint it
-   if (!env.page.hasLintableContentModel()) {
-   return true;
-   }
-
+function logWikitextFixups(node, env, tplInfo) {
var dp = DU.getDataParsoid(node);
 
/*
@@ -963,11 +953,63 @@
if (dp.fostered && !DU.emitsSolTransparentSingleLineWT(env, node, 
true)) {
return logFosteredContent(env, node, dp, tplInfo);
} else {
-   return true;
+   return null;
}
 }
 
+function findLints(root, env, tplInfo) {
+   var node = root.firstChild;
+   while (node !== null) {
+   if (!DU.isElt(node)) {
+   node = node.nextSibling;
+   continue;
+   }
+
+   // Identify the first template/extension node.
+   // You'd think the !tplInfo check isn't necessary since
+   // we don't have nested transclusions, however, you can
+   // get extensions in transclusions.
+   if (!tplInfo && DU.isFirstEncapsulationWrapperNode(node)) {
+   var about = node.getAttribute("a

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Reorganize some mocha tests

2017-12-16 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398650 )

Change subject: Linter: Reorganize some mocha tests
..

Linter: Reorganize some mocha tests

Change-Id: Ib4920d58a03697d7dbcfadbdf49bb19870f8
---
M tests/mocha/linter.js
1 file changed, 58 insertions(+), 60 deletions(-)


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

diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index a4f914f..55e1019 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -869,74 +869,72 @@
noLintsOfThisType('foo\nfoo 
x bar', "multiple-unclosed-formatting-tags");
});
});
-   describe('MISC TIDY REPLACEMENT ISSUES', function() {
-   describe('Unclosed wikitext i/b in headings', function() {
-   it('should detect unclosed wikitext i tags in 
headings', function() {
-   return 
parseWT("==foo''a==\nx").then(function(result) {
-   result.should.have.length(1);
-   
result[0].should.have.a.property("type", "unclosed-quotes-in-heading");
-   
result[0].params.should.have.a.property("name", "i");
-   
result[0].params.should.have.a.property("ancestorName", "h2");
-   });
-   });
-   it('should detect unclosed wikitext b tags in 
headings', function() {
-   return 
parseWT("==foo'''a==\nx").then(function(result) {
-   result.should.have.length(1);
-   
result[0].should.have.a.property("type", "unclosed-quotes-in-heading");
-   
result[0].params.should.have.a.property("name", "b");
-   
result[0].params.should.have.a.property("ancestorName", "h2");
-   });
-   });
-   it('should not detect unclosed HTML i/b tags in 
headings', function() {
-   return 
parseWT("==fooa==\nx\n==fooa==\ny").then(function(result)
 {
-   result.should.have.length(2);
-   
result[0].should.have.a.property("type", "missing-end-tag");
-   
result[1].should.have.a.property("type", "missing-end-tag");
-   });
+   describe('UNCLOSED WIKITEXT I/B tags in headings', function() {
+   it('should detect unclosed wikitext i tags in headings', 
function() {
+   return 
parseWT("==foo''a==\nx").then(function(result) {
+   result.should.have.length(1);
+   result[0].should.have.a.property("type", 
"unclosed-quotes-in-heading");
+   result[0].params.should.have.a.property("name", 
"i");
+   
result[0].params.should.have.a.property("ancestorName", "h2");
});
});
-   describe('Multiline HTML tables in lists', function() {
-   it('should detect multiline HTML tables in lists (1)', 
function() {
-   return parseWT("* 
x\n").then(function(result) {
-   result.should.have.length(1);
-   
result[0].should.have.a.property("type", "multiline-html-table-in-list");
-   
result[0].params.should.have.a.property("name", "table");
-   
result[0].params.should.have.a.property("ancestorName", "li");
-   });
+   it('should detect unclosed wikitext b tags in headings', 
function() {
+   return 
parseWT("==foo'''a==\nx").then(function(result) {
+   result.should.have.length(1);
+   result[0].should.have.a.property("type", 
"unclosed-quotes-in-heading");
+   result[0].params.should.have.a.property("name", 
"b");
+   
result[0].params.should.have.a.property("ancestorName", "h2");
});
-   it('should detect multiline HTML tables in lists (2)', 
function() {
-   return parseWT("* 
x\n").then(function(result) {
-   result.should.have.length(1);
-   
result[0].should.have.a.property("type", "multiline-html-table-in-list");
-   
result[0].params.should.have.a.property("name", 

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Additional updates to multiline-html-table-in-list

2017-12-16 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398649 )

Change subject: Linter: Additional updates to multiline-html-table-in-list
..

Linter: Additional updates to multiline-html-table-in-list

* Handle HTML lists -- don't trigger linter issue there
* Handle dl/dt lists -- trigger linter issue there
* Added new tests

Change-Id: I33206f29cf9a9e6b991824eff2302d45bd32
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 32 insertions(+), 5 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index caa1891..c414d87 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -874,19 +874,27 @@
detectMultipleUnclosedFormattingTags(lints);
 }
 
-function hasListAncestor(node) {
-   while (node && node.nodeName !== 'LI') {
+function getWikitextListItemAncestor(node) {
+   while (node && !DU.isListItem(node)) {
node = node.parentNode;
}
 
+   // If the list item is a HTML list item, ignore it
// If the list item comes from references content, ignore it
-   return node && 
!(/mw:Extension\/references/.test(node.parentNode.getAttribute('typeof')));
+   if (node && !DU.isLiteralHTMLNode(node) &&
+   
!(/mw:Extension\/references/.test(node.parentNode.getAttribute('typeof')))
+   )  {
+   return node;
+   } else {
+   return null;
+   }
 }
 
 function logPHPParserBug(env, node, dp, tplInfo) {
+   var li;
if (!DU.isLiteralHTMLNode(node) ||
node.nodeName !== 'TABLE' ||
-   !hasListAncestor(node) ||
+   !(li = getWikitextListItemAncestor(node)) ||
!/\n/.test(node.outerHTML)
) {
return;
@@ -901,7 +909,7 @@
templateInfo: templateInfo,
params: {
name: 'table',
-   ancestorName: 'li',
+   ancestorName: li.nodeName.toLowerCase(),
}
};
env.log('lint/multiline-html-table-in-list', lintObj);
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index f1679db..a4f914f 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -912,6 +912,25 @@

result[0].params.should.have.a.property("ancestorName", "li");
});
});
+   it('should detect multiline HTML tables in lists (3)', 
function() {
+   return parseWT("; 
x\n").then(function(result) {
+   result.should.have.length(1);
+   
result[0].should.have.a.property("type", "multiline-html-table-in-list");
+   
result[0].params.should.have.a.property("name", "table");
+   
result[0].params.should.have.a.property("ancestorName", "dt");
+   });
+   });
+   it('should detect multiline HTML tables in lists (4)', 
function() {
+   return parseWT(": 
x\n").then(function(result) {
+   result.should.have.length(1);
+   
result[0].should.have.a.property("type", "multiline-html-table-in-list");
+   
result[0].params.should.have.a.property("name", "table");
+   
result[0].params.should.have.a.property("ancestorName", "dd");
+   });
+   });
+   it('should not detect multiline HTML tables in HTML 
lists', function() {
+   return 
expectEmptyResults("\nx\n\n");
+   });
it('should not detect single-line HTML tables in 
lists', function() {
return expectEmptyResults("* 
x");
});

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I33206f29cf9a9e6b991824eff2302d45bd32
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Update comments

2017-12-15 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398516 )

Change subject: Linter: Update comments
..

Linter: Update comments

Change-Id: Ia2f411dec0f9a83e75ddc7eafdc50f146b6a36c2
---
M lib/wt2html/pp/handlers/linter.js
1 file changed, 8 insertions(+), 0 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index f06ad79..db43032 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -283,6 +283,14 @@
  * 1. Unclosed end tags
  * 2. Unclosed start tags
  * 3. Stripped tags
+ *
+ * In addition, we have specialized categories for some patterns
+ * where we encounter unclosed end tags.
+ *
+ * 4. misnested-tag
+ * 5. html5-misnesting
+ * 6. multiple-unclosed-formatting-tags
+ * 7. unclosed-quotes-in-heading
  */
 function logTreeBuilderFixup(env, c, dp, tplInfo) {
// This might have been processed as part of

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2f411dec0f9a83e75ddc7eafdc50f146b6a36c2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Suppress false positives for multiple-unclosed-forma...

2017-12-15 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398518 )

Change subject: Linter: Suppress false positives for 
multiple-unclosed-formatting-tags
..

Linter: Suppress false positives for multiple-unclosed-formatting-tags

* Unclosed tags in tables don't leak out of the table in the HTML5
  tree building algorithm. So, those should be ignored for the purpose
  of detecting multiple unclosed formatting tags.

* There are of course edge cases here that we are going to conveniently
  ignore. For example, if the multiple unclosed tags are in the same
  table cell, that should trigger the check, but not sure it is worth
  the complexity.

  There are probably other edge cases where Tidy and HTML5 parsing
  will do things differently, but I think this is enough for now.
  At this rate, before long, we'll be running Tidy's fixup code in Parsoid.

* New tests added to spec this behavior.

* Verified on enwiki:Papa_Dee

Change-Id: Ie979ce0940a1613d5a4203ff75358dbf91f2535e
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 23 insertions(+), 11 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index a752413..caa1891 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -386,6 +386,7 @@
adjDp.tmp.linted = true;
env.log('lint/misnested-tag', lintObj);
} else if (!endTagOptional(c)) {
+   lintObj.params.inTable = 
DU.hasAncestorOfName(c, 'TABLE');
env.log('lint/missing-end-tag', 
lintObj);
if 
(Consts.HTML.FormattingTags.has(c.nodeName) && matchedOpenTagPairExists(c, dp)) 
{

env.log('lint/multiple-unclosed-formatting-tags', lintObj);
@@ -843,7 +844,8 @@
};
var multiUnclosedTagName = null;
lints.find(function(item) {
-   if (item.type === 'missing-end-tag') {
+   // Unclosed tags in tables don't leak out of the table
+   if (item.type === 'missing-end-tag' && !item.params.inTable) {
if (item.params.name === 'small' || item.params.name 
=== 'big') {
var tagName = item.params.name;
if (!firstUnclosedTag[tagName]) {
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index 4ed63ac..f1679db 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -40,6 +40,14 @@
});
};
 
+   var noLintsOfThisType = function(wt, type) {
+   return parseWT(wt).then(function(result) {
+   result.forEach(function(r) {
+   r.should.not.have.a.property("type", type);
+   });
+   });
+   };
+
describe('#Issues', function() {
it('should not lint any issues', function() {
return expectEmptyResults('foo');
@@ -833,6 +841,16 @@
result[4].params.should.have.a.property("name", 
"small");
});
});
+   it('should ignore unclosed small tags in tables', function() {
+   noLintsOfThisType('{|\n|a\n|b\n|}', 
"multiple-unclosed-formatting-tags");
+   });
+   it('should ignore unclosed small tags in tables but detect 
those outside it', function() {
+   return 
parseWT('x\n{|\n|a\n|b\n|}\ny').then(function(result)
 {
+   result.should.have.length(5);
+   result[4].should.have.a.property("type", 
"multiple-unclosed-formatting-tags");
+   result[4].params.should.have.a.property("name", 
"small");
+   });
+   });
it("should detect Tidy's smart auto-fixup of paired unclosed 
formatting tags", function() {
return parseWT('foo\nfoo x 
bar').then(function(result) {
result.should.have.length(6);
@@ -845,18 +863,10 @@
});
});
it("should not flag Tidy's smart auto-fixup of paired unclosed 
formatting tags where Tidy won't do it", function() {
-   return parseWT('foo \nfoo x 
').then(function(result) {
-   result.forEach(function(r) {
-   r.should.not.have.a.property("type", 
"multiple-unclosed-formatting-tags");
-   });
-   });
+ 

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Comment out unused linter category

2017-12-15 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398517 )

Change subject: Linter: Comment out unused linter category
..

Linter: Comment out unused linter category

Change-Id: I36fa0f62959aa5044e9bcb56a3dd9c747fdffef9
---
M lib/wt2html/pp/handlers/linter.js
1 file changed, 2 insertions(+), 0 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index db43032..e13d4ac 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -394,6 +394,7 @@
}
}
 
+   /* TODO: not sure if this is useful / valid at all. Suppress 
for now.
if (DU.hasLiteralHTMLMarker(dp) &&
dp.autoInsertedStart === true &&
(tplInfo ||  dsr[3] > 0)) {
@@ -403,6 +404,7 @@
};
env.log('lint/missing-start-tag', lintObj);
}
+   */
}
 }
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I36fa0f62959aa5044e9bcb56a3dd9c747fdffef9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: WIP: Remove false positives from multiline-table-in-list cat...

2017-12-14 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398418 )

Change subject: WIP: Remove false positives from multiline-table-in-list 
category
..

WIP: Remove false positives from multiline-table-in-list category

Change-Id: If633fc34584bde6a7f13ba903a563026fd304272
---
M lib/wt2html/pp/handlers/linter.js
1 file changed, 10 insertions(+), 1 deletion(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index f06ad79..a1cee92 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -862,10 +862,19 @@
detectMultipleUnclosedFormattingTags(lints);
 }
 
+function hasListAncestor(node) {
+   while (node && node.nodeName !== 'LI') {
+   node = node.parentNode;
+   }
+
+   // If the list item comes from references content, ignore it
+   return node && 
!(/mw:Extension\/references/.test(node.parentNode.getAttribute('typeof')));
+}
+
 function logPHPParserBug(env, node, dp, tplInfo) {
if (!DU.isLiteralHTMLNode(node) ||
node.nodeName !== 'TABLE' ||
-   !DU.hasAncestorOfName(node, 'LI') ||
+   !hasListAncestor(node) ||
!/\n/.test(node.outerHTML)
) {
return;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If633fc34584bde6a7f13ba903a563026fd304272
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to ca206808 for deploy

2017-12-14 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398284 )

Change subject: Bump src to ca206808 for deploy
..

Bump src to ca206808 for deploy

Change-Id: Ic7b0d06ac087591bac537962edbe64b3f839e4d2
---
M src
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/84/398284/1

diff --git a/src b/src
index 741fc5d..ca20680 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit 741fc5dc0f683df8d81bc09843734dad966138bd
+Subproject commit ca206808bce54eda348382f8185ad79e934126bf

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7b0d06ac087591bac537962edbe64b3f839e4d2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: Update en/i18n message for multiple-unclosed-formatting-tags

2017-12-13 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398180 )

Change subject: Update en/i18n message for multiple-unclosed-formatting-tags
..

Update en/i18n message for multiple-unclosed-formatting-tags

* Looks like I missed other instances :(

Change-Id: If28d3127ca93af575d8b7c2b8e1539efde0639c2
---
M i18n/en.json
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/80/398180/1

diff --git a/i18n/en.json b/i18n/en.json
index e6a9b10..2ef9756 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -52,8 +52,8 @@
"linter-category-html5-misnesting-desc": "These misnested tags will 
behave differently in HTML5 compared to HTML4.",
"linter-category-tidy-font-bug": "Tidy bug affecting font tags wrapping 
links",
"linter-category-tidy-font-bug-desc": "Tidy moves these font tags 
inside links to change link colour",
-   "linter-category-multiple-unclosed-formatting-tags": "Multiple unclosed 
small or big tags",
-   "linter-category-multiple-unclosed-formatting-tags-desc": "These pages 
have multiple unclosed small or big tags",
+   "linter-category-multiple-unclosed-formatting-tags": "Multiple unclosed 
formatting tags",
+   "linter-category-multiple-unclosed-formatting-tags-desc": "These pages 
have multiple unclosed formatting tags",
"linter-category-unclosed-quotes-in-heading": "Unclosed quote in 
heading",
"linter-category-unclosed-quotes-in-heading-desc": "These pages have an 
unclosed quote in a heading, which then leaks out of the table of contents.",
"linter-category-multiline-html-table-in-list": "Multiline table in 
list",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If28d3127ca93af575d8b7c2b8e1539efde0639c2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Revert "Use a Set for trace/debug/dump flags."

2017-12-13 Thread Subramanya Sastry (Code Review)
Hello C. Scott Ananian, Sbailey, jenkins-bot, Arlolra,

I'd like you to do a code review.  Please visit

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

to review the following change.


Change subject: Revert "Use a Set for trace/debug/dump flags."
..

Revert "Use a Set for trace/debug/dump flags."

Looks like this breaks tracing - can revisit post deploy tomorrow.

This reverts commit fff22b4dd951faf3f1d521e46abe1a189633c28f.

Change-Id: I4d5a68cbb77e63aeebb951171e28722a195910f0
---
M bin/parserTests.js
M lib/html2wt/SelectiveSerializer.js
M lib/html2wt/WikitextSerializer.js
M lib/logger/ParsoidLogger.js
M lib/utils/Util.js
M lib/wt2html/DOMPostProcessor.js
M lib/wt2html/TokenTransformManager.js
M lib/wt2html/pp/processors/computeDSR.js
M lib/wt2html/pp/processors/wrapSections.js
M lib/wt2html/pp/processors/wrapTemplates.js
M lib/wt2html/tokenizer.js
M lib/wt2html/tt/TemplateHandler.js
12 files changed, 32 insertions(+), 32 deletions(-)


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

diff --git a/bin/parserTests.js b/bin/parserTests.js
index cab20f8..9fe93e6 100755
--- a/bin/parserTests.js
+++ b/bin/parserTests.js
@@ -367,7 +367,7 @@
}
 
if (this.env.conf.parsoid.dumpFlags &&
-   this.env.conf.parsoid.dumpFlags.has("dom:post-changes")) {
+   this.env.conf.parsoid.dumpFlags.indexOf("dom:post-changes") !== 
-1) {
DU.dumpDOM(body, 'Original DOM');
}
 
@@ -382,7 +382,7 @@
}
 
if (this.env.conf.parsoid.dumpFlags &&
-   this.env.conf.parsoid.dumpFlags.has("dom:post-changes")) {
+   this.env.conf.parsoid.dumpFlags.indexOf("dom:post-changes") !== 
-1) {
console.warn("Change tree : " + JSON.stringify(item.changes));
DU.dumpDOM(body, 'Edited DOM');
}
diff --git a/lib/html2wt/SelectiveSerializer.js 
b/lib/html2wt/SelectiveSerializer.js
index 0844c8a..66f286d 100644
--- a/lib/html2wt/SelectiveSerializer.js
+++ b/lib/html2wt/SelectiveSerializer.js
@@ -30,7 +30,7 @@
 
// Debug options
this.trace = this.env.conf.parsoid.traceFlags &&
-   this.env.conf.parsoid.traceFlags.has("selser");
+   (this.env.conf.parsoid.traceFlags.indexOf("selser") !== 
-1);
 
// Performance Timing option
this.metrics = this.env.conf.parsoid.metrics;
@@ -97,7 +97,7 @@
p = Promise.resolve(this.env.page.src);
} else {
if (this.trace || (this.env.conf.parsoid.dumpFlags &&
-   
this.env.conf.parsoid.dumpFlags.has('dom:post-dom-diff'))) {
+   
this.env.conf.parsoid.dumpFlags.indexOf('dom:post-dom-diff') !== -1)) {
DU.dumpDOM(body, 'DOM after running DOMDiff', {
storeDiffMark: true,
env: this.env,
diff --git a/lib/html2wt/WikitextSerializer.js 
b/lib/html2wt/WikitextSerializer.js
index 0e8ac71..bdaba5e 100644
--- a/lib/html2wt/WikitextSerializer.js
+++ b/lib/html2wt/WikitextSerializer.js
@@ -1429,7 +1429,7 @@
(new Normalizer(state)).normalizeDOM(body);
 
var psd = this.env.conf.parsoid;
-   if (psd.dumpFlags && psd.dumpFlags.has("dom:post-normal")) {
+   if (psd.dumpFlags && (psd.dumpFlags.indexOf("dom:post-normal") !== -1)) 
{
DU.dumpDOM(body, 'DOM: post-normal');
}
 
diff --git a/lib/logger/ParsoidLogger.js b/lib/logger/ParsoidLogger.js
index d44690d..63b2db4 100644
--- a/lib/logger/ParsoidLogger.js
+++ b/lib/logger/ParsoidLogger.js
@@ -90,9 +90,13 @@
// TRACE / DEBUG: Make trace / debug regexp with appropriate postfixes,
// depending on the command-line options passed in.
function buildTraceOrDebugFlag(parsoidFlags, logType) {
-   var escapedFlags = 
Array.from(parsoidFlags).map(Util.escapeRegExp);
-   var combinedFlag = logType + "\/(" + escapedFlags.join("|") + 
")(\\/|$)";
-   return new RegExp(combinedFlag);
+   if (Array.isArray(parsoidFlags)) {
+   var escapedFlags = parsoidFlags.map(Util.escapeRegExp);
+   var combinedFlag = logType + "\/(" + 
escapedFlags.join("|") + ")(\\/|$)";
+   return new RegExp(combinedFlag);
+   } else {
+   return null;
+   }
}
 
// Register separate backend for tracing / debugging events.
diff --git a/lib/utils/Util.js b/lib/utils/Util.js
index 0ca4085..f8cbc7e 100644
--- a/lib/utils/Util.js
+++ b/lib/utils/Util.js
@@ -79,12 +79,8 @@
console.warn("Warning: Generic tracing is no 
longer supported. Ignoring --trace flag. Please provide handler-specific 
tracing flags, e.g. '--trace pre,html5', to 

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: WIP: If a section is both psuedo and in a tpl, assign it -2, ...

2017-12-13 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398113 )

Change subject: WIP: If a section is both psuedo and in a tpl, assign it -2, 
not -1
..

WIP: If a section is both psuedo and in a tpl, assign it -2, not -1

Most a RFC patch.

Change-Id: I423fbaee3e18ff598837a97ccb7100bf8b57e5ac
---
M lib/wt2html/pp/processors/wrapSections.js
1 file changed, 3 insertions(+), 3 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/wrapSections.js 
b/lib/wt2html/pp/processors/wrapSections.js
index f453d23..ab25dc5 100644
--- a/lib/wt2html/pp/processors/wrapSections.js
+++ b/lib/wt2html/pp/processors/wrapSections.js
@@ -66,10 +66,10 @@
 *
 * The code here handles uneditable sections because of templating.
 */
-   if (state.inTemplate) {
-   section.container.setAttribute('data-mw-section-id', -1);
-   } else if (pseudoSection) {
+   if (pseudoSection) {
section.container.setAttribute('data-mw-section-id', -2);
+   } else if (state.inTemplate) {
+   section.container.setAttribute('data-mw-section-id', -1);
} else {
section.container.setAttribute('data-mw-section-id', 
state.sectionNumber);
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I423fbaee3e18ff598837a97ccb7100bf8b57e5ac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: WIP: T182793: Handle extension <-> section boundary conflicts

2017-12-13 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398077 )

Change subject: WIP: T182793: Handle extension <-> section boundary conflicts
..

WIP: T182793: Handle extension <-> section boundary conflicts

This seems to eliminate crashers on a number of pages
but, wt2wt will not be clean if section tags are preserved.
Right now, this is not a concern since we are stripping
section tags in our html2wt code paths.

Both the tpl and ext expansion feels ugly but in the presence of
unbalanced content, unclear what other solutions exist.

Change-Id: Idb1f793a315fb5e068a0f520d0f3297f3b3ff9ef
---
M lib/wt2html/pp/processors/wrapSections.js
1 file changed, 27 insertions(+), 14 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/wrapSections.js 
b/lib/wt2html/pp/processors/wrapSections.js
index 73f9b89..7108784 100644
--- a/lib/wt2html/pp/processors/wrapSections.js
+++ b/lib/wt2html/pp/processors/wrapSections.js
@@ -155,7 +155,7 @@
// are in different sections! This might require 
resolution.
if (currSection !== tplInfo.firstSection) {
tplInfo.lastSection = currSection;
-   state.templatesToExamine.push(tplInfo);
+   state.tplsAndExtsToExamine.push(tplInfo);
}
 
tplInfo = null;
@@ -196,8 +196,8 @@
return -1;
 }
 
-function resolveTemplateSectionConflicts(state) {
-   state.templatesToExamine.forEach(function(tplInfo) {
+function resolveTplExtSectionConflicts(state) {
+   state.tplsAndExtsToExamine.forEach(function(tplInfo) {
var s1 = tplInfo.firstSection && 
tplInfo.firstSection.container; // could be undefined
var s2 = tplInfo.lastSection.container; // guaranteed to be 
non-null
 
@@ -227,7 +227,11 @@
tplDsr = DU.getDataParsoid(tplInfo.first).dsr;
var tplEndOffset = tplDsr[1];
dmw = DU.getDataMw(tplInfo.first);
-   dmw.parts.push(state.getSrc(tplEndOffset, 
newTplEndOffset));
+   if 
(/mw:Transclusion/.test(tplInfo.first.getAttribute('typeof'))) {
+   
dmw.parts.push(state.getSrc(tplEndOffset, newTplEndOffset));
+   } else { /* extension */
+   dmw.body.extsrc = dmw.body.extsrc + 
state.getSrc(tplEndOffset, newTplEndOffset);
+   }
// Update DSR
tplDsr[1] = newTplEndOffset;
 
@@ -267,14 +271,21 @@
var tplDP = DU.getDataParsoid(tplInfo.first);
tplDsr = tplDP.dsr;
dmw = Util.clone(DU.getDataMw(tplInfo.first));
-   dmw.parts.unshift(state.getSrc(dsr1, tplDsr[0]));
-   dmw.parts.push(state.getSrc(tplDsr[1], dsr2));
-   DU.setDataMw(newS1, dmw);
-   newS1.setAttribute('typeof', 'mw:Transclusion');
-   // Copy the template's parts-information object
-   // which has white-space information for formatting
-   // the transclusion and eliminates dirty-diffs.
-   DU.setDataParsoid(newS1, { pi: tplDP.pi, dsr: [ dsr1, 
dsr2 ] });
+   if 
(/mw:Transclusion/.test(tplInfo.first.getAttribute('typeof'))) {
+   dmw.parts.unshift(state.getSrc(dsr1, 
tplDsr[0]));
+   dmw.parts.push(state.getSrc(tplDsr[1], dsr2));
+   DU.setDataMw(newS1, dmw);
+   newS1.setAttribute('typeof', 'mw:Transclusion');
+   // Copy the template's parts-information object
+   // which has white-space information for 
formatting
+   // the transclusion and eliminates dirty-diffs.
+   DU.setDataParsoid(newS1, { pi: tplDP.pi, dsr: [ 
dsr1, dsr2 ] });
+   } else { /* extension */
+   dmw.body.extsrc = state.getSrc(dsr1, tplDsr[0]) 
+ dmw.body.extsrc + state.getSrc(tplDsr[1], dsr2);
+   DU.setDataMw(newS1, dmw);
+   newS1.setAttribute('typeof', 
tplInfo.first.getAttribute('typeof'));
+   DU.setDataParsoid(newS1, { dsr: [ dsr1, dsr2 ] 
});
+   }
}
});
 }
@@ -283,6 +294,8 @@
if (!atTopLevel || !env.wrapSections) {
return;
}
+
+   

[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to 741fc5dc for deploy

2017-12-12 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397868 )

Change subject: Bump src to 741fc5dc for deploy
..

Bump src to 741fc5dc for deploy

Change-Id: I044e4c9b17846c7a4f8a89589dedca427aff1c50
---
M src
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/68/397868/1

diff --git a/src b/src
index 01c1fc3..741fc5d 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit 01c1fc33c15cec32871b5440d7d6b7a57a53a225
+Subproject commit 741fc5dc0f683df8d81bc09843734dad966138bd

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I044e4c9b17846c7a4f8a89589dedca427aff1c50
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: Update en/i18n message for multiple-unclosed-formatting-tags

2017-12-11 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/397705 )

Change subject: Update en/i18n message for multiple-unclosed-formatting-tags
..

Update en/i18n message for multiple-unclosed-formatting-tags

* On the Parsoid side, we update the use of this linter category
  for more than small and big tags.

Change-Id: I55ac9e3cc16135ac4e353a03d4d9223a599b58b8
---
M i18n/en.json
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/05/397705/1

diff --git a/i18n/en.json b/i18n/en.json
index c25c1b5..e6a9b10 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -22,7 +22,7 @@
"linter-pager-tidy-whitespace-bug-details": "Tidy whitespace bug",
"linter-pager-html5-misnesting-details": "Misnesting in HTML5 (but not 
in Tidy)",
"linter-pager-tidy-font-bug-details": "Font tag changes link color in 
Tidy but won't in HTML5",
-   "linter-pager-multiple-unclosed-formatting-tags-details": "Multiple 
unclosed small or big tags on the page",
+   "linter-pager-multiple-unclosed-formatting-tags-details": "Multiple 
unclosed formatting tags on the page",
"linter-pager-unclosed-quotes-in-heading-details": "Unclosed quote 
which leaks out of the table of contents",
"linter-pager-multiline-html-table-in-list-details": "Multiline HTML5 
table inside a list, rendered differently in HTML5 and Tidy",
"linter-pager-misc-tidy-replacement-issues-details": "Miscellaneous 
markup errors affecting Tidy replacement",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I55ac9e3cc16135ac4e353a03d4d9223a599b58b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Tweak multiple-unclosed-formatting-tags category

2017-12-08 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/396550 )

Change subject: Linter: Tweak multiple-unclosed-formatting-tags category
..

Linter: Tweak multiple-unclosed-formatting-tags category

* itwiki folks flagged a new Tidy fixup that Remex (and Parsoid)
  won't do. Thankfully, it falls under an existing linter category
  we added.

* Added new mocha tests to spec behaviour.

Change-Id: I29bfdd3652a87c9d61bde14ab88dbd86a155e5e7
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 58 insertions(+), 0 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 7ccc5d4..8bd556b 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -251,6 +251,36 @@
 }
 
 /*
+ * For formatting tags, Tidy seems to be doing this "smart" fixup of
+ * unclosed tags by looking for matching unclosed pairs of identical tags
+ * and if the content ends in non-whitespace text, it treats the second
+ * unclosed opening tag as a closing tag. But, a HTML5 parser won't do this.
+ * So, detect this pattern and flag for linter fixup.
+ */
+function matchedOpenTagPairExists(c, dp) {
+   if (!Consts.HTML.FormattingTags.has(c.nodeName)) {
+   return false;
+   }
+
+   var lc = c.lastChild;
+   if (!lc || lc.nodeName !== c.nodeName) {
+   return false;
+   }
+
+   var lcDP = DU.getDataParsoid(lc);
+   if (!lcDP.autoInsertedEnd || lcDP.stx !== dp.stx) {
+   return false;
+   }
+
+   var prev = lc.previousSibling;
+   if (DU.isText(prev) && !/\s$/.test(prev.data)) {
+   return true;
+   }
+
+   return false;
+}
+
+/*
  * Log Treebuilder fixups marked by dom.markTreeBuilderFixup.js
  * It handles the following scenarios:
  *
@@ -353,6 +383,9 @@
env.log('lint/misnested-tag', lintObj);
} else if (!endTagOptional(c)) {
env.log('lint/missing-end-tag', 
lintObj);
+   if (matchedOpenTagPairExists(c, dp)) {
+   
env.log('lint/multiple-unclosed-formatting-tags', lintObj);
+   }
}
}
}
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index ef68e54..d57e142 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -833,6 +833,31 @@
result[4].params.should.have.a.property("name", 
"small");
});
});
+   it("should detect Tidy's smart auto-fixup of paired unclosed 
formatting tags", function() {
+   return parseWT('foo\nfoo x 
bar').then(function(result) {
+   result.should.have.length(6);
+   result[0].should.have.a.property("type", 
"missing-end-tag");
+   result[1].should.have.a.property("type", 
"multiple-unclosed-formatting-tags");
+   result[1].params.should.have.a.property("name", 
"b");
+   result[3].should.have.a.property("type", 
"missing-end-tag");
+   result[4].should.have.a.property("type", 
"multiple-unclosed-formatting-tags");
+   result[4].params.should.have.a.property("name", 
"code");
+   });
+   });
+   it("should not flag Tidy's smart auto-fixup of paired unclosed 
formatting tags where Tidy won't do it", function() {
+   return parseWT('foo \nfoo x 
').then(function(result) {
+   result.forEach(function(r) {
+   r.should.not.have.a.property("type", 
"multiple-unclosed-formatting-tags");
+   });
+   });
+   });
+   it("should not flag Tidy's smart auto-fixup of paired unclosed 
tags for non-formatting tags", function() {
+   return parseWT('foo\nfoo 
x bar').then(function(result) {
+   result.forEach(function(r) {
+   r.should.not.have.a.property("type", 
"multiple-unclosed-formatting-tags");
+   });
+   });
+   });
});
describe('MISC TIDY REPLACEMENT ISSUES', function() {
describe('Unclosed wikitext i/b in headings', function() {

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

Gerrit-Mes

[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: WIP: Create new high priority linter categories

2017-12-07 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/396105 )

Change subject: WIP: Create new high priority linter categories
..

WIP: Create new high priority linter categories

* Some things need to be clarified on the Parsoid end about whether
  we want multiple categories or if a catch-all category is okay.

Change-Id: If21a22b7f1d8d582c92af13d60261c97502fbe48
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/CategoryManager.php
M includes/LintErrorsPager.php
5 files changed, 29 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/05/396105/1

diff --git a/extension.json b/extension.json
index 566ef08..b48f927 100644
--- a/extension.json
+++ b/extension.json
@@ -121,6 +121,16 @@
"enabled": true,
"priority": "high",
"parser-migration": true
+   },
+   "multiple-unclosed-formatting-tags": {
+   "enabled": true,
+   "priority": "high",
+   "parser-migration": true
+   },
+   "misc-tidy-replacement-issues": {
+   "enabled": true,
+   "priority": "high",
+   "parser-migration": true
}
},
"LinterSubmitterWhitelist": {
diff --git a/i18n/en.json b/i18n/en.json
index 2c0909f..a9e2a3b 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -22,6 +22,8 @@
"linter-pager-tidy-whitespace-bug-details": "Tidy whitespace bug",
"linter-pager-html5-misnesting-details": "Misnesting in HTML5 (but not 
in Tidy)",
"linter-pager-tidy-font-bug-details": "Font tag changes link color in 
Tidy but won't in HTML5",
+   "linter-pager-multiple-unclosed-formatting-tags": "Multiple unclosed 
small/big tags on the page",
+   "linter-pager-misc-tidy-replacement-issues": "Miscellaneous markup 
errors affecting Tidy replacement",
"linter-category-fostered": "Fostered content",
"linter-category-fostered-desc": "These pages have fostered content.",
"linter-category-obsolete-tag": "Obsolete HTML tags",
@@ -48,6 +50,10 @@
"linter-category-html5-misnesting-desc": "These misnested tags will 
behave differently in HTML5 compared to HTML4.",
"linter-category-tidy-font-bug": "Tidy bug affecting font tags wrapping 
links",
"linter-category-tidy-font-bug-desc": "Tidy moves these font tags 
inside links to change link colour",
+   "linter-category-multiple-unclosed-formatting-tags": "Multiple unclosed 
small/big tags",
+   "linter-category-multiple-unclosed-formatting-tags-desc": "These pages 
have multiple unclosed small/big tags",
+   "linter-category-misc-tidy-replacement-issues": "Miscellaneous Tidy 
replacement issues",
+   "linter-category-misc-tidy-replacement-issues-desc": "These pages have 
other issues that affect rendering when Tidy is removed",
"linter-numerrors": "($1 {{PLURAL:$1|error|errors}})",
"linter-page-title-edit": "$1 ($2)",
"linter-page-edit": "edit",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 58212e4..5f2b44d 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -26,6 +26,8 @@
"linter-pager-tidy-whitespace-bug-details": "Table column heading. 
\"Tidy\" is a name of a software package that transforms HTML files, so it 
doesn't have to be translated. For information about the bug, see the commit 
message https://gerrit.wikimedia.org/r/#/c/371068 .",
"linter-pager-html5-misnesting-details": "Table column heading.",
"linter-pager-tidy-font-bug-details": "Table column heading. Don't 
translate \"font\".",
+   "linter-pager-multiple-unclosed-formatting-tags-details": "Table column 
heading.",
+   "linter-pager-misc-tidy-replacement-issues-details": "Table column 
heading.",
"linter-category-fostered": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/fostered]]",
"linter-category-fostered-desc": "Description of category.",
"linter-category-obsolete-tag": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/obsolete-tag]]",
@@ -52,6 +54,10 @@
"linter-category-html5-misnesting-desc": "Description of category",
"linter-category-tidy-font-bug": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/tidy-font-bug]]. Don't translate \"font\".",
"linter-category-tidy-font-bug-desc": "Description of category",
+   "linter-category-multiple-unclosed-formatting-tags": "Name of lint 
error category. See 
[[:mw:Help:Extension:Linter/multiple-unclosed-formatting-tags]]",
+   "linter-category-multiple-unclosed-formatting-tags-desc": "Description 

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Enable missing-end-tag detection for quotes

2017-12-07 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/396057 )

Change subject: Linter: Enable missing-end-tag detection for quotes
..

Linter: Enable missing-end-tag detection for quotes

* We had suppressed this from the beginning, but looks like some
  editors want it.

Change-Id: I5d2542ed0760043560c2d5c5a2c618f6cd6ba223
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 10 insertions(+), 1 deletion(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 2c1b748..c9f8a85 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -352,7 +352,7 @@
}
adjDp.tmp.linted = true;
env.log('lint/misnested-tag', lintObj);
-   } else if (DU.hasLiteralHTMLMarker(dp) && 
!endTagOptional(c)) {
+   } else if (!endTagOptional(c)) {
env.log('lint/missing-end-tag', 
lintObj);
}
}
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index f9fa0ff..b29fe51 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -56,6 +56,15 @@
result[0].params.should.have.a.property("name", 
"div");
});
});
+   it('should lint missing end tags for quotes correctly', 
function() {
+   return parseWT("'''foo").then(function(result) {
+   result.should.have.length(1);
+   result[0].should.have.a.property("type", 
"missing-end-tag");
+   result[0].dsr.should.deep.equal([ 0, 6, 3, 0 ]);
+   result[0].should.have.a.property("params");
+   result[0].params.should.have.a.property("name", 
"b");
+   });
+   });
it('should lint missing end tags found in transclusions 
correctly', function() {
return 
parseWT('{{1x|foobar}}').then(function(result) {
result.should.have.length(1);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d2542ed0760043560c2d5c5a2c618f6cd6ba223
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: WIP: Create catchall misc-tidy-replacement-issues linter cat...

2017-12-06 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395782 )

Change subject: WIP: Create catchall misc-tidy-replacement-issues linter 
category
..

WIP: Create catchall misc-tidy-replacement-issues linter category

* Quick POC to judge reception
* Will throw a bunch of assorted issues into this category

Change-Id: Ie4bed59ecba3104586be6372cf8946b9d41b5fd4
---
M lib/utils/DOMUtils.js
M lib/wt2html/pp/handlers/linter.js
2 files changed, 6 insertions(+), 0 deletions(-)


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

diff --git a/lib/utils/DOMUtils.js b/lib/utils/DOMUtils.js
index aad5b46..e2aad3f 100644
--- a/lib/utils/DOMUtils.js
+++ b/lib/utils/DOMUtils.js
@@ -80,6 +80,10 @@
return node && Consts.WTQuoteTags.has(node.nodeName);
},
 
+   isHeadingElt: function(node) {
+   return node && /^H[1-6]$/.test(node.nodeName);
+   },
+
isZeroWidthWikitextElt: function(node) {
return Consts.ZeroWidthWikitextTags.has(node.nodeName) &&
!this.isLiteralHTMLNode(node);
diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index bbec33d..a546392 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -331,6 +331,8 @@
!hasIdenticalNestedTag(c, c.nodeName)
) {
env.log('lint/html5-misnesting', lintObj);
+   } else if (!DU.hasLiteralHTMLMarker(dp) && 
DU.isQuoteElt(c) && DU.isHeadingElt(c.parentNode)) {
+   env.log('lint/misc-tidy-replacement-issues', 
lintObj);
} else {
var adjNode = getNextMatchingNode(c, c);
if (adjNode) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie4bed59ecba3104586be6372cf8946b9d41b5fd4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: WIP: T182170: Linter: Detect multiple-unclosed-formatting-ta...

2017-12-05 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395689 )

Change subject: WIP: T182170: Linter: Detect multiple-unclosed-formatting-tag 
linter errors
..

WIP: T182170: Linter: Detect multiple-unclosed-formatting-tag linter errors

* Quick POC.
* Need tests + discussing if this is the best approach.
* Works on itwiki:Hubert_H._Humphrey_Metrodome

---
[info/lint/multiple-unclosed-formatting-tag][itwiki/Hubert_H._Humphrey_Metrodome?oldid=93017491]
{"type":"multiple-unclosed-formatting-tag","params":{"name":"small"},"dsr":[4999,5046,7,0]}
---

Change-Id: I334738c77b3677b59c91792b9dc2e7ec8fa829e5
---
M lib/logger/LintLogger.js
1 file changed, 29 insertions(+), 0 deletions(-)


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

diff --git a/lib/logger/LintLogger.js b/lib/logger/LintLogger.js
index 89f1c6e..0114d0a 100644
--- a/lib/logger/LintLogger.js
+++ b/lib/logger/LintLogger.js
@@ -36,6 +36,35 @@
console.assert(false, 'Why are we here? Linting is 
disabled.');
}
 
+   var firstUnclosedTag = {
+   small: null,
+   big: null,
+   };
+   var multiUnclosedTagName = null;
+   enabledBuffer.filter(function(item) {
+   if (item.type === 'missing-end-tag') {
+   if (item.params.name === 'small' || 
item.params.name === 'big') {
+   var tagName = item.params.name;
+   if (!firstUnclosedTag[tagName]) {
+   firstUnclosedTag[tagName] = 
item;
+   } else {
+   multiUnclosedTagName = tagName;
+   return true;
+   }
+   }
+   }
+   return false;
+   });
+   if (multiUnclosedTagName) {
+   var item = firstUnclosedTag[multiUnclosedTagName];
+   enabledBuffer.push({
+   type: 'multiple-unclosed-formatting-tag',
+   params: item.params,
+   dsr: item.dsr,
+   templateInfo: item.templateInfo,
+   });
+   }
+
this.buffer = [];
 
if (env.page.id % env.conf.parsoid.linter.apiSampling !== 0) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I334738c77b3677b59c91792b9dc2e7ec8fa829e5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: s/RemexHTML/RemexHtml

2017-12-05 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395675 )

Change subject: s/RemexHTML/RemexHtml
..

s/RemexHTML/RemexHtml

Change-Id: I4a62b8723aba07e8fcf58ca9547d3a96297d44c6
---
M wmf-config/InitialiseSettings.php
1 file changed, 172 insertions(+), 172 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/75/395675/1

diff --git a/wmf-config/InitialiseSettings.php 
b/wmf-config/InitialiseSettings.php
index 78d7519..433eb8e 100644
--- a/wmf-config/InitialiseSettings.php
+++ b/wmf-config/InitialiseSettings.php
@@ -19228,178 +19228,178 @@
'dewiki' => [ 'driver' => 'RemexHtml' ], // T181188
'itwiki' => [ 'driver' => 'RemexHtml' ], // T181190
 
-   // T182042: Enable RemexHTML on wikis with zero high-priority linter 
errors
-   'alswikiquote' => [ 'driver' => 'RemexHTML' ],
-   'alswiktionary' => [ 'driver' => 'RemexHTML' ],
-   'angwikisource' => [ 'driver' => 'RemexHTML' ],
-   'astwikibooks' => [ 'driver' => 'RemexHTML' ],
-   'astwikiquote' => [ 'driver' => 'RemexHTML' ],
-   'aswikibooks' => [ 'driver' => 'RemexHTML' ],
-   'aswiktionary' => [ 'driver' => 'RemexHTML' ],
-   'avwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'aywikibooks' => [ 'driver' => 'RemexHTML' ],
-   'bawikibooks' => [ 'driver' => 'RemexHTML' ],
-   'bhwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'biwikibooks' => [ 'driver' => 'RemexHTML' ],
-   'biwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'bmwikibooks' => [ 'driver' => 'RemexHTML' ],
-   'bmwikiquote' => [ 'driver' => 'RemexHTML' ],
-   'bmwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'bowikibooks' => [ 'driver' => 'RemexHTML' ],
-   'bowiktionary' => [ 'driver' => 'RemexHTML' ],
-   'chowiki' => [ 'driver' => 'RemexHTML' ],
-   'chrwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'chwikibooks' => [ 'driver' => 'RemexHTML' ],
-   'chwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'cowikibooks' => [ 'driver' => 'RemexHTML' ],
-   'cowikiquote' => [ 'driver' => 'RemexHTML' ],
-   'crwikiquote' => [ 'driver' => 'RemexHTML' ],
-   'crwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'csbwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'cswikibooks' => [ 'driver' => 'RemexHTML' ],
-   'cswikinews' => [ 'driver' => 'RemexHTML' ],
-   'cswikiquote' => [ 'driver' => 'RemexHTML' ],
-   'dinwiki' => [ 'driver' => 'RemexHTML' ],
-   'donatewiki' => [ 'driver' => 'RemexHTML' ],
-   'dzwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'elwikinews' => [ 'driver' => 'RemexHTML' ],
-   'eowikiquote' => [ 'driver' => 'RemexHTML' ],
-   'fjwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'fowiktionary' => [ 'driver' => 'RemexHTML' ],
-   'gawikibooks' => [ 'driver' => 'RemexHTML' ],
-   'gawikiquote' => [ 'driver' => 'RemexHTML' ],
-   'gdwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'gnwikibooks' => [ 'driver' => 'RemexHTML' ],
-   'gnwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'gotwikibooks' => [ 'driver' => 'RemexHTML' ],
-   'guwikibooks' => [ 'driver' => 'RemexHTML' ],
-   'hifwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'hiwikivoyage' => [ 'driver' => 'RemexHTML' ],
-   'howiki' => [ 'driver' => 'RemexHTML' ],
-   'htwikisource' => [ 'driver' => 'RemexHTML' ],
-   'huwikinews' => [ 'driver' => 'RemexHTML' ],
-   'hzwiki' => [ 'driver' => 'RemexHTML' ],
-   'iawiktionary' => [ 'driver' => 'RemexHTML' ],
-   'iewikibooks' => [ 'driver' => 'RemexHTML' ],
-   'iiwiki' => [ 'driver' => 'RemexHTML' ],
-   'ikwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'iswikisource' => [ 'driver' => 'RemexHTML' ],
-   'iuwiki' => [ 'driver' => 'RemexHTML' ],
-   'jamwiki' => [ 'driver' => 'RemexHTML' ],
-   'kbpwiki' => [ 'driver' => 'RemexHTML' ],
-   'kiwiki' => [ 'driver' => 'RemexHTML' ],
-   'kjwiki' => [ 'driver' => 'RemexHTML' ],
-   'kkwikiquote' => [ 'driver' => 'RemexHTML' ],
-   'kkwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'knwikibooks' => [ 'driver' => 'RemexHTML' ],
-   'krwiki' => [ 'driver' => 'RemexHTML' ],
-   'krwikiquote' => [ 'driver' => 'RemexHTML' ],
-   'kswikibooks' => [ 'driver' => 'RemexHTML' ],
-   'kswikiquote' => [ 'driver' => 'RemexHTML' ],
-   'kwwikiquote' => [ 'driver' => 'RemexHTML' ],
-   'ladwiki' => [ 'driver' => 'RemexHTML' ],
-   'lawiki' => [ 'driver' => 'RemexHTML' ],
-   'lawikibooks' => [ 'driver' => 'RemexHTML' ],
-   'lawikiquote' => [ 'driver' => 'RemexHTML' ],
-   'lbwiki' => [ 'driver' => 'RemexHTML' ],
-   'lbwikibooks' => [ 'driver' => 'RemexHTML' ],
-   'lbwikiquote' => [ 'driver' => 'RemexHTML' ],
-   'lbwiktionary' => [ 'driver' => 'RemexHTML' ],
-   'lnwikibooks' 

[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: Enable RemexHTML on wikis with zero high priority linter errors

2017-12-04 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395139 )

Change subject: Enable RemexHTML on wikis with zero high priority linter errors
..

Enable RemexHTML on wikis with zero high priority linter errors

Bug: T182042

Change-Id: I2012dbf8215ec7dec35b19cd68eac4ce56f5910f
---
M wmf-config/InitialiseSettings.php
1 file changed, 173 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/39/395139/1

diff --git a/wmf-config/InitialiseSettings.php 
b/wmf-config/InitialiseSettings.php
index a6b1634..78d7519 100644
--- a/wmf-config/InitialiseSettings.php
+++ b/wmf-config/InitialiseSettings.php
@@ -19227,6 +19227,179 @@
'nowiki' => [ 'driver' => 'RemexHtml' ], // T177989
'dewiki' => [ 'driver' => 'RemexHtml' ], // T181188
'itwiki' => [ 'driver' => 'RemexHtml' ], // T181190
+
+   // T182042: Enable RemexHTML on wikis with zero high-priority linter 
errors
+   'alswikiquote' => [ 'driver' => 'RemexHTML' ],
+   'alswiktionary' => [ 'driver' => 'RemexHTML' ],
+   'angwikisource' => [ 'driver' => 'RemexHTML' ],
+   'astwikibooks' => [ 'driver' => 'RemexHTML' ],
+   'astwikiquote' => [ 'driver' => 'RemexHTML' ],
+   'aswikibooks' => [ 'driver' => 'RemexHTML' ],
+   'aswiktionary' => [ 'driver' => 'RemexHTML' ],
+   'avwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'aywikibooks' => [ 'driver' => 'RemexHTML' ],
+   'bawikibooks' => [ 'driver' => 'RemexHTML' ],
+   'bhwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'biwikibooks' => [ 'driver' => 'RemexHTML' ],
+   'biwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'bmwikibooks' => [ 'driver' => 'RemexHTML' ],
+   'bmwikiquote' => [ 'driver' => 'RemexHTML' ],
+   'bmwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'bowikibooks' => [ 'driver' => 'RemexHTML' ],
+   'bowiktionary' => [ 'driver' => 'RemexHTML' ],
+   'chowiki' => [ 'driver' => 'RemexHTML' ],
+   'chrwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'chwikibooks' => [ 'driver' => 'RemexHTML' ],
+   'chwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'cowikibooks' => [ 'driver' => 'RemexHTML' ],
+   'cowikiquote' => [ 'driver' => 'RemexHTML' ],
+   'crwikiquote' => [ 'driver' => 'RemexHTML' ],
+   'crwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'csbwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'cswikibooks' => [ 'driver' => 'RemexHTML' ],
+   'cswikinews' => [ 'driver' => 'RemexHTML' ],
+   'cswikiquote' => [ 'driver' => 'RemexHTML' ],
+   'dinwiki' => [ 'driver' => 'RemexHTML' ],
+   'donatewiki' => [ 'driver' => 'RemexHTML' ],
+   'dzwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'elwikinews' => [ 'driver' => 'RemexHTML' ],
+   'eowikiquote' => [ 'driver' => 'RemexHTML' ],
+   'fjwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'fowiktionary' => [ 'driver' => 'RemexHTML' ],
+   'gawikibooks' => [ 'driver' => 'RemexHTML' ],
+   'gawikiquote' => [ 'driver' => 'RemexHTML' ],
+   'gdwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'gnwikibooks' => [ 'driver' => 'RemexHTML' ],
+   'gnwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'gotwikibooks' => [ 'driver' => 'RemexHTML' ],
+   'guwikibooks' => [ 'driver' => 'RemexHTML' ],
+   'hifwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'hiwikivoyage' => [ 'driver' => 'RemexHTML' ],
+   'howiki' => [ 'driver' => 'RemexHTML' ],
+   'htwikisource' => [ 'driver' => 'RemexHTML' ],
+   'huwikinews' => [ 'driver' => 'RemexHTML' ],
+   'hzwiki' => [ 'driver' => 'RemexHTML' ],
+   'iawiktionary' => [ 'driver' => 'RemexHTML' ],
+   'iewikibooks' => [ 'driver' => 'RemexHTML' ],
+   'iiwiki' => [ 'driver' => 'RemexHTML' ],
+   'ikwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'iswikisource' => [ 'driver' => 'RemexHTML' ],
+   'iuwiki' => [ 'driver' => 'RemexHTML' ],
+   'jamwiki' => [ 'driver' => 'RemexHTML' ],
+   'kbpwiki' => [ 'driver' => 'RemexHTML' ],
+   'kiwiki' => [ 'driver' => 'RemexHTML' ],
+   'kjwiki' => [ 'driver' => 'RemexHTML' ],
+   'kkwikiquote' => [ 'driver' => 'RemexHTML' ],
+   'kkwiktionary' => [ 'driver' => 'RemexHTML' ],
+   'knwikibooks' => [ 'driver' => 'RemexHTML' ],
+   'krwiki' => [ 'driver' => 'RemexHTML' ],
+   'krwikiquote' => [ 'driver' => 'RemexHTML' ],
+   'kswikibooks' => [ 'driver' => 'RemexHTML' ],
+   'kswikiquote' => [ 'driver' => 'RemexHTML' ],
+   'kwwikiquote' => [ 'driver' => 'RemexHTML' ],
+   'ladwiki' => [ 'driver' => 'RemexHTML' ],
+   'lawiki' => [ 'driver' => 'RemexHTML' ],
+   'lawikibooks' => [ 'driver' => 'RemexHTML' ],
+   'lawikiquote' => [ 'driver' => 'RemexHTML' ],
+   'lbwiki' => [ 'driver' => 'RemexHTML' ],
+   'lbwikibooks' => [ 'dri

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: lib/parse.js: Make wt2html and html2wt methods do what they say

2017-12-04 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395116 )

Change subject: lib/parse.js: Make wt2html and html2wt methods do what they say
..

lib/parse.js: Make wt2html and html2wt methods do what they say

Make wt2wt and html2html be external transformations on output
of those methods.

Made out.lint conditional on linting being enabled.

Change-Id: Ifa7150d9badcf5b558b3774185431ef1a1e4f7a0
---
M lib/parse.js
1 file changed, 39 insertions(+), 32 deletions(-)


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

diff --git a/lib/parse.js b/lib/parse.js
index b045dab..61a2fdb 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -8,7 +8,7 @@
 var DU = require('./utils/DOMUtils.js').DOMUtils;
 var Promise = require('./utils/promise.js');
 
-var wt2html, html2wt;
+var _wt2html, _html2wt;
 
 /**
  * Transform wikitext to html
@@ -23,7 +23,7 @@
  *   @return {String} return.contentmodel
  *   @return {Object} [return.pb] If pageBundle was requested
  */
-wt2html = function(obj, env, wt) {
+_wt2html = function(obj, env, wt) {
// `wt` will be `undefined` when we fetched page source and info,
// which we don't want to overwrite.
if (wt !== undefined) {
@@ -37,28 +37,25 @@
}
})
.then(function(doc) {
-   if (['wt2html', 'html2html'].includes(obj.mode)) {
-   var out;
-   if (env.pageBundle) {
-   out = DU.extractDpAndSerialize(obj.bodyOnly ? 
doc.body : doc, {
-   innerXML: obj.bodyOnly,
-   });
-   } else {
-   out = {
-   html: DU.toXML(obj.bodyOnly ? doc.body 
: doc, {
-   innerXML: obj.bodyOnly,
-   }),
-   };
-   }
-   out.lint = env.lintLogger.buffer;
-   if (env.conf.parsoid.linting) {
-   env.log("end/parse");
-   }
-   out.contentmodel = (obj.contentmodel || 
env.page.getContentModel());
-   return out;
+   var out;
+   if (env.pageBundle) {
+   out = DU.extractDpAndSerialize(obj.bodyOnly ? doc.body 
: doc, {
+   innerXML: obj.bodyOnly,
+   });
} else {
-   return html2wt(obj, env, DU.toXML(doc));
+   out = {
+   html: DU.toXML(obj.bodyOnly ? doc.body : doc, {
+   innerXML: obj.bodyOnly,
+   }),
+   };
}
+
+   if (env.conf.parsoid.linting) {
+   out.lint = env.lintLogger.buffer;
+   env.log("end/parse");
+   }
+   out.contentmodel = (obj.contentmodel || 
env.page.getContentModel());
+   return out;
});
 };
 
@@ -73,7 +70,7 @@
  * @return {Promise} Assuming we're ending at wt
  *   @return {String} return.wt
  */
-html2wt = function(obj, env, html, pb) {
+_html2wt = function(obj, env, html, pb) {
var useSelser = (obj.selser !== undefined);
var doc = DU.parseHTML(html);
pb = pb || DU.extractPageBundle(doc);
@@ -89,11 +86,7 @@
var handler = env.getContentHandler(obj.contentmodel);
return handler.fromHTML(env, doc.body, useSelser)
.then(function(out) {
-   if (['html2wt', 'wt2wt', 'selser'].includes(obj.mode)) {
-   return { wt: out };
-   } else {
-   return wt2html(obj, env, out);
-   }
+   return { wt: out };
});
 };
 
@@ -152,6 +145,7 @@
env.page.meta.revision.revid = obj.oldid;
}
 
+   var p;
if (['html2wt', 'html2html', 'selser'].includes(obj.mode)) {
// Selser
var selser = obj.selser;
@@ -171,8 +165,15 @@
throw new Error('this is broken');
}
}
-   return html2wt(obj, env, obj.input, obj.pb);
-   } else {
+   p = _html2wt(obj, env, obj.input, obj.pb);
+   if (obj.mode === 'html2html') {
+   return p.then(function(out) {
+   return _wt2html(obj, env, out.wt);
+   });
+   } else { /* html2wt, selser */
+   re

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: lib/parse.js: Move env initializations to relevant parsing p...

2017-12-04 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395096 )

Change subject: lib/parse.js: Move env initializations to relevant parsing paths
..

lib/parse.js: Move env initializations to relevant parsing paths

Change-Id: Ibb71ac279e8f3e67f487ee738ce9cfe92853e07a
---
M lib/parse.js
1 file changed, 29 insertions(+), 31 deletions(-)


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

diff --git a/lib/parse.js b/lib/parse.js
index 3128834..b045dab 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -145,45 +145,43 @@
return ParserEnv.getParserEnv(parsoidConfig, obj.envOptions)
.then(function(env) {
env.startTime = start;
-
-   // The content version to output
-   if (obj.contentVersion) {
-   env.setContentVersion(obj.contentVersion);
-   }
-
-   if (obj.reuseExpansions) {
-   env.cacheReusableExpansions(obj.reuseExpansions);
-   }
+   var s1 = Date.now();
+   env.bumpTimeUse("Setup Environment", s1 - start);
 
if (obj.oldid) {
env.page.meta.revision.revid = obj.oldid;
}
 
-   // Selser
-   var selser = obj.selser;
-   if (selser !== undefined) {
-   if (selser.oldtext !== null) {
-   env.setPageSrcInfo(selser.oldtext);
-   }
-   if (selser.oldhtml) {
-   env.page.dom = 
DU.parseHTML(selser.oldhtml).body;
-   }
-   if (selser.domdiff) {
-   // FIXME: need to load diff markers from 
attributes
-   env.page.domdiff = {
-   isEmpty: false,
-   dom: DU.ppToDOM(selser.domdiff),
-   };
-   throw new Error('this is broken');
-   }
-   }
-
-   var s1 = Date.now();
-   env.bumpTimeUse("Setup Environment", s1 - start);
-
if (['html2wt', 'html2html', 'selser'].includes(obj.mode)) {
+   // Selser
+   var selser = obj.selser;
+   if (selser !== undefined) {
+   if (selser.oldtext !== null) {
+   env.setPageSrcInfo(selser.oldtext);
+   }
+   if (selser.oldhtml) {
+   env.page.dom = 
DU.parseHTML(selser.oldhtml).body;
+   }
+   if (selser.domdiff) {
+   // FIXME: need to load diff markers 
from attributes
+   env.page.domdiff = {
+   isEmpty: false,
+   dom: DU.ppToDOM(selser.domdiff),
+   };
+   throw new Error('this is broken');
+   }
+   }
return html2wt(obj, env, obj.input, obj.pb);
} else {
+   // The content version to output
+   if (obj.contentVersion) {
+   env.setContentVersion(obj.contentVersion);
+   }
+
+   if (obj.reuseExpansions) {
+   
env.cacheReusableExpansions(obj.reuseExpansions);
+   }
+
var p;
if (obj.input === undefined) {
var target = env.normalizeAndResolvePageTitle();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb71ac279e8f3e67f487ee738ce9cfe92853e07a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Bump Parsoid HTML version to 1.6.0

2017-12-04 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395011 )

Change subject: Bump Parsoid HTML version to 1.6.0
..

Bump Parsoid HTML version to 1.6.0

Change-Id: I48ec581a03b26a7ead96747e2b13fe63de428d15
---
M bin/roundtrip-test.js
M lib/config/MWParserEnvironment.js
M tests/mocha/api.js
M tests/mocha/templatedata.js
4 files changed, 4 insertions(+), 4 deletions(-)


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

diff --git a/bin/roundtrip-test.js b/bin/roundtrip-test.js
index 2f97dda..76a544b 100755
--- a/bin/roundtrip-test.js
+++ b/bin/roundtrip-test.js
@@ -16,7 +16,7 @@
 
 var gzip = Promise.promisify(require('zlib').gzip, false);
 
-var defaultContentVersion = '1.5.0';
+var defaultContentVersion = '1.6.0';
 
 function displayDiff(type, count) {
var pad = (10 - type.length);  // Be positive!
diff --git a/lib/config/MWParserEnvironment.js 
b/lib/config/MWParserEnvironment.js
index 56861fb..d448823 100644
--- a/lib/config/MWParserEnvironment.js
+++ b/lib/config/MWParserEnvironment.js
@@ -746,7 +746,7 @@
  *
  * @property {Array} availableVersions
  */
-MWParserEnvironment.prototype.availableVersions = ['1.5.0', '2.0.0'];
+MWParserEnvironment.prototype.availableVersions = ['1.6.0', '2.0.0'];
 
 /**
  * The default content version that Parsoid will generate.
diff --git a/tests/mocha/api.js b/tests/mocha/api.js
index 4d2208a..14b4612 100644
--- a/tests/mocha/api.js
+++ b/tests/mocha/api.js
@@ -22,7 +22,7 @@
 parsoidOptions.useBatchAPI = true;
 parsoidOptions.linting = true;
 
-var defaultContentVersion = '1.5.0';
+var defaultContentVersion = '1.6.0';
 
 // section wrappers are a distraction from the main business of
 // this file which is to verify functionality of API end points
diff --git a/tests/mocha/templatedata.js b/tests/mocha/templatedata.js
index 0d81382..71c5a1d 100644
--- a/tests/mocha/templatedata.js
+++ b/tests/mocha/templatedata.js
@@ -17,7 +17,7 @@
 var parsoidOptions = yaml.load(optionsYaml).services[0].conf;
 
 var api, runner;
-var defaultContentVersion = '1.5.0';
+var defaultContentVersion = '1.6.0';
 var mockDomain = 'customwiki';
 
 function verifyTransformation(newHTML, origHTML, origWT, expectedWT, done, 
dpVersion) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I48ec581a03b26a7ead96747e2b13fe63de428d15
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: Enable RemexHTML on itwiki and dewiki

2017-12-04 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/395009 )

Change subject: Enable RemexHTML on itwiki and dewiki
..

Enable RemexHTML on itwiki and dewiki

Bug: T181188
Bug: T181190
Change-Id: Ifff519c41baf3958717970461ee1e9a79ab4d115
---
M wmf-config/InitialiseSettings.php
1 file changed, 4 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/09/395009/1

diff --git a/wmf-config/InitialiseSettings.php 
b/wmf-config/InitialiseSettings.php
index c3468c4..1f5104d 100644
--- a/wmf-config/InitialiseSettings.php
+++ b/wmf-config/InitialiseSettings.php
@@ -19216,13 +19216,13 @@
 
'mediawikiwiki' => [ 'driver' => 'RemexHtml' ],
'testwiki' => [ 'driver' => 'RemexHtml' ],
+   'eswikiversity' => [ 'driver' => 'RemexHtml' ],
+   'wikitech' => [ 'driver' => 'RemexHtml' ],
 
'fawiki' => [ 'driver' => 'RemexHtml' ], // T176150
'nowiki' => [ 'driver' => 'RemexHtml' ], // T177989
-
-   'eswikiversity' => [ 'driver' => 'RemexHtml' ],
-
-   'wikitech' => [ 'driver' => 'RemexHtml' ],
+   'dewiki' => [ 'driver' => 'RemexHtml' ], // T181188
+   'itwiki' => [ 'driver' => 'RemexHtml' ], // T181190
 ],
 
 // Cache ResourceLoader modules in localStorage

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifff519c41baf3958717970461ee1e9a79ab4d115
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Fix crasher in section <-> template conflict resolution code

2017-11-29 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/394242 )

Change subject: Fix crasher in section <-> template conflict resolution code
..

Fix crasher in section <-> template conflict resolution code

* In some scenarios, a section overlaps transclusion content
  partially where it starts somewhere after the start and
  goes all the way the end and extends beyond the transclusion
  boundary. This is better understood with the example below.

 
 a

 {{1x|
 b
 ==h2==
 c
 }}

 d
 

* In this context, in the conflict resolution code,
  tplInfo.firstSection will be undefined and was causing a crasher.

  This scenario needs to be handled identically to the case
  where s1 is an ancestor of s2.

* Added a new test case to cover this scenario.

Change-Id: I1fd22c781f3a37ae5fe91a643faee5287b2c0ada
---
M lib/wt2html/pp/processors/wrapSections.js
M tests/parserTests.txt
2 files changed, 55 insertions(+), 11 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/wrapSections.js 
b/lib/wt2html/pp/processors/wrapSections.js
index 829e4a5..7544779 100644
--- a/lib/wt2html/pp/processors/wrapSections.js
+++ b/lib/wt2html/pp/processors/wrapSections.js
@@ -23,6 +23,9 @@
container: state.doc.createElement('section'),
};
 
+   // console.log("NEW section @ " + node.nodeName + "; level: "
+   //  + newLevel + "; pseudo: " + pseudoSection + "; id: "+ 
section.debug_id);
+
/* Step 1. Get section stack to the right nesting level
 * 1a. Pop stack till we have a higher-level section.
 */
@@ -195,27 +198,31 @@
 
 function resolveTemplateSectionConflicts(state) {
state.templatesToExamine.forEach(function(tplInfo) {
-   var s1 = tplInfo.firstSection.container;
-   var s2 = tplInfo.lastSection.container;
+   var s1 = tplInfo.firstSection && 
tplInfo.firstSection.container; // could be undefined
+   var s2 = tplInfo.lastSection.container; // guaranteed to be 
non-null
 
// Find a common ancestor of s1 and s2 (could be s1)
var s2Ancestors = arrayMap(DU.pathToRoot(s2));
var s1Ancestors = [];
var ancestor;
var i;
-   for (ancestor = s1; !s2Ancestors.has(ancestor); ancestor = 
ancestor.parentNode) {
+   if (s1) {
+   for (ancestor = s1; !s2Ancestors.has(ancestor); 
ancestor = ancestor.parentNode) {
+   s1Ancestors.push(ancestor);
+   }
+   // ancestor is now the common ancestor of s1 and s2
s1Ancestors.push(ancestor);
+   i = s2Ancestors.get(ancestor);
}
-   // ancestor is now the common ancestor of s1 and s2
-   s1Ancestors.push(ancestor);
-   i = s2Ancestors.get(ancestor);
 
var n, tplDsr, dmw;
-   if (ancestor === s1) {
-   // Scenario 1: s1 is s2's ancestor
-   s2 = tplInfo.lastSection.container;
+   if (!s1 || ancestor === s1) {
+   // Scenario 1: s1 is s2's ancestor OR s1 doesn't exist.
+   // In either case, s2 only covers part of the 
transcluded content.
+   // But, s2 could also include content that follows the 
transclusion.
+   // If so, append the content of the section after the 
last node
+   // to data-mw.parts.
if (tplInfo.last.nextSibling) {
-   // Append the content of the section after the 
last node to data-mw.parts
var newTplEndOffset = getDSR(tplInfo, s2, 
false); // will succeed because it traverses non-tpl content
tplDsr = DU.getDataParsoid(tplInfo.first).dsr;
var tplEndOffset = tplDsr[1];
@@ -282,6 +289,7 @@
container: doc.createElement('section'),
// lowest possible level since we don't want
// any nesting of h-tags in the lead section
+   debug_id: 0,
level: 6,
lead: true,
};
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 3d6e6a9..be7f01a 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -29989,8 +29989,43 @@
 # Because of section-wrapping and template-wrapping interactions,
 # the scope of the template is expanded so that the template markup
 # is valid in the presence of  tags.
+# This exercises the s1 is null scenario in the wrapSections code
 !! test
 Section wrapping with template-generated sections (bad nesting 1)
+!! o

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: roundtrip-test.js: Strip section tags before comparing DOMs

2017-11-28 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393926 )

Change subject: roundtrip-test.js: Strip section tags before comparing DOMs
..

roundtrip-test.js: Strip section tags before comparing DOMs

Since we don't add DSR info on section tags, they can trip up
roundtrip-test.js error classification code.

This fixes the odd behavior we saw where a vast majority of semantic
errors got classified as syntactic errors.

Change-Id: Iec1d42f7cd943388efc4c4d7d22efd346e8944d8
---
M bin/roundtrip-test.js
1 file changed, 4 insertions(+), 0 deletions(-)


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

diff --git a/bin/roundtrip-test.js b/bin/roundtrip-test.js
index f3280c6..2f97dda 100755
--- a/bin/roundtrip-test.js
+++ b/bin/roundtrip-test.js
@@ -392,6 +392,10 @@
stripElementIds(oldBody.ownerDocument.body);
stripElementIds(newBody.ownerDocument.body);
 
+   // Strip section tags from the DOMs
+   DU.stripSectionTags(oldBody.ownerDocument.body);
+   DU.stripSectionTags(newBody.ownerDocument.body);
+
var i, offset;
var results = [];
// Use the full tests for fostered content.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iec1d42f7cd943388efc4c4d7d22efd346e8944d8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Fix crasher in getDSR in section wrapping code

2017-11-28 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393921 )

Change subject: Fix crasher in getDSR in section wrapping code
..

Fix crasher in getDSR in section wrapping code

When resolving section-template conflicts, we try to expand the range
of template ranges to includes all content within a section. As part
of that, we need to update the DSR and traverse the non-template
content to compute offsets. When non-templated content only includes
text and comment nodes, we hit templated content. At that point, we
should get the baseline DSR info from the template wrapper. Otherwise,
if we query the last node of the templated content region for DSR
info, we get an undefined value.

This should fix crashers found in RT testing.

I left behind section counters added during debugging.

Change-Id: I8eb21996b9e7bcb856322a7bdfa6eec5882303a0
---
M lib/wt2html/pp/processors/wrapSections.js
1 file changed, 8 insertions(+), 7 deletions(-)


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

diff --git a/lib/wt2html/pp/processors/wrapSections.js 
b/lib/wt2html/pp/processors/wrapSections.js
index 0ac5b54..d2fb077 100644
--- a/lib/wt2html/pp/processors/wrapSections.js
+++ b/lib/wt2html/pp/processors/wrapSections.js
@@ -18,9 +18,9 @@
 */
var section = {
level: newLevel,
+   id: state.count++,
container: state.doc.createElement('section'),
};
-
 
/* Step 1. Get section stack to the right nesting level
 * 1a. Pop stack till we have a higher-level section.
@@ -172,9 +172,9 @@
return highestSectionLevel;
 }
 
-function getDSR(node, start) {
+function getDSR(tplInfo, node, start) {
if (node.nodeName !== 'SECTION') {
-   var dsr = DU.getDataParsoid(node).dsr;
+   var dsr = DU.getDataParsoid(node).dsr || 
DU.getDataParsoid(tplInfo.first).dsr;
return start ? dsr[0] : dsr[1];
}
 
@@ -184,7 +184,7 @@
if (!DU.isElt(c)) {
offset += c.textContent.length;
} else {
-   return getDSR(c, start) + (start ? -offset : offset);
+   return getDSR(tplInfo, c, start) + (start ? -offset : 
offset);
}
c = start ? c.nextSibling : c.previousSibling;
}
@@ -215,7 +215,7 @@
s2 = tplInfo.lastSection.container;
if (tplInfo.last.nextSibling) {
// Append the content of the section after the 
last node to data-mw.parts
-   var newTplEndOffset = getDSR(s2, false); // 
will succeed because it traverses non-tpl content
+   var newTplEndOffset = getDSR(tplInfo, s2, 
false); // will succeed because it traverses non-tpl content
tplDsr = DU.getDataParsoid(tplInfo.first).dsr;
var tplEndOffset = tplDsr[1];
dmw = DU.getDataMw(tplInfo.first);
@@ -254,8 +254,8 @@
}
 
// Update transclusion info
-   var dsr1 = getDSR(newS1, true); // will succeed because 
it traverses non-tpl content
-   var dsr2 = getDSR(newS2, false); // will succeed 
because it traverses non-tpl content
+   var dsr1 = getDSR(tplInfo, newS1, true); // will 
succeed because it traverses non-tpl content
+   var dsr2 = getDSR(tplInfo, newS2, false); // will 
succeed because it traverses non-tpl content
var tplDP = DU.getDataParsoid(tplInfo.first);
tplDsr = tplDP.dsr;
dmw = Util.clone(DU.getDataMw(tplInfo.first));
@@ -289,6 +289,7 @@
// Global state
var state = {
env: env,
+   count: 0,
doc: doc,
rootNode: rootNode,
sectionNumber: 0,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8eb21996b9e7bcb856322a7bdfa6eec5882303a0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: T181226: Don't emit wrappers in body only mode

2017-11-28 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393850 )

Change subject: T181226: Don't emit  wrappers in body only mode
..

T181226: Don't emit  wrappers in body only mode

* We can separately discussing deprecating the body only mode that we
  have been considering.

Change-Id: I7b2bcff432783cc3367d01d7103c742ba3e0e2d9
---
M lib/api/routes.js
M tests/mocha/api.js
2 files changed, 10 insertions(+), 0 deletions(-)


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

diff --git a/lib/api/routes.js b/lib/api/routes.js
index 348e1e8..d09d554 100644
--- a/lib/api/routes.js
+++ b/lib/api/routes.js
@@ -405,6 +405,12 @@
var oldid = res.locals.oldid;
var target = env.normalizeAndResolvePageTitle();
 
+   // VE, the only client using bodyOnly property,
+   // doesn't want section tags when this flag is set.
+   if (res.locals.bodyOnly) {
+   env.wrapSections = false;
+   }
+
var pageBundle = !!(res.locals.opts && res.locals.opts.format 
=== 'pagebundle');
env.pageBundle = pageBundle;
 
diff --git a/tests/mocha/api.js b/tests/mocha/api.js
index a23aa2e..e214931 100644
--- a/tests/mocha/api.js
+++ b/tests/mocha/api.js
@@ -764,6 +764,8 @@
// v3 only returns children of 
res.body.html.body.should.not.match(/
res.text.should.not.match(/https://gerrit.wikimedia.org/r/393850
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b2bcff432783cc3367d01d7103c742ba3e0e2d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Use env.wrapSections to decide whether to add tags...

2017-11-28 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393846 )

Change subject: Use env.wrapSections to decide whether to add  tags or 
not
..

Use env.wrapSections to decide whether to add  tags or not

* Initialize the env property with the parsoid config setting.

* This lets tests, scripts, and api requests to opt in/out of this
  independent of the parsoid config option without testing both
  settings.

Change-Id: I276f2a7c5d954ea320d32d6589e94c6657a3548b
---
M lib/config/MWParserEnvironment.js
M lib/wt2html/pp/processors/wrapSections.js
2 files changed, 4 insertions(+), 1 deletion(-)


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

diff --git a/lib/config/MWParserEnvironment.js 
b/lib/config/MWParserEnvironment.js
index be26705..01a5a75 100644
--- a/lib/config/MWParserEnvironment.js
+++ b/lib/config/MWParserEnvironment.js
@@ -139,6 +139,9 @@
wiki: null,
};
 
+   // Default
+   this.wrapSections = parsoidConfig.wrapSections;
+
// FIXME: This is temporary and will be replaced after the call to
// `switchToConfig`.  However, it may somehow be used in the
// `ConfigRequest` along the way. Perhaps worth seeing if that can be
diff --git a/lib/wt2html/pp/processors/wrapSections.js 
b/lib/wt2html/pp/processors/wrapSections.js
index 99f1947..0ac5b54 100644
--- a/lib/wt2html/pp/processors/wrapSections.js
+++ b/lib/wt2html/pp/processors/wrapSections.js
@@ -272,7 +272,7 @@
 }
 
 function wrapSections(rootNode, env, options, atTopLevel) {
-   if (!atTopLevel || (!env.conf.parsoid.wrapSections && 
!env.wrapSections)) {
+   if (!atTopLevel || !env.wrapSections) {
return;
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I276f2a7c5d954ea320d32d6589e94c6657a3548b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Add lead section before resolving template-section conflicts

2017-11-28 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393838 )

Change subject: Add lead section before resolving template-section conflicts
..

Add lead section before resolving template-section conflicts

* Should fix a bunch of crashers seen in round trip testing

Change-Id: I5238f18dfd54c78f94090b072a8892f70124f294
---
M lib/wt2html/pp/processors/wrapSections.js
1 file changed, 3 insertions(+), 1 deletion(-)


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

diff --git a/lib/wt2html/pp/processors/wrapSections.js 
b/lib/wt2html/pp/processors/wrapSections.js
index abace33..99f1947 100644
--- a/lib/wt2html/pp/processors/wrapSections.js
+++ b/lib/wt2html/pp/processors/wrapSections.js
@@ -299,11 +299,13 @@
},
};
wrapSectionsInDOM(state, leadSection, rootNode);
-   resolveTemplateSectionConflicts(state);
 
// There will always be a lead section, even if sometimes it only
// contains whitespace + comments.
rootNode.insertBefore(leadSection.container, rootNode.firstChild);
+
+   // Resolve template conflicts after all sections have been added to the 
DOM
+   resolveTemplateSectionConflicts(state);
 }
 
 module.exports = {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5238f18dfd54c78f94090b072a8892f70124f294
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to c9f40476 for beta cluster update

2017-11-27 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/393627 )

Change subject: Bump src to c9f40476 for beta cluster update
..

Bump src to c9f40476 for beta cluster update

Change-Id: I53c435e128706207b351870682638fb046f5fe97
---
M src
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/27/393627/1

diff --git a/src b/src
index e71937d..c9f4047 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit e71937d03430ea993585b948f1215966b823563e
+Subproject commit c9f404761cd288e7b58b89623ac459bbb2901a7d

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I53c435e128706207b351870682638fb046f5fe97
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Sync up with Parsoid parserTests.txt

2017-11-21 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/392724 )

Change subject: Sync up with Parsoid parserTests.txt
..

Sync up with Parsoid parserTests.txt

This now aligns with Parsoid commit 0723e5c47845ff4361b9635b591e7d386c975fdf

Change-Id: Ic78ee28a5cdeb9d32147332bf6c06bbe6ab19acd
---
M tests/parser/parserTests.txt
1 file changed, 405 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/24/392724/1

diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index c3cea04..a879f6d 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -15181,7 +15181,7 @@
 http://example.com/images/thumb/f/ff/Foobar.svg/180px-Foobar.svg.png"; 
width="180" height="135" class="thumbimage" 
srcset="http://example.com/images/thumb/f/ff/Foobar.svg/270px-Foobar.svg.png 
1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 2x" 
/>  lang=invalid:language:code
 
 !! html/parsoid
-lang=invalid.language.code
+lang=invalid:language:code
 !! end
 
 !! test
@@ -18549,10 +18549,14 @@
 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
 
 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
-!! html
+!! html/php
 
 http://example.com/images/3/3a/Foobar.jpg"; width="1941" height="220" />
 
+!! html/parsoid
+
+
+
 !! end
 
 !! test
@@ -29739,4 +29743,403 @@
 !! html/php
 #[foo]
 
+
+## --
+## Parsoid section-wrapping tests
+## --
+!! test
+Section wrapping for well-nested sections (no leading content)
+!! options
+parsoid={
+  "wrapSections": true
+}
+!! wikitext
+= 1 =
+a
+
+= 2 =
+b
+
+== 2.1 ==
+c
+
+== 2.2 ==
+d
+
+=== 2.2.1 ===
+e
+
+= 3 =
+f
+!! html/parsoid
+ 1 
+a
+
+ 2 
+b
+
+ 2.1 
+c
+
+ 2.2 
+d
+
+ 2.2.1 
+e
+
+ 3 

+f
+
+
+!! end
+
+!! test
+Section wrapping for well-nested sections (with leading content)
+!! options
+parsoid={
+  "wrapSections": true
+}
+!! wikitext
+Para 1.
+
+Para 2 with a nested in it
+
+Para 3.
+
+= 1 =
+a
+
+= 2 =
+b
+
+== 2.1 ==
+c
+!! html/parsoid
+Para 1.
+
+Para 2 with a nested in it
+
+Para 3.
+
+ 1 
+a
+
+ 2 
+b
+
+ 2.1 
+c
+
+
+!! end
+
+!! test
+Section wrapping with template-generated sections (good nesting 1)
+!! options
+parsoid={
+  "wrapSections": true
+}
+!! wikitext
+= 1 =
+a
+
+{{echo|1=
+== 1.1 ==
+b
+}}
+
+== 1.2 ==
+c
+
+= 2 =
+d
+!! html/parsoid
+ 1 
+a
+
+ 1.1 
+b
+ 1.2 
+c
+
+ 2 
+d
+!! end
+
+# In this example, the template scope is mildly expanded to incorporate the
+# trailing newline after the transclusion since that is part of section 1.1.1
+!! test
+Section wrapping with template-generated sections (good nesting 2)
+!! options
+parsoid={
+  "wrapSections": true,
+  "modes": ["wt2html", "wt2wt"]
+}
+!! wikitext
+= 1 =
+a
+
+{{echo|1=
+== 1.1 ==
+b
+=== 1.1.1 ===
+d
+}}
+= 2 =
+e
+!! html/parsoid
+ 1 
+a
+
+ 1.1 
+b
+ 1.1.1 
+d
+ 2 
+e
+!! end
+
+# In this example, the template scope is mildly expanded to incorporate the
+# trailing newline after the transclusion since that is part of section 1.2.1
+!! test
+Section wrapping with template-generated sections (good nesting 3)
+!! options
+parsoid={
+  "wrapSections": true,
+  "modes": ["wt2html", "wt2wt"]
+}
+!! wikitext
+= 1 =
+a
+
+{{echo|1=
+x
+== 1.1 ==
+b
+==1.2==
+c
+===1.2.1===
+d
+}}
+= 2 =
+e
+!! html/parsoid
+ 1 
+a
+
+x
+ 1.1 
+b
+1.2
+c
+1.2.1
+d
+ 2 
+e
+!! end
+
+# Because of section-wrapping and template-wrapping interactions,
+# the scope of the template is expanded so that the template markup
+# is valid in the presence of  tags.
+!! test
+Section wrapping with template-generated sections (bad nesting 1)
+!! options
+parsoid={
+  "wrapSections": true
+}
+!! wikitext
+= 1 =
+a
+
+{{echo|1=
+= 2 =
+b
+== 2.1 ==
+c
+}}
+
+d
+
+= 3 =
+e
+!! html/parsoid
+ 1 
+a
+
+ 2 
+b
+ 2.1 
+c
+
+d
+
+ 3 
+e
+!! end
+
+# Because of section-wrapping and template-wrapping interactions,
+# additional template wrappers are added to  tags
+# so that template wrapping semantics are valid whether section
+# tags are retained or stripped. But, the template scope can expand
+# greatly when accounting for section tags.
+!! test
+Section wrapping with template-generated sections (bad nesting 2)
+!! options
+parsoid={
+  "wrapSections": true,
+  "modes": ["wt2html", "wt2wt"]
+}
+!! wikitext
+= 1 =
+a
+
+{{echo|1=
+== 1.2 ==
+b
+= 2 =
+c
+}}
+
+d
+
+= 3 =
+e
+!! html/parsoid
+ 1 
+a
+
+ 1.2 
+b
+ 2 
+c
+
+d
+ 3 
+e
+!! end
+
+!! test
+Section wrapping with uneditable lead section + div wrapping multiple sections
+!! options
+parsoid={
+  "wrapSections": true
+}
+!! wikitext
+foo
+
+
+= 1 =
+a
+
+== 1.1 ==
+b
+
+= 2 =
+c
+
+
+= 3 =
+d
+
+== 3.1 ==
+e
+!! html/parsoid
+foo
+
+
+ 1 
+a
+
+ 1.1 
+b
+
+ 2 
+c
+
+
+ 3 
+d
+
+ 3.1 
+e
+
+!! end
+
+!! test
+Section wrapping with editable lead section + div overlapping multiple sections
+!! options
+parsoid={
+  "wrapSections": true
+}
+!!

[MediaWiki-commits] [Gerrit] operations/mediawiki-config[master]: Revert "Temporary disable remex html"

2017-11-17 Thread Subramanya Sastry (Code Review)
Hello Urbanecm, Paladox, Hoo man, jenkins-bot, Zoranzoki21,

I'd like you to do a code review.  Please visit

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

to review the following change.


Change subject: Revert "Temporary disable remex html"
..

Revert "Temporary disable remex html"

This reverts commit b1da6a77d9edae0786381972b41af663666eed7b.

Change-Id: I97c47cdb0bb72b5ce805ce1eb8143ceb5268ff24
---
M wmf-config/InitialiseSettings.php
1 file changed, 6 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/85/392185/1

diff --git a/wmf-config/InitialiseSettings.php 
b/wmf-config/InitialiseSettings.php
index a263862..1d476fb 100644
--- a/wmf-config/InitialiseSettings.php
+++ b/wmf-config/InitialiseSettings.php
@@ -19116,16 +19116,15 @@
 'wgTidyConfig' => [
'default' => null,
 
-   // TEMP disable: T178632
-   // 'mediawikiwiki' => [ 'driver' => 'RemexHtml' ],
-   // 'testwiki' => [ 'driver' => 'RemexHtml' ],
+   'mediawikiwiki' => [ 'driver' => 'RemexHtml' ],
+   'testwiki' => [ 'driver' => 'RemexHtml' ],
 
-   // 'fawiki' => [ 'driver' => 'RemexHtml' ], // T176150
-   // 'nowiki' => [ 'driver' => 'RemexHtml' ], // T177989
+   'fawiki' => [ 'driver' => 'RemexHtml' ], // T176150
+   'nowiki' => [ 'driver' => 'RemexHtml' ], // T177989
 
-   // 'eswikiversity' => [ 'driver' => 'RemexHtml' ],
+   'eswikiversity' => [ 'driver' => 'RemexHtml' ],
 
-   // 'wikitech' => [ 'driver' => 'RemexHtml' ],
+   'wikitech' => [ 'driver' => 'RemexHtml' ],
 ],
 
 // Cache ResourceLoader modules in localStorage

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I97c47cdb0bb72b5ce805ce1eb8143ceb5268ff24
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 
Gerrit-Reviewer: Hoo man 
Gerrit-Reviewer: Paladox 
Gerrit-Reviewer: Urbanecm 
Gerrit-Reviewer: Zoranzoki21 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src/ to ab4dc209 and update mediawiki-title

2017-11-13 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391082 )

Change subject: Bump src/ to ab4dc209 and update mediawiki-title
..

Bump src/ to ab4dc209 and update mediawiki-title

Change-Id: Id36aa619f8abcec81aa641e4848242a72e4c811c
---
M node_modules/mediawiki-title/.jscs.json
M node_modules/mediawiki-title/.jshintignore
D node_modules/mediawiki-title/.npmignore
M node_modules/mediawiki-title/.travis.yml
M node_modules/mediawiki-title/lib/index.js
A node_modules/mediawiki-title/lib/mediawiki.Title.phpCharToUpper.js
M node_modules/mediawiki-title/package.json
M node_modules/mediawiki-title/test/index.js
M src
9 files changed, 310 insertions(+), 62 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/82/391082/1

diff --git a/node_modules/mediawiki-title/.jscs.json 
b/node_modules/mediawiki-title/.jscs.json
index 189fa2b..7005142 100644
--- a/node_modules/mediawiki-title/.jscs.json
+++ b/node_modules/mediawiki-title/.jscs.json
@@ -26,6 +26,7 @@
 "node_modules/**",
 "test/**",
 "coverage/**",
-"test.db.**"
+"test.db.**",
+"lib/mediawiki.Title.phpCharToUpper.js"
   ]
-}
\ No newline at end of file
+}
diff --git a/node_modules/mediawiki-title/.jshintignore 
b/node_modules/mediawiki-title/.jshintignore
index 1c69eee..7e45fc9 100644
--- a/node_modules/mediawiki-title/.jshintignore
+++ b/node_modules/mediawiki-title/.jshintignore
@@ -1,3 +1,4 @@
 coverage
 node_modules
 test
+lib/mediawiki.Title.phpCharToUpper.js
diff --git a/node_modules/mediawiki-title/.npmignore 
b/node_modules/mediawiki-title/.npmignore
deleted file mode 100644
index 269d298..000
--- a/node_modules/mediawiki-title/.npmignore
+++ /dev/null
@@ -1,9 +0,0 @@
-coverage
-node_modules
-npm-debug.log
-
-# WebStorm IDE files
-.idea/*
-
-# vim temp files
-*swp
diff --git a/node_modules/mediawiki-title/.travis.yml 
b/node_modules/mediawiki-title/.travis.yml
index c678a5b..c651632 100644
--- a/node_modules/mediawiki-title/.travis.yml
+++ b/node_modules/mediawiki-title/.travis.yml
@@ -1,9 +1,9 @@
 language: node_js
 node_js:
-- "0.10"
-- "0.12"
-- "4.2"
-- "5"
+- "4"
+- "6"
+- "8"
+- "node"
 
 sudo: false
 
diff --git a/node_modules/mediawiki-title/lib/index.js 
b/node_modules/mediawiki-title/lib/index.js
index aa380b6..9b7c997 100644
--- a/node_modules/mediawiki-title/lib/index.js
+++ b/node_modules/mediawiki-title/lib/index.js
@@ -1,7 +1,8 @@
 "use strict";
 
-var sanitizeIP = require('./ip');
-var utils  = require('./utils');
+var sanitizeIP = require('./ip');
+var utils  = require('./utils');
+var phpCharToUpper = require('./mediawiki.Title.phpCharToUpper.js');
 
 /**
  * A UTF-8 replacement character that's explicitly prohibited in the title
@@ -211,6 +212,8 @@
 function _capitalizeTitle(result, siteInfo) {
 var nsCase = siteInfo.namespaces[result.namespace._id + ''].case;
 if (nsCase === 'first-letter') {
+// This special casing is from core's `Language::ucfirst`
+// Grep for definitions in core/languages/classes/
 if (result.title[0] === 'i' && (siteInfo.general.lang === 'az'
 || siteInfo.general.lang === 'tr'
 || siteInfo.general.lang === 'kaa'
@@ -218,12 +221,8 @@
 result.title = 'İ' +  result.title.substr(1);
 } else if (!/^[A-Z]/.test(result.title)) {
 var firstCharacter = result.title.charAt(0);
-var upperCasedFirstLetter = firstCharacter.toUpperCase();
-// PHP is only capable of upper-casing letters that end up
-// as a single character, however JS upper-cases German 'ß' to SS
-if (upperCasedFirstLetter.length === firstCharacter.length) {
-result.title = upperCasedFirstLetter + result.title.substr(1);
-}
+var upperCasedFirstLetter = phpCharToUpper(firstCharacter);
+result.title = upperCasedFirstLetter + result.title.substr(1);
 }
 }
 return result;
diff --git a/node_modules/mediawiki-title/lib/mediawiki.Title.phpCharToUpper.js 
b/node_modules/mediawiki-title/lib/mediawiki.Title.phpCharToUpper.js
new file mode 100644
index 000..f337911
--- /dev/null
+++ b/node_modules/mediawiki-title/lib/mediawiki.Title.phpCharToUpper.js
@@ -0,0 +1,255 @@
+// This file can't be parsed by JSDuck due to 
.
+// (It is excluded in jsduck.json.)
+// ESLint suggests unquoting some object keys, which would render the file 
unparseable by Opera 12.
+/* eslint-disable quote-props */
+( function () {
+   var toUpperMapping = {
+   'ß': 'ß',
+   'ʼn': 'ʼn',
+   'Dž': 'Dž',
+   'dž': 'Dž',
+   'Lj': 'Lj',
+   'lj': 'Lj',
+   'Nj': 'Nj',
+   'nj': 'Nj',
+   'ǰ': 'ǰ',
+   'Dz

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Preserve original transclusion's parameter order

2017-11-07 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389852 )

Change subject: Preserve original transclusion's parameter order
..

Preserve original transclusion's parameter order

* Parameters that were previously present aren't reordered.
  Any updates to params are made in place.

* Newly introduce parameters are serialized in the order
  in which they show up in templatedata format.

  In the absence of templatedata, they will be serialized
  in the order in which they were added by VE into data-mw.

* Updated mocha tests.

Change-Id: I2b269d5bfb08efbe56b9293c2aa3e810fb1b29da
---
M lib/html2wt/WikitextSerializer.js
M tests/mocha/templatedata.js
2 files changed, 13 insertions(+), 10 deletions(-)


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

diff --git a/lib/html2wt/WikitextSerializer.js 
b/lib/html2wt/WikitextSerializer.js
index d404bee..118257b 100644
--- a/lib/html2wt/WikitextSerializer.js
+++ b/lib/html2wt/WikitextSerializer.js
@@ -550,17 +550,20 @@
}, paramOrder);
}
var argOrder = [].concat(
-   // 1. Use tpldata param order as the first guide
+   // 1. Push keys from data-parsoid first.
+   //This ensures that param order from the original
+   //transclusion is preserved.
+   //(data-parsoid argInfo also present in data-mw
+   //will get processed).
+   dpArgInfo.map(function(argInfo) { return argInfo.k; }),
+
+   // 2. Use tpldata param order as the next source of
+   //ordering information.
//Note that:
//(a) template arg names are case-sensitive
//(b) arg names in tplData.paramOrder already
//have their spaces trimmed
paramOrder,
-
-   // 2. Push keys from data-parsoid
-   //data-parsoid argInfo also present in data-mw
-   //will get processed
-   dpArgInfo.map(function(argInfo) { return argInfo.k; }),
 
// 3. Push keys from data-mw
//data-mw entry not present in data-parsoid argInfo
diff --git a/tests/mocha/templatedata.js b/tests/mocha/templatedata.js
index 0d81382..c88dfc9 100644
--- a/tests/mocha/templatedata.js
+++ b/tests/mocha/templatedata.js
@@ -90,7 +90,7 @@
'wt': {
'no_selser':   
'{{NoFormatWithParamOrder|f2=foo|f1=foo}}',
'new_content': 
'{{NoFormatWithParamOrder|f1=foo|f2=foo}}',
-   'edited':  
'{{NoFormatWithParamOrder|f1=BAR|f2=foo}}',
+   'edited':  
'{{NoFormatWithParamOrder|f2=foo|f1=BAR}}',
},
},
 
@@ -134,7 +134,7 @@
'wt': {
'no_selser':   '{{InlineTplWithParamOrder\n|f2 = 
foo\n|f1 = foo\n}}',
'new_content': 
'{{InlineTplWithParamOrder|f1=foo|f2=foo}}',
-   'edited':  
'{{InlineTplWithParamOrder|f1=BAR|f2=foo}}',
+   'edited':  
'{{InlineTplWithParamOrder|f2=foo|f1=BAR}}',
},
},
 
@@ -145,7 +145,7 @@
'wt': {
'no_selser':   
'{{BlockTplWithParamOrder|f2=foo|f1=foo}}',
'new_content': '{{BlockTplWithParamOrder\n| f1 = foo\n| 
f2 = foo\n}}',
-   'edited':  '{{BlockTplWithParamOrder\n| f1 = BAR\n| 
f2 = foo\n}}',
+   'edited':  '{{BlockTplWithParamOrder\n| f2 = foo\n| 
f1 = BAR\n}}',
},
},
 
@@ -167,7 +167,7 @@
'wt': {
'no_selser':   
'{{BlockTplWithParamOrder|f2=foo|f1=foo}}SOME TEXT{{InlineTplNoParamOrder\n|f2 
= foo\n|f1 = foo\n}}',
'new_content': '{{BlockTplWithParamOrder\n| f1 = foo\n| 
f2 = foo\n}}SOME TEXT{{InlineTplNoParamOrder|f1=foo|f2=foo}}',
-   'edited':  '{{BlockTplWithParamOrder\n| f1 = BAR\n| 
f2 = foo\n}}SOME TEXT{{InlineTplNoParamOrder|f2=foo|f1=foo}}',
+   'edited':  '{{BlockTplWithParamOrder\n| f2 = foo\n| 
f1 = BAR\n}}SOME TEXT{{InlineTplNoParamOrder|f2=foo|f1=foo}}',
},
},
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b269d5bfb08efbe56b9293c2aa3e810fb1b29da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Turn off non-actionable mixed-content-templates cate...

2017-11-06 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389533 )

Change subject: Linter: Turn off non-actionable mixed-content-templates category
..

Linter: Turn off non-actionable mixed-content-templates category

Change-Id: Ic323a4d463984177d5c1ff711d2b6490fc9755d0
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 13 insertions(+), 6 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index ed5794b..c51f46d 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -769,10 +769,15 @@
 
var dp = DU.getDataParsoid(node);
 
+   /*
+* Turn this off since this is wasted processing
+* that is not really actionable at this time.
+*
if (tplInfo && tplInfo.first === node) {
// Log transclusions with more than one part
logTransclusions(env, node, dp, tplInfo);
}
+   */
 
logTreeBuilderFixup(env, node, dp, tplInfo);
// Turning this off for now since
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index abf642d..9cd0280 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -320,6 +320,7 @@
});
});
 
+   /*
describe('MIXED-CONTENT TEMPLATES', function() {
it('should lint mixed-content templates', function() {
return parseWT('{{1x|*}}hi').then(function(result) {
@@ -336,6 +337,7 @@
});
});
});
+   */
 
describe('DELETABLE TABLE TAG', function() {
it('should identify deletable table tag for T161341 (1)', 
function() {
@@ -407,12 +409,12 @@
"|}",
].join('\n');
return parseWT(wt).then(function(result) {
-   result.should.have.length(2);
-   result[1].should.have.a.property("type", 
"deletable-table-tag");
-   
result[1].should.not.have.a.property("templateInfo");
-   result[1].should.have.a.property("params");
-   result[1].params.should.have.a.property("name", 
"table");
-   result[1].dsr.should.deep.equal([ 29, 31, 0, 0 
]);
+   result.should.have.length(1);
+   result[0].should.have.a.property("type", 
"deletable-table-tag");
+   
result[0].should.not.have.a.property("templateInfo");
+   result[0].should.have.a.property("params");
+   result[0].params.should.have.a.property("name", 
"table");
+   result[0].dsr.should.deep.equal([ 29, 31, 0, 0 
]);
});
});
});

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic323a4d463984177d5c1ff711d2b6490fc9755d0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: T171381: Linter: Handle Optional end tags in missing-end-tag...

2017-11-06 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389531 )

Change subject: T171381: Linter: Handle Optional end tags in missing-end-tag 
category
..

T171381: Linter: Handle Optional end tags in missing-end-tag category

Additional DOM analysis will be required for handling
tbody, thead, tfoot, and colgroup tags. But, these tags are
not common in our corpus, so not worth the extra effort.

Change-Id: I4455fa26a969fc8dea56273259140d13e9995236
---
M lib/config/WikitextConstants.js
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
3 files changed, 14 insertions(+), 1 deletion(-)


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

diff --git a/lib/config/WikitextConstants.js b/lib/config/WikitextConstants.js
index 1382b7c..a9dd312 100644
--- a/lib/config/WikitextConstants.js
+++ b/lib/config/WikitextConstants.js
@@ -253,6 +253,16 @@
'TABLE', 'TBODY', 'THEAD', 'TFOOT', 'CAPTION', 'TH', 
'TR', 'TD',
]),
 
+   // https://www.w3.org/TR/html5/tabular-data.html#the-tr-element
+   // https://www.w3.org/TR/html5/tabular-data.html#the-td-element
+   // https://www.w3.org/TR/html5/tabular-data.html#the-th-element
+   //
+   // tbody, tfoot, thead, colgroup also have optional end tag 
requirements
+   // but they are conditional on other properties of the DOM.
+   OptionalEndTags: new Set([
+   'TR', 'TD', 'TH'
+   ]),
+
// Table tags that can be parents
ParentTableTags: new Set([
"TABLE", "TBODY", "THEAD", "TFOOT", "TR",
diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index d50a5ec..ed5794b 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -317,7 +317,7 @@
}
adjDp.tmp.linted = true;
env.log('lint/misnested-tag', lintObj);
-   } else if (DU.hasLiteralHTMLMarker(dp)) {
+   } else if (DU.hasLiteralHTMLMarker(dp) && 
!Consts.HTML.OptionalEndTags.has(c.nodeName)) {
env.log('lint/missing-end-tag', 
lintObj);
}
}
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index be4fe7d..abf642d 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -67,6 +67,9 @@
result[0].params.should.have.a.property("name", 
"p");
});
});
+   it('should not flag tags where end tags are optional in the 
spec', function() {
+   return expectEmptyResults('heading 
1col 1col 2');
+   });
});
 
describe('STRIPPED TAGS', function() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4455fa26a969fc8dea56273259140d13e9995236
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: T179757: Linter: Fix false positive for tidy-font-bug

2017-11-04 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/389113 )

Change subject: T179757: Linter: Fix false positive for tidy-font-bug
..

T179757: Linter: Fix false positive for tidy-font-bug

Change-Id: I04345253cf4950ba4e9b3140951e377ac2c53cf1
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 2 insertions(+), 1 deletion(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index d50a5ec..8c7d550 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -479,7 +479,7 @@
 * specifies a link colour because the link no longer renders
 * as blue/red but in the font-specified colour.
 * -- */
-   var tidyFontBug = true;
+   var tidyFontBug = c.firstChild !== null;
var haveLink = false;
for (var n = c.firstChild; n; n = n.nextSibling) {
if (!DU.isComment(n) &&
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index be4fe7d..2fa672a 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -777,6 +777,7 @@
});
});
var wtLines2 = [
+   "", // Regression test for 
T179757
"[[Foo]][[Bar]]",
" [[Foo]]",
"[[Foo]] ",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I04345253cf4950ba4e9b3140951e377ac2c53cf1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Git rid of unused brokenHTMLTag data-parsoid attribute

2017-11-03 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/388685 )

Change subject: Git rid of unused brokenHTMLTag data-parsoid attribute
..

Git rid of unused brokenHTMLTag data-parsoid attribute

Change-Id: I969374a8052b9084c84561a40a3354c02a3a396c
---
M lib/wt2html/pegTokenizer.pegjs
M tests/parserTests.txt
2 files changed, 1 insertion(+), 5 deletions(-)


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

diff --git a/lib/wt2html/pegTokenizer.pegjs b/lib/wt2html/pegTokenizer.pegjs
index 580ef15..63bb1a1 100644
--- a/lib/wt2html/pegTokenizer.pegjs
+++ b/lib/wt2html/pegTokenizer.pegjs
@@ -1441,10 +1441,6 @@
 res.dataAttribs.noClose = true;
 }
 
-if (broken || bad_ws.length > 0) {
-res.dataAttribs.brokenHTMLTag = true;
-}
-
 return maybeExtensionTag(res);
 }
 / "<" "/"? tag_name & { return stops.pop('extTag'); }
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 057e794..6a97171 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -9449,7 +9449,7 @@
 !! html/parsoid
 
 
-
+
 
 
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I969374a8052b9084c84561a40a3354c02a3a396c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Rename stx_v data-parsoid flag to stx

2017-11-03 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/388680 )

Change subject: Rename stx_v data-parsoid flag to stx
..

Rename stx_v data-parsoid flag to stx

Accept both stx and stx_v for now till RESTBase storage turns over
or is refreshed. Might be worth getting this out before or during
the upcoming HTML version bump.

Step 1 of mw:Parsoid/Internals/data-parsoid#Proposal:_Maybe_move_to_data-mw.3F

Change-Id: I768041bcb02b748c4b957f3e710211f7f6c27b70
---
M lib/html2wt/DOMHandlers.js
M lib/html2wt/WTSUtils.js
M lib/html2wt/normalizeDOM.js
M lib/wt2html/pegTokenizer.pegjs
M tests/parserTests-blacklist.js
M tests/parserTests.txt
6 files changed, 29 insertions(+), 21 deletions(-)


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

diff --git a/lib/html2wt/DOMHandlers.js b/lib/html2wt/DOMHandlers.js
index 3165aa6..6085676 100644
--- a/lib/html2wt/DOMHandlers.js
+++ b/lib/html2wt/DOMHandlers.js
@@ -514,7 +514,8 @@
 
 function stxInfoValidForTableCell(state, node) {
// If there is no syntax info, nothing to worry about
-   if (!DU.getDataParsoid(node).stx_v) {
+   var dp = DU.getDataParsoid(node);
+   if (!dp.stx && !dp.stx_v) {
return true;
}
 
@@ -768,7 +769,7 @@
var attrSepSrc = usableDP ? (dp.attrSepSrc || null) : 
null;
var startTagSrc = usableDP ? dp.startTagSrc : '';
if (!startTagSrc) {
-   startTagSrc = (usableDP && dp.stx_v === 'row') 
? '!!' : '!';
+   startTagSrc = (usableDP && (dp.stx_v === 'row' 
|| dp.stx === 'row')) ? '!!' : '!';
}
 
// T149209: Special case to deal with scenarios
@@ -795,7 +796,8 @@
sepnls: {
before: function(node, otherNode, state) {
if (otherNode.nodeName === 'TH' &&
-   DU.getDataParsoid(node).stx_v 
=== 'row') {
+   (DU.getDataParsoid(node).stx === 'row' 
||
+DU.getDataParsoid(node).stx_v === 
'row')) {
// force single line
return { min: 0, max: 
maxNLsInTable(node, otherNode) };
} else {
@@ -819,7 +821,7 @@
var attrSepSrc = usableDP ? (dp.attrSepSrc || null) : 
null;
var startTagSrc = usableDP ? dp.startTagSrc : '';
if (!startTagSrc) {
-   startTagSrc = (usableDP && dp.stx_v === 'row') 
? '||' : '|';
+   startTagSrc = (usableDP && (dp.stx === 'row' || 
dp.stx_v === 'row')) ? '||' : '|';
}
 
// T149209: Special case to deal with scenarios
@@ -845,7 +847,8 @@
sepnls: {
before: function(node, otherNode, state) {
if (otherNode.nodeName === 'TD' &&
-   DU.getDataParsoid(node).stx_v 
=== 'row') {
+   (DU.getDataParsoid(node).stx === 'row' 
||
+DU.getDataParsoid(node).stx_v === 
'row')) {
// force single line
return { min: 0, max: 
maxNLsInTable(node, otherNode) };
} else {
diff --git a/lib/html2wt/WTSUtils.js b/lib/html2wt/WTSUtils.js
index 0b711fa..0c68889 100644
--- a/lib/html2wt/WTSUtils.js
+++ b/lib/html2wt/WTSUtils.js
@@ -91,7 +91,10 @@
// If it didn't have a stx_v marker that indicated that the cell
// showed up on the same line via the "||" or "!!" syntax, 
nothing
// to worry about.
-   return DU.getDataParsoid(node).stx_v !== 'row';
+   var dp = DU.getDataParsoid(node);
+   // Temporarily check for both stx_v and stx till
+   // the old flag expires in cache / storage.
+   return dp.stx_v !== 'row' && dp.stx !== 'row';
} else if (node.nodeName === 'TR' && 
!DU.getDataParsoid(node).startTagSrc) {
// If this  didn't have a startTagSrc, it would have been
// the first row of a table in original wikitext. So, it is safe
diff --git a/lib/html2wt/normalizeDOM.js b/lib/html2wt/normalizeDOM.js
index 37350ec..cd551a3 100644
--- a/lib/html2wt/normalizeDOM.js
+++ b/lib/html2wt/normalizeDOM.js
@@ -358,11 +358,13 @@
 
// * HTML s won't have escapable prefixes
// * First cell should always be checked for escapable prefixes
-   // * Second and later cells in a 

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Image captions are not affected by tidy-font-bug

2017-11-01 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387833 )

Change subject: Linter: Image captions are not affected by tidy-font-bug
..

Linter: Image captions are not affected by tidy-font-bug

See https://www.mediawiki.org/wiki/Topic:U149apx11uv6l1x0

Change-Id: I735b734c2ff9d3770da296327b54c72a54e084c0
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 0 insertions(+), 4 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 22712e7..d50a5ec 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -484,8 +484,6 @@
for (var n = c.firstChild; n; n = n.nextSibling) {
if (!DU.isComment(n) &&
n.nodeName !== 'A' &&
-   n.nodeName !== 'FIGURE' &&
-   !(n.nodeName === 'SPAN' && 
/\bmw:Image\b/.test(n.getAttribute('typeof'))) &&
!DU.isBehaviorSwitch(env, n) &&
!DU.isSolTransparentLink(n) &&
!(n.nodeName === 'META' && 
Util.TPL_META_TYPE_REGEXP.test(n.getAttribute('typeof')))
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index d710ede..be4fe7d 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -754,8 +754,6 @@
"[[Foo|bar]]",
"[[Foo|''bar'']]",
"[[Foo|''bar'' and boo]]",
-   "[[File:Foo.jpg|some 
caption]]",
-   "[[File:Foo.jpg|thumb|128px|some 
caption]]",
"[[Foo]]l",
"{{1x|[[Foo]]}}",
];

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I735b734c2ff9d3770da296327b54c72a54e084c0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...ParserMigration[master]: WIP: Follow redirects

2017-10-30 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387368 )

Change subject: WIP: Follow redirects
..

WIP: Follow redirects

* Since this extension is commonly used to compare rendering differences,
  it makes sense to follow redirects by default.

* Provide the &redirect=no API option for the scenario where clients
  need to actually fetch the redirect page.

Change-Id: Ia720277f2806288eae88c6051819725403f1cf08
---
M includes/ApiParserMigration.php
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ParserMigration 
refs/changes/68/387368/1

diff --git a/includes/ApiParserMigration.php b/includes/ApiParserMigration.php
index 62aef11..c489d9a 100644
--- a/includes/ApiParserMigration.php
+++ b/includes/ApiParserMigration.php
@@ -12,6 +12,14 @@
$params = $this->extractRequestParams();
 
$title = $this->getTitleOrPageId( $params )->getTitle();
+   // Follow redirects by default. Redirect link output is not
+   // interesting for rendering diff comparisons. Provide clients
+   // the option to choose the redirect page via '&redirect=no'.
+   if ( $title->isRedirect() && (
+   !isset($params['redirect']) || $params['redirect'] !== 
'no'
+   )) {
+   $title = new WikiPage( $title )->getRedirectTarget();
+   }
$revision = \Revision::newFromTitle( $title );
if ( !$revision ) {
$this->dieWithError( 'apierror-missingtitle' );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia720277f2806288eae88c6051819725403f1cf08
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ParserMigration
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: parse.js: Fix bug / broken --apiURL option

2017-10-27 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386902 )

Change subject: parse.js: Fix bug / broken --apiURL option
..

parse.js: Fix bug / broken --apiURL option

Change-Id: I6bae699f17df1b2150941c77526300037d337ff8
---
M lib/utils/Util.js
1 file changed, 2 insertions(+), 2 deletions(-)


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

diff --git a/lib/utils/Util.js b/lib/utils/Util.js
index 95dbd5d..39f52a7 100644
--- a/lib/utils/Util.js
+++ b/lib/utils/Util.js
@@ -232,9 +232,9 @@
}
if (cliOpts.apiURL) {
if (!Array.isArray(parsoidOptions.mwApi)) {
-   parsoidOptions.mwApi = [];
+   parsoidOptions.mwApis = [];
}
-   parsoidOptions.mwApi.push({ prefix: 'customwiki', uri: 
cliOpts.apiURL });
+   parsoidOptions.mwApis.push({ prefix: 'customwiki', uri: 
cliOpts.apiURL });
}
if (cliOpts.addHTMLTemplateParameters !== undefined) {
parsoidOptions.addHTMLTemplateParameters =

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6bae699f17df1b2150941c77526300037d337ff8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: Add tidy-font-bug linter high-priority category

2017-10-23 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386098 )

Change subject: Add tidy-font-bug linter high-priority category
..

Add tidy-font-bug linter high-priority category

*  tags with color attribute that wrap links and images
  will have different behavior and hence rendering compared to Tidy.

Change-Id: I7a551ef9b7e8f57d7a43c823832f0e3add6b1367
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/CategoryManager.php
M includes/LintErrorsPager.php
5 files changed, 12 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/98/386098/1

diff --git a/extension.json b/extension.json
index 6ce3aa3..566ef08 100644
--- a/extension.json
+++ b/extension.json
@@ -116,6 +116,11 @@
"enabled": true,
"priority": "high",
"parser-migration": true
+   },
+   "tidy-font-bug": {
+   "enabled": true,
+   "priority": "high",
+   "parser-migration": true
}
},
"LinterSubmitterWhitelist": {
diff --git a/i18n/en.json b/i18n/en.json
index 11b097c..451893c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -45,6 +45,8 @@
"linter-category-tidy-whitespace-bug-desc": "These pages trigger a tidy 
whitespace bug that should be worked around.",
"linter-category-html5-misnesting": "Misnested tag with different 
rendering in HTML5 and HTML4",
"linter-category-html5-misnesting-desc": "These misnested tags will 
behave differently in HTML5 compared to HTML4.",
+   "linter-category-tidy-font-bug": "Tidy bug affecting font tags wrapping 
links",
+   "linter-category-tidy-font-bug-desc": "Tidy moves these font tags 
inside links to change link colour",
"linter-numerrors": "($1 {{PLURAL:$1|error|errors}})",
"linker-page-title-edit": "$1 ($2)",
"linker-page-edit": "edit",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 7d9f15c..aac9405 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -25,6 +25,7 @@
"linter-pager-pwrap-bug-workaround-details": "Table column heading",
"linter-pager-tidy-whitespace-bug-details": "Table column heading. 
\"Tidy\" is a name of a software package that transforms HTML files, so it 
doesn't have to be translated. For information about the bug, see the commit 
message https://gerrit.wikimedia.org/r/#/c/371068 .",
"linter-pager-html5-misnesting-details": "Table column heading.",
+   "linter-pager-tidy-font-bug-details": "Table column heading.",
"linter-category-fostered": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/fostered]]",
"linter-category-fostered-desc": "Description of category.",
"linter-category-obsolete-tag": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/obsolete-tag]]",
@@ -49,6 +50,8 @@
"linter-category-tidy-whitespace-bug-desc": "Description of category.",
"linter-category-html5-misnesting": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/html5-misnesting]]",
"linter-category-html5-misnesting-desc": "Description of category",
+   "linter-category-tidy-font-bug": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/tidy-font-bug]]",
+   "linter-category-tidy-font-bug-desc": "Description of category",
"linter-numerrors": "Shown after a category link to indicate how many 
errors are in that category. $1 is the number of errors, and can be used for 
PLURAL.\n{{Identical|Error}}",
"linker-page-title-edit": "Used in a table cell. $1 is a link to the 
page, $2 is pipe separated links to the edit and history pages, the link text 
is {{msg-mw|linker-page-edit}} and {{msg-mw|linker-page-history}}",
"linker-page-edit": "Link text for edit link in 
{{msg-mw|linker-page-title-edit}}\n{{Identical|Edit}}",
diff --git a/includes/CategoryManager.php b/includes/CategoryManager.php
index 614bf17..3e57251 100644
--- a/includes/CategoryManager.php
+++ b/includes/CategoryManager.php
@@ -48,6 +48,7 @@
'tidy-whitespace-bug' => 10,
'multi-colon-escape' => 11,
'html5-misnesting' => 12,
+   'tidy-font-bug' => 13,
];
 
/**
diff --git a/includes/LintErrorsPager.php b/includes/LintErrorsPager.php
index 43b6473..f7ee521 100644
--- a/includes/LintErrorsPager.php
+++ b/includes/LintErrorsPager.php
@@ -143,6 +143,7 @@
'misnested-tag',
'stripped-tag',
'html5-misnesting',
+   'tidy-font-bug',
];
  

[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update src to 6fd67276 for deb v0.8.0 pkg + update maintaine...

2017-10-23 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386051 )

Change subject: Update src to 6fd67276 for deb v0.8.0 pkg + update maintainer 
info
..

Update src to 6fd67276 for deb v0.8.0 pkg + update maintainer info

Change-Id: I08a5e5975b6d8dc6afdd6442d05cc164f0d950c6
---
M debian/control
M src
2 files changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/51/386051/1

diff --git a/debian/control b/debian/control
index 39b604b..2fe8e2d 100644
--- a/debian/control
+++ b/debian/control
@@ -1,7 +1,7 @@
 Source: parsoid
 Section: web
 Priority: optional
-Maintainer: Gabriel Wicke 
+Maintainer: Parsing Team, Wikimedia Foundation 
 Build-Depends: debhelper (>= 8.0.0)
 Standards-Version: 3.9.4
 Homepage: http://www.mediawiki.org/wiki/Parsoid
diff --git a/src b/src
index 1cefef1..6fd6727 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit 1cefef127c51854952f8035ec4b17238a1eda96e
+Subproject commit 6fd67276f629344485146820514111a54fab41b5

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I08a5e5975b6d8dc6afdd6442d05cc164f0d950c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: WIP: Add tidy-font-bug high priority linteer category

2017-10-23 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386016 )

Change subject: WIP: Add tidy-font-bug high priority linteer category
..

WIP: Add tidy-font-bug high priority linteer category

Change-Id: I7510ad39172b4025a79bc6f3f26eb265587c8d8c
---
M lib/wt2html/pp/handlers/linter.js
1 file changed, 63 insertions(+), 0 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 87d1ba0..6de5926 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -452,6 +452,69 @@
};
env.log('lint/obsolete-tag', lintObj);
}
+
+   if (c.nodeName === 'FONT' && c.getAttribute('color')) {
+   /* --
+* Tidy migrates  into the link in these cases
+* [[Foo]]
+* [[Foo]]l (link-trail)
+* [[Foo]]
+* __NOTOC__[[Foo]]
+* [[Category:Foo]][[Foo]]
+* {{1x|[[Foo]]}}
+*
+* Tidy does not migrate  into the link in these cases
+*  [[Foo]]
+* [[Foo]] 
+* [[Foo]]L (not a link-trail)
+* [[Foo]][[Bar]]
+* [[Foo]][[Bar]]
+*
+*  is special.
+* This behavior is not seen with other formatting tags.
+*
+* Remex/parsoid won't do any of this.
+* This difference in behavior only matters when the font tag
+* specifies a link colour because the link no longer renders
+* as blue/red but in the font-specified colour.
+* -- */
+   var tidyFontBug = true;
+   var haveLink = false;
+   var n = c.firstChild;
+   while (n) {
+   if (!DU.isComment(n) &&
+   n.nodeName !== 'A' &&
+   n.nodeName !== 'FIGURE' &&
+   !(n.nodeName === 'SPAN' && 
/\bmw:Image\b/.test(n.getAttribute('typeof'))) &&
+   !DU.isBehaviorSwitch(env, n) &&
+   !DU.isSolTransparentLink(n) &&
+   !(n.nodeName === 'META' && 
Util.TPL_META_TYPE_REGEXP.test(n.getAttribute('typeof')))
+   ) {
+   tidyFontBug = false;
+   break;
+   }
+
+   if (n.nodeName === 'A' || n.nodeName === 'FIGURE') {
+   if (!haveLink) {
+   haveLink = true;
+   } else {
+   tidyFontBug = false;
+   break;
+   }
+   }
+
+   n = n.nextSibling;
+   }
+
+   if (tidyFontBug) {
+   var templateInfo = findEnclosingTemplateName(env, 
tplInfo);
+   env.log('lint/tidy-font-bug', {
+   dsr: findLintDSR(templateInfo, tplInfo, dp.dsr),
+   templateInfo: templateInfo,
+   params: { name: 'font' },
+   });
+   }
+   }
 }
 
 /*

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7510ad39172b4025a79bc6f3f26eb265587c8d8c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Add html5-misnesting category to tools/compare.linter.result...

2017-10-23 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/386001 )

Change subject: Add html5-misnesting category to tools/compare.linter.results.js
..

Add html5-misnesting category to tools/compare.linter.results.js

Change-Id: I5240d4c603a85dcc6f847712743988b6f3a7acc3
---
M tools/compare.linter.results.js
1 file changed, 1 insertion(+), 0 deletions(-)


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

diff --git a/tools/compare.linter.results.js b/tools/compare.linter.results.js
index 2a93e8a..6731cc2 100755
--- a/tools/compare.linter.results.js
+++ b/tools/compare.linter.results.js
@@ -80,6 +80,7 @@
"pwrap-bug-workaround",
"self-closed-tag",
"tidy-whitespace-bug",
+   "html5-misnesting",
 ];
 
 var argv = opts.argv;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5240d4c603a85dcc6f847712743988b6f3a7acc3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Provide accurate DSR offsets for issues in extension...

2017-10-13 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/384198 )

Change subject: Linter: Provide accurate DSR offsets for issues in extension 
content
..

Linter: Provide accurate DSR offsets for issues in extension content

* DSR info was being blindly updated to entire extension range
  instead of looking inside the extension content.

* Updated mocha test that now has updated DSR offsets.

Bug: T178217
Change-Id: I7d99c1771fb4d55866d296ecd283202bfc62a8ed
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 17 insertions(+), 22 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index fbd4d24..6f12352 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -229,8 +229,11 @@
var templateInfo;
 
if (tplInfo) {
-   dsr = tplInfo.dsr;
templateInfo = findEnclosingTemplateName(env, tplInfo);
+   }
+
+   if (templateInfo) {
+   dsr = tplInfo.dsr;
} else if (dp.tmp.origDSR) {
// During DSR computation, stripped meta tags
// surrender their width to its previous sibling.
@@ -420,15 +423,11 @@
// Let us carry on with regularly scheduled programming.
}
 
-   var dsr;
-   var templateInfo;
-   if (tplInfo) {
-   dsr = tplInfo.dsr;
-   templateInfo = findEnclosingTemplateName(env, tplInfo);
-   } else {
-   dsr = DU.getDataParsoid(maybeTable).dsr;
-   }
-   var lintObj = { dsr: dsr, templateInfo: templateInfo };
+   var templateInfo = tplInfo ? findEnclosingTemplateName(env, tplInfo) : 
null;
+   var lintObj = {
+   dsr: templateInfo ? tplInfo.dsr : 
DU.getDataParsoid(maybeTable).dsr,
+   templateInfo: templateInfo
+   };
env.log('lint/fostered', lintObj);
 
return maybeTable;
@@ -456,7 +455,7 @@
templateInfo = findEnclosingTemplateName(env, tplInfo);
}
var lintObj = {
-   dsr: tplInfo ? tplInfo.dsr : dp.dsr,
+   dsr: templateInfo ? tplInfo.dsr : dp.dsr,
templateInfo: templateInfo,
params: { name: c.nodeName.toLowerCase() },
};
@@ -482,7 +481,7 @@
templateInfo = findEnclosingTemplateName(env, 
tplInfo);
}
env.log('lint/bogus-image-options', {
-   dsr: tplInfo ? tplInfo.dsr : dp.dsr,
+   dsr: templateInfo ? tplInfo.dsr : dp.dsr,
templateInfo: templateInfo,
params: { items: items },
});
@@ -516,6 +515,9 @@
var dsr;
if (tplInfo) {
templateInfo = findEnclosingTemplateName(env, 
tplInfo);
+   }
+
+   if (templateInfo) {
dsr = tplInfo.dsr;
} else {
// Identify the dsr-span of the opening tag
@@ -569,12 +571,9 @@
var dsr, templateInfo;
if (tplInfo) {
templateInfo = 
findEnclosingTemplateName(env, tplInfo);
-   dsr = tplInfo.dsr;
-   } else {
-   dsr = dp.dsr;
}
var lintObj = {
-   dsr: dsr,
+   dsr: templateInfo ? tplInfo.dsr : 
dp.dsr,
templateInfo: templateInfo,
params: { root: 
node.parentNode.nodeName, child: node.nodeName },
};
@@ -701,17 +700,13 @@
var dsr, templateInfo;
if (tplInfo) {
templateInfo = findEnclosingTemplateName(env, tplInfo);
-   dsr = tplInfo.dsr;
}
var n = nowrapNodes.length - 1;
nowrapNodes.forEach(function(o, i) {
if (o.tidybug && i < n) {
-   if (!tplInfo) {
-   dsr = DU.getDataParsoid(o.node).dsr;
-   }
if (!nowrapNodes[i + 1].hasLeadingWS) {
var lintObj = {
-   dsr: dsr,
+   dsr: templateInfo ? tplInfo.dsr :  
DU.getDataParsoid(o.node).dsr,
  

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Update reverse interwiki map to prefer language prefixes ove...

2017-10-13 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/384171 )

Change subject: Update reverse interwiki map to prefer language prefixes over 
others
..

Update reverse interwiki map to prefer language prefixes over others

* Updated a bunch of parser tests to reflect the change.

Bug: T177784
Change-Id: I5cf93950a6da69263fb9da59fba2b33cc2e8931f
---
M lib/config/WikiConfig.js
M tests/parserTests-blacklist.js
M tests/parserTests.txt
3 files changed, 38 insertions(+), 21 deletions(-)


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

diff --git a/lib/config/WikiConfig.js b/lib/config/WikiConfig.js
index e9f8e48..52e1c4f 100644
--- a/lib/config/WikiConfig.js
+++ b/lib/config/WikiConfig.js
@@ -232,14 +232,12 @@
}
});
 
-   var cachedMatcher = null;
-   this.interWikiMatcher = function() {
-   if (cachedMatcher) {
-   return cachedMatcher;
-   }
-   var keys = [];
-   var patterns = [];
+   var updatePatterns = function(keys, patterns, filter) {
conf.interwikiMap.forEach(function(val, key) {
+   if (!filter(val)) {
+   return;
+   }
+
var url = val.url;
var protocolRelative = url.startsWith('//');
if (val.protorel !== undefined) {
@@ -271,6 +269,20 @@
patterns.push('^' + val.prefix + '%3A(.*?)');
}
});
+   }
+
+   var cachedMatcher = null;
+   this.interWikiMatcher = function() {
+   if (cachedMatcher) {
+   return cachedMatcher;
+   }
+   var keys = [];
+   var patterns = [];
+   // For html -> wt reverse mapping, prefer language interwiki 
prefixes
+   // over other interwiki prefixes. So, use "en" instead of 
"wikipedia"
+   // for English wikipedia interwiki links.
+   updatePatterns(keys, patterns, function(val) { return 
!!val.language; });
+   updatePatterns(keys, patterns, function(val) { return 
!val.language; });
var reString = '^(?:' + patterns.join('|') + ')$';
var regExp = new RegExp(reString, 'i');
var matchFunc = function(s) {
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 0c418d9..0cd0c61 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -358,6 +358,7 @@
 add("html2html", "Internal link with is link prefix", "Aðrir mótmælendasöfnuðir
 og\n");
 add("html2html", "Internal link with is link trail and link prefix", "xxxar\nmótmælendatrúar\nmótmælendasöfnuður\nmótmælendasöfnuðir\nmótmælendasöfnuðirxxx\n");
 add("html2html", "Parsoid-centric test: Whitespace in ext- and wiki-links 
should be preserved", "
  bar\n\n
  bar\n\nhttp://wp.org\"; 
data-parsoid='{\"targetOff\":59,\"contentOffsets\":[59,62],\"dsr\":[44,63,15,1]}'>foo\n\nhttp://wp.org\"; 
data-parsoid='{\"targetOff\":80,\"contentOffsets\":[80,87],\"dsr\":[65,88,15,1]}'>foo\n");
+add("html2html", "Interwiki link encoding conversion (T3636)\n+!! 
options\n+parsoid=wt2html,wt2wt\n+## html2wt and html2html will fail because we 
will prefer the :en: interwiki prefix over wikipedia:", " Wikipedia:ro:Olteniţa\n Wikipedia:ro:Olteniţa\n");
 add("html2html", "Space and question mark encoding in interlanguage links 
(T95473)", "Blah blah blah\nhttp://es.wikipedia.org/wiki/Foo_bar?\"; 
data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"http://es.wikipedia.org/wiki/Foo_bar?\"},\"sa\":{\"href\":\"es:Foo_bar?\"},\"dsr\":[15,30,null,null]}'/>");
 add("html2html", "Parsoid-specific test: Wikilinks with   should RT 
properly", "[/index.php?title=WW_II&action=edit&redlink=1
 WW II]\n");
 add("html2html", " to ", "1\n2\n3\n");
@@ -652,7 +653,7 @@
 add("html2wt", "Internal link with is link prefix", "Aðrir 
[[wiki/Söfnuður|mótmælendasöfnuðir]] og\n");
 add("html2wt", "Internal link with is link trail and link prefix", 
"[[wiki/Mótmælendatrú|xxxar]]\n[[wiki/Mótmælendatrú|mótmælendatrúar]]\n[[wiki/Söfnuður|mótmælendasöfnuður]]\n[[wiki/Söfnuður|mótmælendasöfnuðir]]\n[[wiki/Söfnuður|mótmælendasöfnuðirxxx]]\n");
 add("html2wt", "Parsoid-centric test: Whitespace in ext- and wiki-links should 
be preserved", "[[wiki/Foo|  bar]]\n\n[[wiki/Foo|  ''bar'']]\n\n[http://wp.org 
foo]\n\n[http://wp.org ''foo'']\n");
-add("html2wt", "Interwiki link encoding conversion (T3636)", "* 
[[wikipedia:ro:Olteniţa|Wikipedia:ro:Olteniţa]]\n* 
[[wikipedia:ro:Olteniţa|Wikipedia:ro:Olteniţa]]\n");
+add("html2wt", "Interwiki link encoding conversion (T3636)\n+!! 
options\n+parsoid=wt2html,wt2wt\n+## html2wt and html2html will fail because we 
will prefer the :en: 

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Improve reporting of parse times by tracking initializations

2017-10-12 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383936 )

Change subject: Improve reporting of parse times by tracking initializations
..

Improve reporting of parse times by tracking initializations

Change-Id: Ic674cdcdc0e0e15c4c9e89be79155e953ce78d91
---
M bin/parse.js
M lib/wt2html/parser.js
2 files changed, 16 insertions(+), 1 deletion(-)


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

diff --git a/bin/parse.js b/bin/parse.js
index ba32008..3c0d1ae 100755
--- a/bin/parse.js
+++ b/bin/parse.js
@@ -19,6 +19,8 @@
 var yargs = require('yargs');
 var yaml = require('js-yaml');
 
+var initTime;
+
 process.on('SIGUSR2', function() {
var heapdump = require('heapdump');
console.error('SIGUSR2 received! Writing snapshot.');
@@ -240,12 +242,16 @@
 
 var parse = exports.parse = function(input, argv, parsoidConfig, prefix, 
domain) {
var env;
+   var s1, s2;
+   s1 = Date.now();
return ParserEnv.getParserEnv(parsoidConfig, {
prefix: prefix,
domain: domain,
pageName: argv.page,
}).then(function(_env) {
env = _env;
+   env.startTime = s1;
+   env.bumpTimeUse("Init", initTime);
 
// fetch templates from enwiki by default.
if (argv.wgScriptPath) {
@@ -294,6 +300,9 @@
if (typeof input === 'string') {
return input;
}
+
+   s2 = Date.now();
+   env.bumpTimeUse("Setup Environment", s2 - s1);
 
if (argv.inputfile) {
// read input from the file, then process
@@ -348,6 +357,7 @@
}
return startsAtHTML(argv, env, str, pb);
} else {
+   env.bumpTimeUse("Pre-parse (source fetch)", Date.now() 
- s2);
return startsAtWikitext(argv, env, str);
}
});
@@ -355,6 +365,7 @@
 
 if (require.main === module) {
(function() {
+   var start = Date.now();
var defaultModeStr = "Default conversion mode : --wt2html";
 
var opts = yargs.usage(
@@ -448,6 +459,8 @@
}
}
 
+   initTime = Date.now() - start;
+
return parse(null, argv, pc, prefix, domain)
.then(function(res) {
var stdout = process.stdout;
diff --git a/lib/wt2html/parser.js b/lib/wt2html/parser.js
index dc77ed9..caf40ce 100644
--- a/lib/wt2html/parser.js
+++ b/lib/wt2html/parser.js
@@ -478,7 +478,9 @@
// maintained across all pipelines used by the document.
// (Ex: Cite state)
this.resetState({ toplevel: true });
-   this.env.startTime = Date.now();
+   if (!this.env.startTime) {
+   this.env.startTime = Date.now();
+   }
this.env.log('trace/time', 'Starting parse at ', this.env.startTime);
this.process(input);
 };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic674cdcdc0e0e15c4c9e89be79155e953ce78d91
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to ddf7b293 for deploy

2017-10-11 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383624 )

Change subject: Bump src to ddf7b293 for deploy
..

Bump src to ddf7b293 for deploy

Change-Id: Id1ba4c1a93b4b3d1039762bef4f0a4a42a25d7cf
---
M src
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/24/383624/1

diff --git a/src b/src
index a47a898..ddf7b29 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit a47a89845a93b4cd1fa961494d156f2555ce2531
+Subproject commit ddf7b293b882e72a8479a4e26b9ccc16ecf6f367

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id1ba4c1a93b4b3d1039762bef4f0a4a42a25d7cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Suppress more false positives for html5-misnesting

2017-10-10 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383504 )

Change subject: Linter: Suppress more false positives for html5-misnesting
..

Linter: Suppress more false positives for html5-misnesting

* Should be the last of these

Change-Id: I340efd3a26a4300e22ab8a05f45bec38d52a24ed
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 12 insertions(+), 5 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 10c2a74..fbd4d24 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -182,11 +182,10 @@
 }
 
 function hasMisnestableContent(node, name) {
-   // This check for 'A' tag is because Tidy doesn't
-   // seem to do the fixups outside the  tag.
-   // FIXME: Test if there are other tags that have
-   // similar behavior.
-   if (DU.isBody(node) || node.nodeName === 'A') {
+   // For A, TD, TH, H* tags, Tidy doesn't seem topropagate
+   // the unclosed tag outside these tags.
+   // No need to check for tr/table since content cannot show up there
+   if (DU.isBody(node) || /^(A|TD|TH|H\d)$/.test(node.nodeName)) {
return false;
}
 
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index a503516..29d360f 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -684,6 +684,14 @@
result[0].params.should.have.a.property("name", 
"span");
});
});
+   it('should not trigger html5 misnesting when unclosed tag is 
inside a td/th/heading tags', function() {
+   return parseWT('=x=\n{|\n!z\n|-\n|id="3"\n|}').then(function(result) {
+   result.should.have.length(3);
+   result[0].should.have.a.property("type", 
"missing-end-tag");
+   result[1].should.have.a.property("type", 
"missing-end-tag");
+   result[2].should.have.a.property("type", 
"missing-end-tag");
+   });
+   });
it('should not trigger html5 misnesting when misnested content 
is outside an a-tag (without link-trails)', function() {
return 
parseWT('[[Foo|foo]]Bar').then(function(result) {
result.should.have.length(2);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I340efd3a26a4300e22ab8a05f45bec38d52a24ed
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Update HISTORY.md for new debian release

2017-10-10 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383368 )

Change subject: Update HISTORY.md for new debian release
..

Update HISTORY.md for new debian release

* This only has a notable summary of changes and is not
  a exhaustive listing of all bug fixes and changes.

Change-Id: Ibfbd52dab2cfe53dc221f02c04afd70d37b10433
---
M HISTORY.md
1 file changed, 56 insertions(+), 0 deletions(-)


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

diff --git a/HISTORY.md b/HISTORY.md
index b69ac20..d7b6bac 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,3 +1,59 @@
+0.8.0 / 2017-10-06
+==
+  Notable wt -> html changes:
+  * Parse and serialize language converter markup
+  * Support video and audio content
+  * Markup red links, disambiguation links in Parsoid HTML
+  * Support HTML5 elements in older browsers
+  * Generalize removal of useless p-wrappers
+  * Improve handling of tokens in parser function targets
+  * More permissive attribute name parsing
++ match PHP parser's attribute sanitizer
+  * Remove dependence on native parser functions
+  * Stop using usePHPPreProcessor as a proxy for an existing mw api to parse 
extensions
+  * Handle templated template names
+  * Handle [[Media:Foo.jpg]] syntax correctly
+  * Several bug fixes
+
+  Notable html -> wt changes:
+  * Use improved format specifier for TemplateData enabling templates
+to control formatting of transclusions after VE edits
+  * Cleanup in separator handling in the wikitext serializer
+  * Fix unhandled detection of modified link content
+  * Handle interwiki shortcuts
+  * Several bug fixes
+
+  API:
+  * Remove support for pb2html in the http api
+
+  Extensions:
+  * Cite:
+- Add support for Cite's `responsive` parameter
+  * Gallery:
+- Remove inline styling for vertical alignment in traditional galleries
+- All media should scale in gallery
+
+  Dependencies:
+  * Upgrade service-runner, mediawiki-title
+  * Use uuid instead of node-uuid
+  * Upgrade several dependencies to deal with security advisories
+
+  Infrastructure:
+  * Migrate from jshint to eslint
+
+  Notable wikitext linting changes:
+  * Only lint pages that have wikitext contentmodel
+  * Lint multiple colon escaped links (incorrect usage)
+  * Add an API endpoint to get lint errors for wikitext
+  * Turn off ignored-table-attr output
+  * Add detection for several wikitext patterns that render differently
+in Tidy compared to a HTML5 based parser (Parsoid, RemexHTML).
+This is only relevant if you want to fix pages before replacing
+Tidy or if you want to use Parsoid HTML for non-edit purposes.
+
+  Other:
+  * Add code of conduct file to the repo
+
 0.7.1 / 2017-04-05
 ==
   No changes.  New release to update nodejs dependency in the deb package.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibfbd52dab2cfe53dc221f02c04afd70d37b10433
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to a47a8984 for deploy to beta cluster

2017-10-06 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382838 )

Change subject: Bump src to a47a8984 for deploy to beta cluster
..

Bump src to a47a8984 for deploy to beta cluster

Change-Id: I46346b69f4a9e293d42cc164257590efee586a3c
---
M src
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/38/382838/1

diff --git a/src b/src
index 772e11b..a47a898 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit 772e11bfa7e5dc62ff9aefd4fbd5b09a846467ab
+Subproject commit a47a89845a93b4cd1fa961494d156f2555ce2531

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I46346b69f4a9e293d42cc164257590efee586a3c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to deploy-2017-10-06 branch

2017-10-06 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382748 )

Change subject: Bump src to deploy-2017-10-06 branch
..

Bump src to deploy-2017-10-06 branch

Change-Id: I3381d6ce4f6e2fb3e03c511ea2533bbbd633c712
---
M src
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/48/382748/1

diff --git a/src b/src
index 477942c..772e11b 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit 477942c3cb4bfa701e70a615e6f11c6d6ca40c61
+Subproject commit 772e11bfa7e5dc62ff9aefd4fbd5b09a846467ab

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3381d6ce4f6e2fb3e03c511ea2533bbbd633c712
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Useless p-wrapper stripping shouldn't get tripped by tpl met...

2017-10-06 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382729 )

Change subject: Useless p-wrapper stripping shouldn't get tripped by tpl meta 
tags
..

Useless p-wrapper stripping shouldn't get tripped by tpl meta tags

* The void tag check was too broad and was trapping tpl-meta-end
  tags causing p-wrappers to be left behind around  tags
  which caused them to get stripped and extended the open 
  tag's range beyond its original place.

* Added a parser test to capture this expectation

Bug: T177612
Change-Id: I58dd86da1329744f069722204fcefd8e1c8f10df
---
M lib/utils/Util.js
M lib/wt2html/tt/ParagraphWrapper.js
M tests/parserTests.txt
3 files changed, 18 insertions(+), 2 deletions(-)


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

diff --git a/lib/utils/Util.js b/lib/utils/Util.js
index acfa500..1de607f 100644
--- a/lib/utils/Util.js
+++ b/lib/utils/Util.js
@@ -472,6 +472,11 @@
return token && token.constructor === pd.SelfclosingTagTk && 
token.name === 'template';
},
 
+   isTemplateMeta: function(t) {
+   if (!DU) { DU = require('./DOMUtils.js').DOMUtils; }
+   return t.name === 'meta' && 
DU.TPL_META_TYPE_REGEXP.test(t.getAttribute('typeof'));
+   },
+
isTableTag: function(token) {
var tc = token.constructor;
return (tc === pd.TagTk || tc === pd.EndTagTk) &&
diff --git a/lib/wt2html/tt/ParagraphWrapper.js 
b/lib/wt2html/tt/ParagraphWrapper.js
index 7170cdd..af24c3b 100644
--- a/lib/wt2html/tt/ParagraphWrapper.js
+++ b/lib/wt2html/tt/ParagraphWrapper.js
@@ -108,9 +108,9 @@
// Comments and inline tags by themselves don't need 
them.
// NOTE: We don't check for block tags since p-tags 
won't wrap block tags.
if (t.constructor === String ||
-   Util.isVoidElement(t.name || '') ||
+   (Util.isVoidElement(t.name || '') && 
!Util.isTemplateMeta(t)) ||
// FIXME: do we need a more precise test?
-   /\bmw:/.test(t.constructor === TagTk ? 
t.getAttribute('typeof') : null)
+   Util.hasParsoidTypeOf(t.constructor === TagTk 
&& t.getAttribute('typeof'))
) {
return start;
}
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index df4e9c3..7cff659 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -1928,6 +1928,17 @@
 x
 !! end
 
+# T177612: Parsoid-only test
+!! test
+Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping 
code
+!! wikitext
+{{echo|x}}
+x
+!! html/parsoid
+x
+x
+!! end
+
 !! test
 Block tag on one line ()
 !! wikitext

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I58dd86da1329744f069722204fcefd8e1c8f10df
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Suppress html5-misnesting false positives due to Tid...

2017-10-05 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382512 )

Change subject: Linter: Suppress html5-misnesting false positives due to Tidy 
weirdness
..

Linter: Suppress html5-misnesting false positives due to Tidy weirdness

* Test cases should explain it.
* Discovered by running snippets through php parse.php --tidy.

Change-Id: Ibcde3fcd5f20f7f18fb72ff2c4b5aa241b063fd0
---
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
2 files changed, 35 insertions(+), 1 deletion(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 326706b..a198934 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -164,6 +164,23 @@
}
 }
 
+function hasIdenticalNestedTag(node, name) {
+   var c = node.firstChild;
+   while (c) {
+   if (c.nodeName === name && 
!DU.getDataParsoid(c).autoInsertedInd) {
+   return true;
+   }
+
+   if (DU.isElt(c)) {
+   return hasIdenticalNestedTag(c, name);
+   }
+
+   c = c.nextSibling;
+   }
+
+   return false;
+}
+
 function hasMisnestableContent(node, name) {
// This check for 'A' tag is because Tidy doesn't
// seem to do the fixups outside the  tag.
@@ -270,7 +287,9 @@
// changes (to wikitext or html specs), let us make it 
explicit.
if (DU.hasLiteralHTMLMarker(dp) &&

getTagsWithChangedMisnestingBehavior().has(c.nodeName) &&
-   hasMisnestableContent(c, c.nodeName)
+   hasMisnestableContent(c, c.nodeName) &&
+   // Tidy WTF moment here!
+   !hasIdenticalNestedTag(c, c.nodeName)
) {
env.log('lint/html5-misnesting', lintObj);
} else {
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index 713a1b2..528cb67 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -712,5 +712,20 @@
result[0].params.should.have.a.property("name", 
"small");
});
});
+   it('should not trigger html5 misnesting for span if there is a 
nested span tag', function() {
+   return 
parseWT('fooboo\n\nbar').then(function(result) {
+   result.should.have.length(2);
+   result[0].should.have.a.property("type", 
"missing-end-tag");
+   result[1].should.have.a.property("type", 
"stripped-tag");
+   });
+   });
+   it('should trigger html5 misnesting for span if there is a 
nested unclosed span tag', function() {
+   return 
parseWT('fooboo\n\nbar').then(function(result) {
+   result.should.have.length(3);
+   result[0].should.have.a.property("type", 
"missing-end-tag");
+   result[1].should.have.a.property("type", 
"html5-misnesting");
+   result[2].should.have.a.property("type", 
"stripped-tag");
+   });
+   });
});
 });

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibcde3fcd5f20f7f18fb72ff2c4b5aa241b063fd0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Update eqiad canaries to wtp1025 and wtp1026

2017-10-04 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382255 )

Change subject: Update eqiad canaries to wtp1025 and wtp1026
..

Update eqiad canaries to wtp1025 and wtp1026

wtp1001 - wtp1024 have been decommissioned.

Change-Id: Id99fad8037521747d754773a194e894a03ec3c01
---
M scap/target-canary
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/55/382255/1

diff --git a/scap/target-canary b/scap/target-canary
index 5602d57..fd933f3 100644
--- a/scap/target-canary
+++ b/scap/target-canary
@@ -2,5 +2,5 @@
 # $wgLinterSubmitterWhitelist in operations/mediawiki-config
 wtp2001.codfw.wmnet
 wtp2002.codfw.wmnet
-wtp1001.eqiad.wmnet
-wtp1002.eqiad.wmnet
+wtp1025.eqiad.wmnet
+wtp1026.eqiad.wmnet

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id99fad8037521747d754773a194e894a03ec3c01
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to 7ec1f836 for deploy

2017-10-04 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/382179 )

Change subject: Bump src to 7ec1f836 for deploy
..

Bump src to 7ec1f836 for deploy

Change-Id: Iba5450a58ecdef211f4cade34bdb99909f3ebefa
---
M src
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/79/382179/1

diff --git a/src b/src
index 2f4b9a8..7ec1f83 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit 2f4b9a8cf9e2fdf8d534eaae1d4ec4fadeb85f2c
+Subproject commit 7ec1f8369ef2e620858b40eadb7c43f1c4fa6d3d

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba5450a58ecdef211f4cade34bdb99909f3ebefa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: Fix incorrect message

2017-10-03 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/381989 )

Change subject: Fix incorrect message
..

Fix incorrect message

Bug: T177286
Change-Id: I26d549e7185be7dad7e451f9545b56d2e5556b61
---
M i18n/en.json
M i18n/qqq.json
2 files changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/89/381989/1

diff --git a/i18n/en.json b/i18n/en.json
index 2248a0e..11b097c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -20,7 +20,7 @@
"linter-pager-misnested-tag-details": "Misnested tag which should be 
properly nested",
"linter-pager-pwrap-bug-workaround-details": "Paragraph wrapping bug 
workaround",
"linter-pager-tidy-whitespace-bug-details": "Tidy whitespace bug",
-   "linter-pager-html5-nesting": "Misnesting in HTML5 (but not in Tidy)",
+   "linter-pager-html5-misnesting-details": "Misnesting in HTML5 (but not 
in Tidy)",
"linter-category-fostered": "Fostered content",
"linter-category-fostered-desc": "These pages have fostered content.",
"linter-category-obsolete-tag": "Obsolete HTML tags",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 91daff1..7d9f15c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -24,7 +24,7 @@
"linter-pager-misnested-tag-details": "Table column heading",
"linter-pager-pwrap-bug-workaround-details": "Table column heading",
"linter-pager-tidy-whitespace-bug-details": "Table column heading. 
\"Tidy\" is a name of a software package that transforms HTML files, so it 
doesn't have to be translated. For information about the bug, see the commit 
message https://gerrit.wikimedia.org/r/#/c/371068 .",
-   "linter-pager-html5-nesting": "Table column heading",
+   "linter-pager-html5-misnesting-details": "Table column heading.",
"linter-category-fostered": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/fostered]]",
"linter-category-fostered-desc": "Description of category.",
"linter-category-obsolete-tag": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/obsolete-tag]]",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26d549e7185be7dad7e451f9545b56d2e5556b61
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Minor: Rename BlockTags to HTML4BlockTags

2017-10-02 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/381894 )

Change subject: Minor: Rename BlockTags to HTML4BlockTags
..

Minor: Rename BlockTags to HTML4BlockTags

HTML5 does not have a notion of block tags

Change-Id: Ie5bdf914276af46912f5b71226b8a30d82c415f2
---
M lib/config/WikitextConstants.js
M lib/utils/Util.js
M lib/wt2html/pp/handlers/linter.js
3 files changed, 3 insertions(+), 3 deletions(-)


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

diff --git a/lib/config/WikitextConstants.js b/lib/config/WikitextConstants.js
index cb603c9..a686058 100644
--- a/lib/config/WikitextConstants.js
+++ b/lib/config/WikitextConstants.js
@@ -197,7 +197,7 @@
// From 
https://developer.mozilla.org/en-US/docs/HTML/Block-level_elements
// However, you probably want to use `Util.isBlockTag()`, where 
some
// exceptions are being made.
-   BlockTags: new Set([
+   HTML4BlockTags: new Set([
'DIV', 'P',
// tables
'TABLE', 'TBODY', 'THEAD', 'TFOOT', 'CAPTION', 'TH', 
'TR', 'TD',
diff --git a/lib/utils/Util.js b/lib/utils/Util.js
index f66f734..acfa500 100644
--- a/lib/utils/Util.js
+++ b/lib/utils/Util.js
@@ -429,7 +429,7 @@
 */
isBlockTag: function(name) {
name = name.toUpperCase();
-   return name !== 'VIDEO' && Consts.HTML.BlockTags.has(name);
+   return name !== 'VIDEO' && Consts.HTML.HTML4BlockTags.has(name);
},
 
/**
diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 3691414..326706b 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -61,7 +61,7 @@
tagsWithChangedMisnestingBehavior = new Set();
Consts.HTML.HTML5Tags.forEach(function(t) {
if (Consts.Sanitizer.TagWhiteList.has(t) &&
-   !Consts.HTML.BlockTags.has(t) &&
+   !Consts.HTML.HTML4BlockTags.has(t) &&
!Consts.HTML.FormattingTags.has(t) &&
!Consts.HTML.VoidTags.has(t)
) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5bdf914276af46912f5b71226b8a30d82c415f2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Add a list of HTML4 Inline tags

2017-10-02 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/381895 )

Change subject: Add a list of HTML4 Inline tags
..

Add a list of HTML4 Inline tags

Change-Id: Ibcb862c5ea7d761cfa8ee39feb2b75f6996e39ee
---
M lib/config/WikitextConstants.js
1 file changed, 24 insertions(+), 0 deletions(-)


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

diff --git a/lib/config/WikitextConstants.js b/lib/config/WikitextConstants.js
index a686058..0a04d3d 100644
--- a/lib/config/WikitextConstants.js
+++ b/lib/config/WikitextConstants.js
@@ -213,6 +213,30 @@
'MAP', 'OBJECT', 'PRE', 'PROGRESS', 'VIDEO',
]),
 
+   // From 
https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
+   // plus some non-strict elements not on that list (FONT, S, 
STRIKE, U) since
+   // these are tags that are actually used on wikipedias
+   //
+   // All HTML5 formatting elements except NOBR is on this list
+   HTML4InlineTags: new Set([
+   'A',  'ABBR', /* 'ACRONYM' */,
+   'B', 'BIG', 'BDO', 'BR', 'BUTTON',
+   'CITE', 'CODE',
+   'DFN',
+   'EM',
+   'FONT',
+   'I', 'IMG', 'INPUT',
+   'KBD',
+   'LABEL',
+   'MAP',
+   'Q',
+   'OBJECT',
+   'S', 'SAMP', 'SCRIPT', 'SELECT', 'SMALL', 'SPAN', 
'STRIKE', 'STRONG', 'SUB', 'SUP',
+   'TEXTAREA', 'TIME', 'TT',
+   'U',
+   'VAR',
+   ]),
+
// See 
http://www.w3.org/html/wg/drafts/html/master/syntax.html#formatting
FormattingTags: new Set([
'A', 'B', 'BIG', 'CODE', 'EM', 'FONT', 'I', 'NOBR',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibcb862c5ea7d761cfa8ee39feb2b75f6996e39ee
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Apply removeUselessPWrappers to all tags except void tags

2017-09-29 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/381518 )

Change subject: Apply removeUselessPWrappers to all tags except void tags
..

Apply removeUselessPWrappers to all tags except void tags

* For some reason, this was only being applied to formatting tags.
  Probably an oversight without adequate test coverage.

* Added a new parser test even though we have a newly passing
  test that was previously failing. This new test is clearer in
  terms of testing the p-wrapping expecation here.

Bug: T177115
Change-Id: I591fda8e8e484f4f584a3f97eaefb11e54ec2a4d
---
M lib/wt2html/tt/ParagraphWrapper.js
M tests/parserTests-blacklist.js
M tests/parserTests.txt
3 files changed, 25 insertions(+), 14 deletions(-)


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

diff --git a/lib/wt2html/tt/ParagraphWrapper.js 
b/lib/wt2html/tt/ParagraphWrapper.js
index 1140c82..8431dca 100644
--- a/lib/wt2html/tt/ParagraphWrapper.js
+++ b/lib/wt2html/tt/ParagraphWrapper.js
@@ -98,7 +98,8 @@
for (var i = 0, n = res.length; i < n; i++) {
var t = res[i];
if (i + 2 < n && t.constructor === TagTk && t.name === 'p' && 
!Util.isHTMLTag(t) &&
-   Consts.HTML.FormattingTags.has((res[i + 1].name || 
'').toUpperCase()) &&
+   Consts.HTML.HTML5Tags.has((res[i + 1].name || 
'').toUpperCase()) &&
+   !Consts.HTML.VoidTags.has((res[i + 1].name || 
'').toUpperCase()) &&
res[i + 2].constructor === EndTagTk && res[i + 2].name 
=== 'p' && !Util.isHTMLTag(res[i + 2])) {
// Init newRes
if (newRes === null) {
diff --git a/tests/parserTests-blacklist.js b/tests/parserTests-blacklist.js
index 583c919..beb7da9 100644
--- a/tests/parserTests-blacklist.js
+++ b/tests/parserTests-blacklist.js
@@ -63,7 +63,6 @@
 add("wt2html", "Space and question mark encoding in interlanguage links 
(T95473)", "Blah blah blah\nhttp://es.wikipedia.org/wiki/Foo%20bar?\"; 
data-parsoid='{\"stx\":\"simple\",\"a\":{\"href\":\"http://es.wikipedia.org/wiki/Foo%20bar?\"},\"sa\":{\"href\":\"es:Foo
 bar?\"},\"dsr\":[15,30,null,null]}'/>");
 add("wt2html", "2. Lists with start-of-line-transparent tokens before bullets: 
Template close", "foo
 bar\n*baz");
 add("wt2html", "Multiple list tags generated by templates", "a\nb\nc");
-add("wt2html", "Unbalanced closing non-block tags don't break a list\n(php 
parser relies on Tidy to fix up)", "\na\nb");
 add("wt2html", "Magic Word: {{CURRENTMONTH1}}", "Parser
 function implementation for pf_currentmonth1 missing in Parsoid.");
 add("wt2html", "Magic Words LOCAL (UTC)", " 
01\n Parser
 function implementation for pf_localmonth1 missing in 
Parsoid.\n January\n January\n Jan\n 1\n 01\n Thursday\n 1970\n 00:02\n 00\n 1\n 4\n 19700101000203");
 add("wt2html", "Magic Word: {{FULLPAGENAMEE}}", "User:Ævar
 Arnfjörð Bjarmason");
@@ -367,7 +366,6 @@
 add("html2html", "Incorrecly removing closing slashes from correctly formed 
XHTML", "\n");
 add("html2html", "Failing to transform badly formed HTML into correct XHTML", 
"\n\n\n");
 add("html2html", "Handling html with a br self-closing tag", "\n\n\n\n\n\n");
-add("html2html", "Unbalanced closing non-block tags don't break a list\n(php 
parser relies on Tidy to fix up)", "\n\n 
a\n b\n\n");
 add("html2html", "2. List embedded in a formatting tag", "\n\n 
a\n\n b\n");
 add("html2html", "Case-sensitive magic words, when cased differently, should 
just be template transclusions", "[/index.php?title=Template:CurrentMonth&action=edit&redlink=1
 
Template:CurrentMonth]\n[/index.php?title=Template:Currentday&action=edit&redlink=1
 
Template:Currentday]\n[/index.php?title=Template:CURreNTweEK&action=edit&redlink=1
 
Template:CURreNTweEK]\n[/index.php?title=Template:CurrentHour&action=edit&redlink=1
 Template:CurrentHour]\n");
 add("html2html", "Nonexistent template", "[/index.php?title=Template:Thistemplatedoesnotexist&action=edit&redlink=1
 Template:Thistemplatedoesnotexist]\n");
@@ -1382,17 +1380,19 @@
 add("selser", "Nested lists 6 (both elements empty) [1]", "*\n**");
 add("selser", "Nested lists 6 (both elements empty) [2]", "1ubvum0\n*\n**");
 add("selser", "Nested lists 6 (both elements empty) [[2]]", "* 
1mfyy4i\n*\n**");
-add("selser", "Unbalanced closing non-block tags don't break a list\n(php 
parser relies on Tidy to fix up) [[4],0,[[4,4],3,2]]", 
"6evk37\n*1bkqey414fxlv9\n* 1tlvylr\n*b");
-add("selser", "Unbalanced closing non-block tags don't break a list\n(php 
parser relies on Tidy to fix up) [3,0,1]", "*a\n*b");
-add("selser", "Unbalanced closing non-block tags don't break a list\n(php 
parser relies on Tidy to fix up) [[1],0,1]", "\n*a\n*b");
-add("selser", "Unbalanced closing non-block tags don't break a list\n(php 
parser relies on Tidy to fix up) [2,4,2]", 
"1dnkwk6\

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Improve detection of html5-misnesting issues

2017-09-28 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/381382 )

Change subject: Linter: Improve detection of html5-misnesting issues
..

Linter: Improve detection of html5-misnesting issues

* Found a couple of unhandled scenarios that causes a number
  of false positives in linter reports.

Change-Id: I15b65d534de6e5e23f9c9788cc66e5606331d4b6
---
M lib/utils/DOMUtils.js
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
3 files changed, 55 insertions(+), 7 deletions(-)


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

diff --git a/lib/utils/DOMUtils.js b/lib/utils/DOMUtils.js
index 5de498f..e073bde 100644
--- a/lib/utils/DOMUtils.js
+++ b/lib/utils/DOMUtils.js
@@ -1244,12 +1244,6 @@
return next;
},
 
-   hasFollowingContent: function(node) {
-   return !DU.isBody(node) && (
-   DU.nextNonSepSibling(node) || 
DU.hasFollowingContent(node.parentNode)
-   );
-   },
-
numNonDeletedChildNodes: function(node) {
var n = 0;
var child = node.firstChild;
diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index e69aeaa..e22df86 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -164,6 +164,34 @@
}
 }
 
+function hasMisnestableContent(node, name) {
+   // This check for 'A' tag is because Tidy doesn't
+   // seem to do the fixups outside the  tag.
+   // FIXME: Test if there are other tags that have
+   // similar behavior.
+   if (DU.isBody(node) || node.nodeName === 'A') {
+   return false;
+   }
+
+   var next = DU.nextNonSepSibling(node);
+   if (!next) {
+   return hasMisnestableContent(node.parentNode, name);
+   }
+
+   var contentNode;
+   if (next.nodeName === 'P' && !DU.isLiteralHTMLNode(next)) {
+   contentNode = DU.firstNonSepChildNode(next);
+   } else {
+   contentNode = next;
+   }
+
+   return contentNode &&
+   // If the first "content" node we find is a matching
+   // stripped tag, we have nothing that can get misnested
+   !(DU.isMarkerMeta(contentNode, 'mw:Placeholder/StrippedTag') &&
+ DU.getDataParsoid(contentNode).name === name);
+}
+
 /*
  * Log Treebuilder fixups marked by dom.markTreeBuilderFixup.js
  * It handles the following scenarios:
@@ -242,7 +270,7 @@
// changes (to wikitext or html specs), let us make it 
explicit.
if (DU.hasLiteralHTMLMarker(dp) &&

getTagsWithChangedMisnestingBehavior().has(c.nodeName) &&
-   DU.hasFollowingContent(c)
+   hasMisnestableContent(c, c.nodeName)
) {
env.log('lint/html5-misnesting', lintObj);
} else {
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index f176e9c..523e96a 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -676,6 +676,32 @@
result[0].params.should.have.a.property("name", 
"span");
});
});
+   it('should not trigger html5 misnesting when there is no 
misnested content', function() {
+   return 
parseWT('foo\n\ny').then(function(result) {
+   result.should.have.length(1);
+   result[0].should.have.a.property("type", 
"misnested-tag");
+   result[0].should.have.a.property("params");
+   result[0].params.should.have.a.property("name", 
"span");
+   });
+   });
+   it('should not trigger html5 misnesting when misnested content 
is outside an a-tag (without link-trails)', function() {
+   return 
parseWT('[[Foo|foo]]Bar').then(function(result) {
+   result.should.have.length(2);
+   result[0].should.have.a.property("type", 
"missing-end-tag");
+   result[0].should.have.a.property("params");
+   result[0].params.should.have.a.property("name", 
"span");
+   result[1].should.have.a.property("type", 
"stripped-tag");
+   });
+   });
+   it('should trigger html5 misnesting when linktrails brings 
content inside an a-tag', function() {
+   return 
parseWT('[[Foo|foo]]bar').then(function(result) {
+   result.should.have.length(2);
+   result[0].should.have.a.property("type", 
"ht

[MediaWiki-commits] [Gerrit] mediawiki...Linter[master]: Add html5-misnesting high-priority category

2017-09-22 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/379931 )

Change subject: Add html5-misnesting high-priority category
..

Add html5-misnesting high-priority category

Change-Id: I840c4dfc14308dffd02dd8a89ab4dcac13f6141a
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/CategoryManager.php
M includes/LintErrorsPager.php
5 files changed, 11 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Linter 
refs/changes/31/379931/1

diff --git a/extension.json b/extension.json
index a8275ac..6ce3aa3 100644
--- a/extension.json
+++ b/extension.json
@@ -111,6 +111,11 @@
"multi-colon-escape": {
"enabled": true,
"priority": "medium"
+   },
+   "html5-misnesting": {
+   "enabled": true,
+   "priority": "high",
+   "parser-migration": true
}
},
"LinterSubmitterWhitelist": {
diff --git a/i18n/en.json b/i18n/en.json
index 542d2dd..bb90b07 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -42,6 +42,8 @@
"linter-category-pwrap-bug-workaround-desc": "These pages have a 
paragraph wrapping bug that could be worked around.",
"linter-category-tidy-whitespace-bug": "Tidy whitespace bug",
"linter-category-tidy-whitespace-bug-desc": "These pages trigger a tidy 
whitespace bug that should be worked around.",
+   "linter-category-html5-misnesting": "Misnested tag with different 
rendering in HTML5 and HTML4",
+   "linter-category-html5-misnesting-desc": "These misnested tags will 
behave differently in HTML5 compared to HTML4.",
"linter-numerrors": "($1 {{PLURAL:$1|error|errors}})",
"linker-page-title-edit": "$1 ($2)",
"linker-page-edit": "edit",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index a06715f..8597bfa 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -46,6 +46,8 @@
"linter-category-pwrap-bug-workaround-desc": "Description of category.",
"linter-category-tidy-whitespace-bug": "Name of lint error category. 
See [[:mw:Help:Extension:Linter/tidy-whitespace-bug]]",
"linter-category-tidy-whitespace-bug-desc": "Description of category.",
+   "linter-category-html5-misnesting": "Name of lint error category. See 
[[:mw:Help:Extension:Linter/html5-misnesting]]",
+   "linter-category-html5-misnesting-desc": "Description of category",
"linter-numerrors": "Shown after a category link to indicate how many 
errors are in that category. $1 is the number of errors, and can be used for 
PLURAL.\n{{Identical|Error}}",
"linker-page-title-edit": "Used in a table cell. $1 is a link to the 
page, $2 is pipe separated links to the edit and history pages, the link text 
is {{msg-mw|linker-page-edit}} and {{msg-mw|linker-page-history}}",
"linker-page-edit": "Link text for edit link in 
{{msg-mw|linker-page-title-edit}}\n{{Identical|Edit}}",
diff --git a/includes/CategoryManager.php b/includes/CategoryManager.php
index 23527c7..614bf17 100644
--- a/includes/CategoryManager.php
+++ b/includes/CategoryManager.php
@@ -47,6 +47,7 @@
'pwrap-bug-workaround' => 9,
'tidy-whitespace-bug' => 10,
'multi-colon-escape' => 11,
+   'html5-misnesting' => 12,
];
 
/**
diff --git a/includes/LintErrorsPager.php b/includes/LintErrorsPager.php
index dbf206f..43b6473 100644
--- a/includes/LintErrorsPager.php
+++ b/includes/LintErrorsPager.php
@@ -142,6 +142,7 @@
'self-closed-tag',
'misnested-tag',
'stripped-tag',
+   'html5-misnesting',
];
if ( in_array( $this->category, $hasNameCats ) 
&& isset( $lintError->params['name'] ) ) {
return Html::element( 'code', [], 
$lintError->params['name'] );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I840c4dfc14308dffd02dd8a89ab4dcac13f6141a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Linter
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to 13972c9b + update linter config for scap & debian

2017-09-22 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/379809 )

Change subject: Bump src to 13972c9b + update linter config for scap & debian
..

Bump src to 13972c9b + update linter config for scap & debian

Change-Id: I6f8fe20137ac3950f3dd3fd1f3d539a6f9ca11da
---
M debian/config.yaml
M scap/templates/config.yaml.j2
M src
3 files changed, 9 insertions(+), 4 deletions(-)


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

diff --git a/debian/config.yaml b/debian/config.yaml
index a8d64d2..22f1a35 100644
--- a/debian/config.yaml
+++ b/debian/config.yaml
@@ -81,8 +81,10 @@
 
 # Enable linting of some wikitext errors to the log
 #linting: true
-# Send lint errors to MW API instead of to the log
-#linterSendAPI: false
+#linter:
+#  sendAPI: false # Send lint errors to MW API instead of to the log
+#  apiSampling: 1 # All requests are sampled
+#  tidyWhitespaceBugMaxLength: 100
 
 # Require SSL certificates to be valid (default true)
 # Set to false when using self-signed SSL certificates
diff --git a/scap/templates/config.yaml.j2 b/scap/templates/config.yaml.j2
index c2218de..9cb1e85 100644
--- a/scap/templates/config.yaml.j2
+++ b/scap/templates/config.yaml.j2
@@ -48,7 +48,10 @@
   useBatchAPI: true
   usePHPPreProcessor: true
   linting: <%= linting %>
-  linterSendAPI: <%= linter_send_api %>
+  linter:
+sendAPI: <%= linter_send_api %>
+apiSampling: 1  # All requests, no sampling
+tidyWhitespaceBugMaxLength: 100
 
   mwApiServer: <%= mwapi_server if mwapi_server else '' %>
   defaultAPIProxyURI: <%= mwapi_proxy if mwapi_proxy else '' %>
diff --git a/src b/src
index 05a0965..13972c9 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit 05a09652402402c93c64ef899eb09ff825607c01
+Subproject commit 13972c9b9d0328e5810609774732d56ebf113112

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6f8fe20137ac3950f3dd3fd1f3d539a6f9ca11da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Suppress logspam in production logs

2017-09-21 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/379670 )

Change subject: Suppress logspam in production logs
..

Suppress logspam in production logs

* We have known about these for a long time and we've whacked
  moles over time, but this is the best we are doing for now
  till we do another round of investigation going over parser tests.

* Production is configured for log message level warn and above.

Change-Id: I7d3c870a8852c4419f4501b5c26f0e40699bd28b
---
M lib/html2wt/separators.js
1 file changed, 4 insertions(+), 4 deletions(-)


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

diff --git a/lib/html2wt/separators.js b/lib/html2wt/separators.js
index 1a617d8..2c72f2e 100644
--- a/lib/html2wt/separators.js
+++ b/lib/html2wt/separators.js
@@ -90,7 +90,7 @@
if (b.min !== undefined) {
if (nlConstraints.max !== undefined && 
nlConstraints.max < b.min) {
// Conflict, warn and let nodeB win.
-   env.log("warn", "Incompatible constraints 1:", 
nodeA.nodeName,
+   env.log("info/html2wt", "Incompatible 
constraints 1:", nodeA.nodeName,
nodeB.nodeName, 
loggableConstraints(nlConstraints));
nlConstraints.min = b.min;
nlConstraints.max = b.min;
@@ -102,7 +102,7 @@
if (b.max !== undefined) {
if (nlConstraints.min !== undefined && 
nlConstraints.min > b.max) {
// Conflict, warn and let nodeB win.
-   env.log("warn", "Incompatible constraints 2:", 
nodeA.nodeName,
+   env.log("info/html2wt", "Incompatible 
constraints 2:", nodeA.nodeName,
nodeB.nodeName, 
loggableConstraints(nlConstraints));
nlConstraints.min = b.max;
nlConstraints.max = b.max;
@@ -278,7 +278,7 @@
}
 
res.max = res.min;
-   env.log("warn", 'Incompatible constraints (merge):', res,
+   env.log("info/html2wt", 'Incompatible constraints (merge):', 
res,
loggableConstraints(oldConstraints), 
loggableConstraints(newConstraints));
}
return res;
@@ -629,7 +629,7 @@
sep = src.substring(dsrA[1], dsrB[1] - 
dsrB[3]);
}
} else {
-   this.env.log("warn", "dsr backwards: should not 
happen!");
+   this.env.log("info/html2wt", "dsr backwards: 
should not happen!");
}
 
if (state.sep.lastSourceSep) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d3c870a8852c4419f4501b5c26f0e40699bd28b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Turn off ignored-table-attr output

2017-09-21 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/379586 )

Change subject: Linter: Turn off ignored-table-attr output
..

Linter: Turn off ignored-table-attr output

Change-Id: I2fa5602907c671962722407442f0aa510aeed6b5
---
M lib/wt2html/pp/handlers/linter.js
1 file changed, 28 insertions(+), 32 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index bd6fb5b..299a9b8 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -232,45 +232,38 @@
  *
  * Here foo gets ignored and is found in the data-parsoid of  tags.
  */
-function logIgnoredTableAttr(env, c, dp, tplInfo) {
+function logIgnoredTableAttr(env, node, dp, tplInfo) {
var dsr;
var templateInfo;
-   if (DU.hasNodeName(c, "table")) {
-   var fc = c.firstChild;
-   while (fc) {
-   if (DU.hasNodeName(fc, "tbody")) {
-   var trfc = fc.firstChild;
-   while (trfc) {
-   if (DU.hasNodeName(trfc, "tr")) {
-   dp = DU.getDataParsoid(trfc);
-   if (dp.sa) {
-   var wc = false;
-   // Discard attributes 
that are only whitespace and comments
-   for (var key in dp.sa) {
-   var re = 
/^\s*$|^([ \t]|)*$/;
-   if 
((!re.test(key) || !re.test(dp.sa[key]))) {
-   wc = 
true;
-   break;
-   }
-   }
+   if (!node.nodeName === 'TABLE') {
+   return;
+   }
 
-   if (wc) {
-   if (tplInfo) {
-   dsr = 
tplInfo.dsr;
-   
templateInfo = findEnclosingTemplateName(env, tplInfo);
-   } else {
-   dsr = 
dp.dsr;
-   }
-   var lintObj = { 
dsr: dsr, templateInfo: templateInfo };
-   
env.log('lint/ignored-table-attr', lintObj);
-   }
+   var tbody = DU.firstNonSepChildNode(node);
+   var c = tbody.firstChild;
+   while (c) {
+   if (c.nodeName === 'TR') {
+   dp = DU.getDataParsoid(c);
+   if (dp.sa) {
+   // Discard attributes that are only whitespace 
and comments
+   for (var key in dp.sa) {
+   var re = 
/^\s*$|^([ \t]|)*$/;
+   if (!re.test(key) || 
!re.test(dp.sa[key])) {
+   // FIXME: This is incorrect.
+   // We need to check if the key 
is absent in dp.a / in the node's attribute
+   if (tplInfo) {
+   dsr = tplInfo.dsr;
+   templateInfo = 
findEnclosingTemplateName(env, tplInfo);
+   } else {
+   dsr = dp.dsr;
}
+   var lintObj = { dsr: dsr, 
templateInfo: templateInfo };
+   
env.log('lint/ignored-table-attr', lintObj);
}
-   trfc = trfc.nextSibling;
}
}
-   fc = fc.nextSibling;
}
+   c = c.nextSibling;
}
 }
 
@@ -618,7 +611,10 @@
}
 
logTreeBuilderFixup(env, node, dp, tplInfo);
-   logIgnoredTableAttr(env, node, dp, tplInfo);
+   // Turning this off for now

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Move linter config properties to the linter config object

2017-09-20 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/379429 )

Change subject: Move linter config properties to the linter config object
..

Move linter config properties to the linter config object

Change-Id: Ic198d3833ea849cee07b6298cfb6724bb1e6b0e1
---
M config.example.yaml
M lib/config/ParsoidConfig.js
M lib/logger/LintLogger.js
M lib/utils/Util.js
4 files changed, 23 insertions(+), 20 deletions(-)


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

diff --git a/config.example.yaml b/config.example.yaml
index e74103a..a19f5da 100644
--- a/config.example.yaml
+++ b/config.example.yaml
@@ -84,8 +84,11 @@
 
 # Enable linting of some wikitext errors to the log
 #linting: true
+#linter:
 # Send lint errors to MW API instead of to the log
-#linterSendAPI: false
+#  - sendAPI: false
+# Sampling rate (1 / 10)
+#apiSampling: 10
 
 # Require SSL certificates to be valid (default true)
 # Set to false when using self-signed SSL certificates
diff --git a/lib/config/ParsoidConfig.js b/lib/config/ParsoidConfig.js
index 359dc2e..7f6a364 100644
--- a/lib/config/ParsoidConfig.js
+++ b/lib/config/ParsoidConfig.js
@@ -233,25 +233,25 @@
  */
 ParsoidConfig.prototype.linting = false;
 
-/**
- * @property {boolean} linterSendAPI
- * Whether to send lint errors to the MW API
- * Requires the MW Linter extension to be installed
- * and configured.
- */
-ParsoidConfig.prototype.linterSendAPI = false;
-
-/**
- * @property {number} linterSampling
- *
- * Ratio at which to sample linter errors, per page.
- * This is deterministic and based on page_id.
- */
-ParsoidConfig.prototype.linterAPISampling = 1;
-
 // FIXME: Fold other linter config options into this.
 ParsoidConfig.prototype.linter = {
/**
+* @property {boolean} sendAPI
+* Whether to send lint errors to the MW API
+* Requires the MW Linter extension to be installed
+* and configured.
+*/
+   sendAPI: false,
+
+   /**
+* @property {number} apiSampling
+*
+* Ratio at which to sample linter errors, per page.
+* This is deterministic and based on page_id.
+*/
+   apiSampling: 1,
+
+   /**
 * @property {number} tidyWhiteSpaceBugMaxLength
 *
 * Max length of content covered by 'white-space:nowrap' CSS
diff --git a/lib/logger/LintLogger.js b/lib/logger/LintLogger.js
index 0297233..89f1c6e 100644
--- a/lib/logger/LintLogger.js
+++ b/lib/logger/LintLogger.js
@@ -38,7 +38,7 @@
 
this.buffer = [];
 
-   if (env.page.id % env.conf.parsoid.linterAPISampling !== 0) {
+   if (env.page.id % env.conf.parsoid.linter.apiSampling !== 0) {
return;
}
 
@@ -47,7 +47,7 @@
return;
}
 
-   if (!env.conf.parsoid.linterSendAPI) {
+   if (!env.conf.parsoid.linter.sendAPI) {
enabledBuffer.forEach(function(item) {
// Call this async, since recursive sync calls 
to the logger
// are suppressed.  This messes up the 
ordering, as you'd
diff --git a/lib/utils/Util.js b/lib/utils/Util.js
index 232d2ac..691a3f3 100644
--- a/lib/utils/Util.js
+++ b/lib/utils/Util.js
@@ -242,7 +242,7 @@
}
if (opts.lint) {
parsoidConfig.linting = true;
-   parsoidConfig.linterSendAPI = false;
+   parsoidConfig.linter.sendAPI = false;
}
if (opts.useBatchAPI !== null) {
parsoidConfig.useBatchAPI = 
Util.booleanOption(opts.useBatchAPI);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic198d3833ea849cee07b6298cfb6724bb1e6b0e1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Detect misnested tags that have different behavior in HTML5 ...

2017-09-20 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/379430 )

Change subject: Detect misnested tags that have different behavior in HTML5 vs 
HTML4
..

Detect misnested tags that have different behavior in HTML5 vs HTML4

* This will make a different when Tidy is replaced by Remex and
  will also make Parsoid rendering more compatible with Tidy.

Bug: T176363
Change-Id: I93d779eba9b7738c309b8a8a4a89f337bb4ac168
---
M lib/utils/DOMUtils.js
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
3 files changed, 76 insertions(+), 9 deletions(-)


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

diff --git a/lib/utils/DOMUtils.js b/lib/utils/DOMUtils.js
index e073bde..5de498f 100644
--- a/lib/utils/DOMUtils.js
+++ b/lib/utils/DOMUtils.js
@@ -1244,6 +1244,12 @@
return next;
},
 
+   hasFollowingContent: function(node) {
+   return !DU.isBody(node) && (
+   DU.nextNonSepSibling(node) || 
DU.hasFollowingContent(node.parentNode)
+   );
+   },
+
numNonDeletedChildNodes: function(node) {
var n = 0;
var child = node.firstChild;
diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 8e95440..bd6fb5b 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -17,6 +17,24 @@
 var Util = require('../../../utils/Util.js').Util;
 var Consts = require('../../../config/WikitextConstants.js').WikitextConstants;
 
+var tagsWithChangedMisnestingBehavior;
+function getTagsWithChangedMisnestingBehavior() {
+   if (!tagsWithChangedMisnestingBehavior) {
+   tagsWithChangedMisnestingBehavior = new Set();
+   Consts.HTML.HTML5Tags.forEach(function(t) {
+   if (Consts.Sanitizer.TagWhiteList.has(t) &&
+   !Consts.HTML.BlockTags.has(t) &&
+   !Consts.HTML.FormattingTags.has(t) &&
+   !Consts.HTML.VoidTags.has(t)
+   ) {
+   tagsWithChangedMisnestingBehavior.add(t);
+   }
+   });
+   }
+
+   return tagsWithChangedMisnestingBehavior;
+}
+
 /*
  * Log Transclusion with more than one parts
  * Ex - {{table-start}}
@@ -172,16 +190,22 @@
templateInfo: templateInfo,
params: { name: cNodeName },
};
-   var adjNode = getNextMatchingNode(c, c);
-   if (adjNode) {
-   var adjDp = DU.getDataParsoid(adjNode);
-   if (!adjDp.tmp) {
-   adjDp.tmp = {};
+   if 
(getTagsWithChangedMisnestingBehavior().has(c.nodeName) &&
+   DU.hasFollowingContent(c)
+   ) {
+   env.log('lint/html5-misnesting', lintObj);
+   } else {
+   var adjNode = getNextMatchingNode(c, c);
+   if (adjNode) {
+   var adjDp = DU.getDataParsoid(adjNode);
+   if (!adjDp.tmp) {
+   adjDp.tmp = {};
+   }
+   adjDp.tmp.linted = true;
+   env.log('lint/misnested-tag', lintObj);
+   } else if (DU.hasLiteralHTMLMarker(dp)) {
+   env.log('lint/missing-end-tag', 
lintObj);
}
-   adjDp.tmp.linted = true;
-   env.log('lint/misnested-tag', lintObj);
-   } else if (DU.hasLiteralHTMLMarker(dp)) {
-   env.log('lint/missing-end-tag', lintObj);
}
}
 
diff --git a/tests/mocha/linter.js b/tests/mocha/linter.js
index f1ad362..d206801 100644
--- a/tests/mocha/linter.js
+++ b/tests/mocha/linter.js
@@ -600,4 +600,41 @@
return expectEmptyResults(wt, { tweakEnv: tweakEnv });
});
});
+
+   describe('HTML5 MISNESTED TAGS', function() {
+   it('should not trigger html5 misnesting if there is no 
following content', function() {
+   return parseWT('foo\nbar').then(function(result) {
+   result.should.have.length(1);
+   result[0].should.have.a.property("type", 
"missing-end-tag");
+   result[0].should.have.a.property("params");
+  

[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: T176151: Handle linting in the presence of fostering and tem...

2017-09-20 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/379264 )

Change subject: T176151: Handle linting in the presence of fostering and 
templating
..

T176151: Handle linting in the presence of fostering and templating

While linting fostered content, we were sometimes skipping past
the first node of template-wrapped content. This prevented the
DOM visitor from passing the right tplInfo for templated nodes
=> missing DSR for those nodes => crashers.

The following command doesn't crash anymore and properly emits
a whole bunch of lint errors.

parse.js --prefix plwiki --page Wikipedia:Dzień_Nowego_Artykułu/szablony --lint

Change-Id: I2eeba089048b450c6b924cd1eb33ffaebb4e776c
---
M lib/wt2html/pp/handlers/linter.js
1 file changed, 31 insertions(+), 6 deletions(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 8e95440..cca2d66 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -263,24 +263,49 @@
  * Here 'foo' gets fostered out.
  */
 function logFosteredContent(env, node, dp, tplInfo) {
-   var nextSibling = node.nextSibling;
-   while (nextSibling && !DU.hasNodeName(nextSibling, 'table')) {
-   if (tplInfo && nextSibling === tplInfo.last) {
+   var maybeTable = node.nextSibling;
+   while (maybeTable && !DU.hasNodeName(maybeTable, 'table')) {
+   if (tplInfo && maybeTable === tplInfo.last) {
tplInfo.clear = true;
}
-   nextSibling = nextSibling.nextSibling;
+   maybeTable = maybeTable.nextSibling;
}
+
+   // In pathological cases, we might walk past fostered nodes
+   // that carry templating information. This then triggers
+   // other errors downstream. So, walk back to that first node
+   // and ignore this fostered content error. The new node will
+   // trigger fostered content lint error.
+   if (!tplInfo && DU.hasParsoidAboutId(maybeTable) &&
+   !DU.isFirstEncapsulationWrapperNode(maybeTable))
+   {
+   var tplNode = maybeTable.previousSibling;
+   while (!DU.isFirstEncapsulationWrapperNode(tplNode) && tplNode 
!== node) {
+   tplNode = tplNode.previousSibling;
+   }
+
+   // This is the node we want
+   if (tplNode !== node) {
+   return tplNode;
+   }
+
+   // Not sure what kind of crazy DOM this is.
+   // We walked all the way back to our starting point.
+   // Don't try to fix this. Let things crash and burn!
+   }
+
var dsr;
var templateInfo;
if (tplInfo) {
dsr = tplInfo.dsr;
templateInfo = findEnclosingTemplateName(env, tplInfo);
} else {
-   dsr = DU.getDataParsoid(nextSibling).dsr;
+   dsr = DU.getDataParsoid(maybeTable).dsr;
}
var lintObj = { dsr: dsr, templateInfo: templateInfo };
env.log('lint/fostered', lintObj);
-   return nextSibling;
+
+   return maybeTable;
 }
 
 var obsoleteTagsRE = null;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2eeba089048b450c6b924cd1eb33ffaebb4e776c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Sync parserTests with core

2017-09-13 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/377869 )

Change subject: Sync parserTests with core
..

Sync parserTests with core

Change-Id: I35480a1736f60a24c0232fd604168a71849f66ea
---
M tests/parserTests.json
M tests/parserTests.txt
2 files changed, 3 insertions(+), 3 deletions(-)


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

diff --git a/tests/parserTests.json b/tests/parserTests.json
index 5f97421..639d90f 100644
--- a/tests/parserTests.json
+++ b/tests/parserTests.json
@@ -2,8 +2,8 @@
"parserTests.txt": {
"repo": "/wikimedia/mediawiki/",
"path": "tests/parser/parserTests.txt",
-   "expectedSHA1": "5868bd054fb3f78fcca592185d289ee734312015",
-   "latestCommit": "ea75da8eb84f38cd04cccabf7e1e408b40d56a8c"
+   "expectedSHA1": "a695a49fa32c04e6186078f1492efecb22a5ee53",
+   "latestCommit": "76537600906eba83691d6e4a4e7432bd8ccac5ad"
},
"citeParserTests.txt": {
"repo": "/wikimedia/mediawiki-extensions-Cite/",
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index a291958..2064e03 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -29305,7 +29305,7 @@
 [[#A&B&C&D&amp;E]]
 !! html/php
 A&B&C&D&amp;E[edit]
-#A&B&C&D&amp;E
+#A&B&C&D&amp;E
 
 !! end
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35480a1736f60a24c0232fd604168a71849f66ea
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Sync up with Parsoid parserTests.txt

2017-09-13 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/377841 )

Change subject: Sync up with Parsoid parserTests.txt
..

Sync up with Parsoid parserTests.txt

This now aligns with Parsoid commit dcf2706cff795b84fbbfb6cd22749a86655b04f2

Change-Id: I24700184204000465922930dbac2b019259b5a01
---
M tests/parser/parserTests.txt
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/41/377841/1

diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index ff777e7..a291958 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -4338,12 +4338,12 @@
 !! test
 Definition Lists: Mixed Lists: Test 11
 !! wikitext
-;a
-:*b
-!! html
-a
+; a
+:* b
+!! html/*
+ a
 
-b
+ b
 
 !! end
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24700184204000465922930dbac2b019259b5a01
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: WIP: Tweak tidy-whitespace-bug detection to handle s

2017-09-09 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376905 )

Change subject: WIP: Tweak tidy-whitespace-bug detection to handle s
..

WIP: Tweak tidy-whitespace-bug detection to handle s

Change-Id: Ib1342e6717880cc024c9153153ed0e604c1da002
---
M lib/wt2html/pp/handlers/linter.js
1 file changed, 1 insertion(+), 1 deletion(-)


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

diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index 8e95440..f024a00 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -454,7 +454,7 @@
var startNode = node;
var haveTidyBug = false;
var runLength = 0;
-   while (node && !DU.isBlockNode(node)) {
+   while (node && !DU.isBlockNode(node) && node.nodeName !== 'BR') { // 
 breaks a line
if (DU.isText(node) || !hasNoWrapCSS(node)) {
// No CSS property that affects whitespace.
s = node.textContent;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1342e6717880cc024c9153153ed0e604c1da002
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: WIP: Fix bug in dl-dt list output generation

2017-09-06 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/376446 )

Change subject: WIP: Fix bug in dl-dt list output generation
..

WIP: Fix bug in dl-dt list output generation

* Tidy was hiding this bug so far
* TODO: Add new tests, verify.

Bug: T175099
Change-Id: I6d5b225b82cecf9a43f23837ed8ec359b31aadad
---
M includes/parser/BlockLevelPass.php
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/46/376446/1

diff --git a/includes/parser/BlockLevelPass.php 
b/includes/parser/BlockLevelPass.php
index 599fbf6..35f0805 100644
--- a/includes/parser/BlockLevelPass.php
+++ b/includes/parser/BlockLevelPass.php
@@ -257,6 +257,11 @@
$output .= $this->nextItem( 
$prefix[$commonPrefixLength - 1] );
}
 
+   # Close an open  if we have a  (":") 
starting on this line
+   if ( $this->DTopen && substr( $prefix, 
$commonPrefixLength - 1, 1) === ':' ) {
+   $output .= $this->nextItem( ':' );
+   }
+
# Open prefixes where appropriate.
if ( $lastPrefix && $prefixLength > 
$commonPrefixLength ) {
$output .= "\n";

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d5b225b82cecf9a43f23837ed8ec359b31aadad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...deploy[master]: Bump src to 538dad7 for deploy

2017-08-24 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373568 )

Change subject: Bump src to 538dad7 for deploy
..

Bump src to 538dad7 for deploy

Change-Id: I7d026ccc9ba54ba0ca28843d7fadf3a8f4ab75b2
---
M src
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid/deploy 
refs/changes/68/373568/1

diff --git a/src b/src
index 28a9a22..538dad7 16
--- a/src
+++ b/src
@@ -1 +1 @@
-Subproject commit 28a9a22b8d213601dbbeb47b01ce8a6c76d75bf7
+Subproject commit 538dad7f7ce614479d6abf3b64b7f1907349b24b

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7d026ccc9ba54ba0ca28843d7fadf3a8f4ab75b2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid/deploy
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: T172896: Add mw-empty-elt class to empty li items that can't...

2017-08-23 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/373420 )

Change subject: T172896: Add mw-empty-elt class to empty li items that can't be 
deleted
..

T172896: Add mw-empty-elt class to empty li items that can't be deleted

* This piece of wikitext "* {{DCdatabase|Batman}}" generates an empty
   item that cannot be removed because it has template encapsulation
  information.

* In keeping with how empty list items are treated in core, this
  patch adds the mw-empty-elt class to it.

Change-Id: I906ee8347726e1fb2cc0b1304ba8e0714afe5f12
---
M lib/utils/DOMUtils.js
M lib/wt2html/pp/handlers/cleanup.js
2 files changed, 19 insertions(+), 18 deletions(-)


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

diff --git a/lib/utils/DOMUtils.js b/lib/utils/DOMUtils.js
index 8fd5b5e..e073bde 100644
--- a/lib/utils/DOMUtils.js
+++ b/lib/utils/DOMUtils.js
@@ -1335,24 +1335,19 @@
 * `strict` adds the condition that all whitespace is forbidden.
 */
nodeEssentiallyEmpty: function(node, strict) {
-   var childNodes = node.childNodes;
-   if (childNodes.length === 0) {
-   return true;
-   } else {
-   var n = node.firstChild;
-   while (n) {
-   if (DU.isElt(n) && !this.isDiffMarker(n)) {
-   return false;
-   } else if (DU.isText(n) &&
-   (strict || !/^[ 
\t]*$/.test(n.nodeValue))) {
-   return false;
-   } else if (DU.isComment(n)) {
-   return false;
-   }
-   n = n.nextSibling;
+   var n = node.firstChild;
+   while (n) {
+   if (DU.isElt(n) && !this.isDiffMarker(n)) {
+   return false;
+   } else if (DU.isText(n) &&
+   (strict || !/^[ 
\t]*$/.test(n.nodeValue))) {
+   return false;
+   } else if (DU.isComment(n)) {
+   return false;
}
-   return true;
+   n = n.nextSibling;
}
+   return true;
},
 
/**
diff --git a/lib/wt2html/pp/handlers/cleanup.js 
b/lib/wt2html/pp/handlers/cleanup.js
index d588ec8..f335105 100644
--- a/lib/wt2html/pp/handlers/cleanup.js
+++ b/lib/wt2html/pp/handlers/cleanup.js
@@ -38,7 +38,7 @@
 }
 
 function stripEmptyElements(node, env, atTopLevel, tplInfo) {
-   if (!atTopLevel || !tplInfo || !DU.isElt(node)) {
+   if (!atTopLevel || !DU.isElt(node) || (!tplInfo && node.nodeName !== 
'LI')) {
return true;
}
 
@@ -48,13 +48,19 @@
//   the info over, but more pain than worth it. We can reconsider if
//   this ever becomes an issue.
// * it has any attributes.
-   if (!node.firstChild && node !== tplInfo.first &&
+   if (!node.firstChild && tplInfo && node !== tplInfo.first &&
node.nodeName in { 'TR': 1, 'LI': 1 } && node.attributes.length 
=== 0
) {
var nextNode = node.nextSibling;
DU.deleteNode(node);
return nextNode;
} else {
+   // Non-deleted empty  nodes should get the mw-empty-elt 
class
+   if (node.nodeName === 'LI' && DU.nodeEssentiallyEmpty(node)) {
+   var classNames = node.getAttribute('class');
+   classNames = classNames ? classNames + ' mw-empty-elt': 
'mw-empty-elt';
+   node.setAttribute('class', classNames);
+   }
return true;
}
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I906ee8347726e1fb2cc0b1304ba8e0714afe5f12
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Add tidy-whitespace-bug category to the stats tool

2017-08-21 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/372895 )

Change subject: Add tidy-whitespace-bug category to the stats tool
..

Add tidy-whitespace-bug category to the stats tool

Change-Id: I1035e4e96aa467c9b09fe731d922ff99b7b1ac4a
---
M tools/compare.linter.results.js
1 file changed, 1 insertion(+), 0 deletions(-)


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

diff --git a/tools/compare.linter.results.js b/tools/compare.linter.results.js
index 7f70354..2a93e8a 100755
--- a/tools/compare.linter.results.js
+++ b/tools/compare.linter.results.js
@@ -79,6 +79,7 @@
"deletable-table-tag",
"pwrap-bug-workaround",
"self-closed-tag",
+   "tidy-whitespace-bug",
 ];
 
 var argv = opts.argv;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1035e4e96aa467c9b09fe731d922ff99b7b1ac4a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry 

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


[MediaWiki-commits] [Gerrit] mediawiki...parsoid[master]: Linter: Tweak tidy-whitespace-bug output

2017-08-21 Thread Subramanya Sastry (Code Review)
Subramanya Sastry has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/372896 )

Change subject: Linter: Tweak tidy-whitespace-bug output
..

Linter: Tweak tidy-whitespace-bug output

* Before this patch, we were reporting all instances of affected
  whitespace. However, with short strings, there is no real issue
  with rendering unless the viewport is small. So, in this patch,
  I am implementing a heuristic that triggers this linter issue
  only if the affected string is of a particular length.

* Updated mocha tests.

Change-Id: I15d401e9a9b649723ae3bfc3598d02e8a619a9ec
---
M lib/config/ParsoidConfig.js
M lib/wt2html/pp/handlers/linter.js
M tests/mocha/linter.js
3 files changed, 94 insertions(+), 57 deletions(-)


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

diff --git a/lib/config/ParsoidConfig.js b/lib/config/ParsoidConfig.js
index 7ad..4958257 100644
--- a/lib/config/ParsoidConfig.js
+++ b/lib/config/ParsoidConfig.js
@@ -249,6 +249,18 @@
  */
 ParsoidConfig.prototype.linterAPISampling = 1;
 
+ParsoidConfig.prototype.linter = {
+   /**
+* @property {number} tidyWhiteSpaceBugMaxLength
+*
+* Max length of content covered by 'white-space:nowrap' CSS
+* that we consider "safe" when Tidy is replaced. Beyond that,
+* wikitext will have to be fixed up to manually insert whitespace
+* at the right places.
+*/
+   tidyWhitespaceBugMaxLength: 100,
+};
+
 /**
  * @property {Function} loggerBackend
  * The logger output function.
diff --git a/lib/wt2html/pp/handlers/linter.js 
b/lib/wt2html/pp/handlers/linter.js
index d4e2e7d..b6fc76c 100644
--- a/lib/wt2html/pp/handlers/linter.js
+++ b/lib/wt2html/pp/handlers/linter.js
@@ -433,66 +433,79 @@
}
 }
 
-function logTidyWhitespaceBug(env, node, dp, tplInfo) {
-   if (DU.isBlockNode(node)) {
-   // Nothing to worry
-   return;
-   }
-
-   if (!hasNoWrapCSS(node)) {
-   // no CSS property that affects whitespcae
-   return;
-   }
-
-   // Find next non-comment sibling of 'node'
-   var next = node.nextSibling;
-   while (next && DU.isComment(next)) {
-   next = next.nextSibling;
-   }
-
-   if (!next || DU.isBlockNode(next) || (DU.isText(next) && 
/^\s/.test(next.data))) {
-   // All good! No text/inline-node sibling
-   return;
-   }
-
+function lastNonCommentNode(node) {
// Find last non-comment child of 'node'
var last = node.lastChild;
while (last && DU.isComment(last)) {
last = last.previousSibling;
}
+}
 
-   if (!last || !DU.isText(last) || !/\s$/.test(last.data)) {
-   // All good! No whitespace for Tidy to hoist out
-   return;
+function logTidyWhitespaceBug(env, node, dp, tplInfo) {
+   // FIXME: Potential for O(n^2) behavior in really bad cases
+
+   var nowrapNodes = [];
+   var startNode = node;
+   while (node && !DU.isBlockNode(node)) {
+   if (DU.isText(node) || !hasNoWrapCSS(node)) {
+   // No CSS property that affects whitespace.
+   if (nowrapNodes.length > 0 && 
!/^\s/.test(node.textContent)) {
+   nowrapNodes.push(node);
+   }
+   break;
+   }
+
+   // Find last non-comment child of 'node'
+   var last = node.lastChild;
+   while (last && DU.isComment(last)) {
+   last = last.previousSibling;
+   }
+
+   if (!last || !DU.isText(last) || !/\s$/.test(last.data)) {
+   // All good! No whitespace for Tidy to hoist out
+   break;
+   }
+
+   // In this scenario, when Tidy hoists the whitespace to
+   // after the node, that whitespace is not subject to the
+   // nowrap CSS => browsers can break content there.
+   //
+   // But, non-Tidy libraries won't hoist the whitespace.
+   // So, browsers don't have a place to break content.
+   //
+   // Track the nodes that are subject to this problem.
+   nowrapNodes.push(node);
+
+   node = node.nextSibling;
+
+   // Skip comments
+   while (node && DU.isComment(node)) {
+   node = node.nextSibling;
+   }
}
 
-   // So, we have:
-   // * two inline siblings without whitespace between then,
-   // * the left sibling has nowrap CSS
-   // * the left sibling has trailing whitespace
-   //
-   // In this scenario, when Tidy hoists the whitespace to
-   // after the left sibling, that whitespace is not subject
-   // to t

  1   2   3   4   5   6   7   8   9   10   >