Arlolra has uploaded a new change for review.

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

Change subject: Remove dead code
......................................................................

Remove dead code

 * formatHTML was made a noop in Ibf511baf91fdb2d8c612e3adbbe1c61c08247eef

Change-Id: Ie1531fb830315573cafe984f23cb054bab5c0223
---
M lib/mediawiki.DOMUtils.js
M tests/parserTests.js
M tests/roundtrip-test.js
3 files changed, 16 insertions(+), 53 deletions(-)


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

diff --git a/lib/mediawiki.DOMUtils.js b/lib/mediawiki.DOMUtils.js
index a2e7fb1..fa42e5f 100644
--- a/lib/mediawiki.DOMUtils.js
+++ b/lib/mediawiki.DOMUtils.js
@@ -2305,9 +2305,7 @@
 /**
  * @method normalizeIEW
  *
- * Normalize newlines in IEW to spaces instead.  Newlines are
- * preserved/inserted around the same set of tags that formatHTML would
- * add them in front of.
+ * Normalize newlines in IEW to spaces instead.
  *
  * @param {Node} body
  *   The document `<body>` node to normalize.
@@ -2548,26 +2546,6 @@
                replace(/ href="[^"]*"/g, Util.decodeURI).
                // strip thumbnail size prefixes
                
replace(/(src="[^"]*?)\/thumb(\/[0-9a-f]\/[0-9a-f]{2}\/[^\/]+)\/[0-9]+px-[^"\/]+(?=")/g,
 '$1$2');
-};
-
-
-
-/**
- * @method formatHTML
- *
- * Insert newlines before some block-level start tags.
- *
- * @param {string} source
- * @returns {string}
- */
-DOMUtils.formatHTML = function(source) {
-       // We do this in normalizeIEW now, no need for a separate function.
-       if (true) {
-               return source;
-       } else {
-               return source.replace(
-                               
/(?!^)<((div|dd|dt|li|p|table|tr|td|tbody|dl|ol|ul|h1|h2|h3|h4|h5|h6)[^>]*)>/g, 
'\n<$1>');
-       }
 };
 
 /**
diff --git a/tests/parserTests.js b/tests/parserTests.js
index 0268da4..3babb7c 100755
--- a/tests/parserTests.js
+++ b/tests/parserTests.js
@@ -1254,9 +1254,6 @@
  *
  * Print the actual and expected outputs.
  *
- * Side effect: Both objects will, after this, have 'formattedRaw' and 
'formattedNormal' properties,
- * which are the result of calling DU.formatHTML() on the 'raw' and 'normal' 
properties.
- *
  * @param {Object} actual
  * @param {string} actual.raw
  * @param {string} actual.normal
@@ -1270,21 +1267,17 @@
  */
 ParserTests.prototype.getActualExpected = function(actual, expected, getDiff) {
        var returnStr = '';
-       expected.formattedRaw = expected.isWT ? expected.raw : 
DU.formatHTML(expected.raw);
        returnStr += 'RAW EXPECTED'.cyan + ':\n';
-       returnStr += expected.formattedRaw + '\n';
+       returnStr += expected.raw + '\n';
 
-       actual.formattedRaw = actual.isWT ? actual.raw : 
DU.formatHTML(actual.raw);
        returnStr += 'RAW RENDERED'.cyan + ':\n';
-       returnStr += actual.formattedRaw + '\n';
+       returnStr += actual.raw + '\n';
 
-       expected.formattedNormal = expected.isWT ? expected.normal : 
DU.formatHTML(expected.normal);
        returnStr += 'NORMALIZED EXPECTED'.magenta + ':\n';
-       returnStr += expected.formattedNormal + '\n';
+       returnStr += expected.normal + '\n';
 
-       actual.formattedNormal = actual.isWT ? actual.normal : 
DU.formatHTML(actual.normal);
        returnStr += 'NORMALIZED RENDERED'.magenta + ':\n';
-       returnStr += actual.formattedNormal + '\n';
+       returnStr += actual.normal + '\n';
 
        returnStr += 'DIFF'.cyan + ':\n';
        returnStr += getDiff(actual, expected);
@@ -1294,14 +1287,14 @@
 
 /**
  * @param {Object} actual
- * @param {string} actual.formattedNormal
+ * @param {string} actual.normal
  * @param {Object} expected
- * @param {string} expected.formattedNormal
+ * @param {string} expected.normal
  */
 ParserTests.prototype.getDiff = function(actual, expected) {
        // safe to always request color diff, because we set color mode='none'
        // if colors are turned off.
-       return Diff.htmlDiff(expected.formattedNormal, actual.formattedNormal, 
true);
+       return Diff.htmlDiff(expected.normal, actual.normal, true);
 };
 
 /**
@@ -1441,8 +1434,8 @@
 
        var input = mode === 'selser' ? item.changedHTMLStr :
                        mode === 'html2wt' ? item.html : itemWikitext;
-       var expected = { isWT: true, normal: normalizedExpected, raw: 
itemWikitext };
-       var actual = { isWT: true, normal: normalizedOut, raw: out, input: 
input };
+       var expected = { normal: normalizedExpected, raw: itemWikitext };
+       var actual = { normal: normalizedOut, raw: out, input: input };
 
        return options.reportResult(item.title, item.time, item.comments, 
item.options || null, expected, actual, options, mode, item);
 };
@@ -2105,7 +2098,7 @@
                                        var exp = new RegExp("(" + 
/!!\s*test\s*/.source +
                                                Util.escapeRegExp(fail.title) + 
/(?:(?!!!\s*end)[\s\S])*/.source +
                                                ")(" + 
Util.escapeRegExp(fail.expected) + ")", "m");
-                                       parserTests = parserTests.replace(exp, 
"$1" + DU.formatHTML(fail.actualNormalized.replace(/\$/g, '$$$$')));
+                                       parserTests = parserTests.replace(exp, 
"$1" + fail.actualNormalized.replace(/\$/g, '$$$$'));
                                }
                        });
                        fs.writeFileSync(parserTestsFilename, parserTests, 
'utf8');
@@ -2152,9 +2145,6 @@
         *
         * Get the actual and expected outputs encoded for XML output.
         *
