Arlolra has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/327579 )

Change subject: Avoid parse requests for LST
......................................................................

Avoid parse requests for LST

 * Follows on 6acdf394

Change-Id: Ic0d8cf7abea8c2c95f434e3188a49798e943be10
---
M lib/ext/LST/index.js
M tests/parserTests.txt
2 files changed, 30 insertions(+), 9 deletions(-)


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

diff --git a/lib/ext/LST/index.js b/lib/ext/LST/index.js
index 85b945c..b6ad75b 100644
--- a/lib/ext/LST/index.js
+++ b/lib/ext/LST/index.js
@@ -3,7 +3,11 @@
 var ParsoidExtApi = 
module.parent.require('./extapi.js').versionCheck('^0.6.1');
 
 var DU = ParsoidExtApi.DOMUtils;
+var Util = ParsoidExtApi.Util;
 var Promise = ParsoidExtApi.Promise;
+var defines = ParsoidExtApi.defines;
+
+var SelfclosingTagTk = defines.SelfclosingTagTk;
 
 // TODO: We're keeping this serial handler around to remain backwards
 // compatible with stored content version 1.3.0 and below.  Remove it
@@ -28,12 +32,34 @@
        }),
 };
 
+// FIXME: Special handling for wikisource: hide section tags for now.
+// See https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
+var tokenHandler = function(manager, pipelineOpts, extToken, cb) {
+       var argDict = Util.getArgInfo(extToken).dict;
+       if (!extToken.dataAttribs.tagWidths[1]) {
+               argDict.body = null;  // Serialize to self-closing.
+       }
+       var token = new SelfclosingTagTk('meta', [
+               { k: 'typeof', v: 'mw:Extension/' + argDict.name },
+               { k: 'about', v: manager.env.newAboutId() },
+               { k: 'data-mw', v: JSON.stringify(argDict) },
+       ], {
+               src: extToken.getAttribute('source'),
+               tsr: Util.clone(extToken.dataAttribs.tsr),
+       });
+       cb({ tokens: [token] });
+};
+
 module.exports = function() {
        this.config = {
-               // FIXME: This is registering <labeledsectiontransclusion> as 
an ext
-               // tag.  All the more reason to get rid of this file altogether.
                tags: [
                        {
+                               name: 'section',
+                               tokenHandler: tokenHandler,
+                       },
+                       // FIXME: These names are being registered as extension 
tags.
+                       // As in, <labeledsectiontransclusion(/(begin|end))?>
+                       {
                                name: 'labeledsectiontransclusion',
                                serialHandler: serialHandler,
                        },
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 1125611..3f1a7e4 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -22977,19 +22977,14 @@
 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 
(MW 1.23wmf22)"/></p>
 !! end
 
-## The unconventional output is the result of `usePHPPreProcessor` being
-## disabled in parserTests.js.  This test is mainly just to show <section> is
-## recognized as an extension tag w/o a native handler.
 !! test
 LST Sections: Newfangled approach
-!! options
-parsoid={ "suppressErrors": true }
 !! wikitext
 <section begin="2011-05-16" />
 <section end="2014-04-10 (MW 1.23wmf22)" />
 !! html/parsoid
-<p><span typeof="mw:Extension/section" about="#mwt1" 
data-parsoid='{"stx":"html","selfClose":true,"src":"&lt;section 
begin=\"2011-05-16\" />","tagWidths":[30,0]}'>&lt;section begin="2011-05-16" 
/></span>
-<span typeof="mw:Extension/section" about="#mwt2" 
data-parsoid='{"stx":"html","selfClose":true,"src":"&lt;section 
end=\"2014-04-10 (MW 1.23wmf22)\" />","tagWidths":[43,0]}'>&lt;section 
end="2014-04-10 (MW 1.23wmf22)" /></span></p>
+<p><meta typeof="mw:Extension/section" about="#mwt2" 
data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'/>
+<meta typeof="mw:Extension/section" about="#mwt4" 
data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 
1.23wmf22)"},"body":null}'/></p>
 !! end
 
 #--------- Test stripping of empty nodes in template content ----------

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0d8cf7abea8c2c95f434e3188a49798e943be10
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <abrea...@wikimedia.org>

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

Reply via email to