Arlolra has uploaded a new change for review.

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

Change subject: Use the spec'd extension model for LST
......................................................................

Use the spec'd extension model for LST

 * It's unclear why we have this unconventional representation.

Change-Id: If3df2ea441a9c89409d98b586a40e181047d8f8b
---
M lib/ext/LST/index.js
1 file changed, 8 insertions(+), 43 deletions(-)


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

diff --git a/lib/ext/LST/index.js b/lib/ext/LST/index.js
index c375916..cd1c9ac 100644
--- a/lib/ext/LST/index.js
+++ b/lib/ext/LST/index.js
@@ -9,49 +9,21 @@
 
 var SelfclosingTagTk = defines.SelfclosingTagTk;
 
-// Special case for <section> until LST is implemented natively.
-var serialHandler = {
-       handle: Promise.method(function(node, state, wrapperUnmodified) {
-               var env = state.env;
-               var typeOf = node.getAttribute('typeof') || '';
-               var dp = DU.getDataParsoid(node);
-               var src;
-               if (dp.src) {
-                       src = dp.src;
-               } else if (typeOf.match('begin')) {
-                       src = '<section begin="' + node.getAttribute('content') 
+ '" />';
-               } else if (typeOf.match('end')) {
-                       src = '<section end="' + node.getAttribute('content') + 
'" />';
-               } else {
-                       env.log('error', 'LST <section> without content in: ' + 
node.outerHTML);
-                       src = '<section />';
-               }
-               return src;
-       }),
-};
-
 // TODO: Properly handle this.
 // 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 sectionAttribs = [];
-       var sectionType = 'mw:Extension/LabeledSectionTransclusion';
-
-       extToken.getAttribute('options').some(function(kv) {
-               if (kv.k === 'begin' || kv.k === 'end') {
-                       sectionType += '/' + kv.k;
-                       sectionAttribs.push({ k: 'content', v: kv.v });
-                       return true;
-               }
-       });
-       sectionAttribs.push({ k: 'typeof', v: sectionType });
-       sectionAttribs.push({ k: 'data-mw', v: JSON.stringify({ name: "section" 
}) });
-
-       var token = new SelfclosingTagTk('meta', sectionAttribs, {
+       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: 'data-mw', v: JSON.stringify(argDict) },
+       ], {
                src: extToken.getAttribute('source'),
                tsr: Util.clone(extToken.dataAttribs.tsr),
        });
-
        cb({ tokens: [token] });
 };
 
@@ -62,13 +34,6 @@
                        {
                                name: 'section',
                                tokenHandler: tokenHandler,
-                       },
-                       {
-                               name: 'labeledsectiontransclusion/begin',
-                               serialHandler: serialHandler,
-                       }, {
-                               name: 'labeledsectiontransclusion/end',
-                               serialHandler: serialHandler,
                        },
                ],
        };

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

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