-        * Side effect: Both objects will, after this, have 'formattedRaw' and 
'formattedNormal' properties,
-        * which are the result of calling DU.formatHTML() on the 'raw' and 
'normal' properties.
-        *
         * @inheritdoc ParserTests#getActualExpected.
         *
         * @returns {string} The XML representation of the actual and expected 
outputs
@@ -2162,22 +2152,17 @@
        var getActualExpectedXML = function(actual, expected, getDiff) {
                var returnStr = '';
 
-               expected.formattedRaw = DU.formatHTML(expected.raw);
-               actual.formattedRaw = DU.formatHTML(actual.raw);
-               expected.formattedNormal = DU.formatHTML(expected.normal);
-               actual.formattedNormal = DU.formatHTML(actual.normal);
-
                returnStr += 'RAW EXPECTED:\n';
-               returnStr += DU.encodeXml(expected.formattedRaw) + '\n\n';
+               returnStr += DU.encodeXml(expected.raw) + '\n\n';
 
                returnStr += 'RAW RENDERED:\n';
-               returnStr += DU.encodeXml(actual.formattedRaw) + '\n\n';
+               returnStr += DU.encodeXml(actual.raw) + '\n\n';
 
                returnStr += 'NORMALIZED EXPECTED:\n';
-               returnStr += DU.encodeXml(expected.formattedNormal) + '\n\n';
+               returnStr += DU.encodeXml(expected.normal) + '\n\n';
 
                returnStr += 'NORMALIZED RENDERED:\n';
-               returnStr += DU.encodeXml(actual.formattedNormal) + '\n\n';
+               returnStr += DU.encodeXml(actual.normal) + '\n\n';
 
                returnStr += 'DIFF:\n';
                returnStr += DU.encodeXml (getDiff(actual, expected, false));
diff --git a/tests/roundtrip-test.js b/tests/roundtrip-test.js
index 5f4770a..b932ac5 100755
--- a/tests/roundtrip-test.js
+++ b/tests/roundtrip-test.js
@@ -302,7 +302,7 @@
                // node need not be an element always!
                html += DU.serializeNode(out[i], { smartQuote: false }).str;
        }
-       html = DU.formatHTML(DU.normalizeOut(html));
+       html = DU.normalizeOut(html);
 
        // Normalize away <br/>'s added by Parsoid because of newlines in 
wikitext.
        // Do this always, not just when nlDiffs is true, because newline diffs

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie1531fb830315573cafe984f23cb054bab5c0223
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to