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

Change subject: Revert some of "Drop native LST altogether"
......................................................................

Revert some of "Drop native LST altogether"

 * This reverts some of commit 023b37b3ed7b102c95e118c1d2fd6bfed63d892f.

 * We need to keep serialization around be backwards compatibility with
   stored content.

Change-Id: I751b62e40d3842c8d0e891a132e967df33501903
---
M lib/config/baseconfig/enwiki.json
A lib/ext/LST/index.js
M tests/parserTests.txt
3 files changed, 93 insertions(+), 1 deletion(-)


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

diff --git a/lib/config/baseconfig/enwiki.json 
b/lib/config/baseconfig/enwiki.json
index ea7858d..524e179 100644
--- a/lib/config/baseconfig/enwiki.json
+++ b/lib/config/baseconfig/enwiki.json
@@ -1296,7 +1296,8 @@
     "extensiontags": [
       "<pre>",
       "<nowiki>",
-      "<gallery>"
+      "<gallery>",
+      "<section>"
     ],
     "general": {
       "mainpage": "Main Page",
diff --git a/lib/ext/LST/index.js b/lib/ext/LST/index.js
new file mode 100644
index 0000000..29e40c5
--- /dev/null
+++ b/lib/ext/LST/index.js
@@ -0,0 +1,54 @@
+'use strict';
+
+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
+// when those versions are no longer supported.
+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;
+       }),
+};
+
+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: 'labeledsectiontransclusion',
+                               serialHandler: serialHandler,
+                       },
+                       {
+                               name: 'labeledsectiontransclusion/begin',
+                               serialHandler: serialHandler,
+                       },
+                       {
+                               name: 'labeledsectiontransclusion/end',
+                               serialHandler: serialHandler,
+                       },
+               ],
+       };
+};
diff --git a/tests/parserTests.txt b/tests/parserTests.txt
index 47401bc..bd7a2bf 100644
--- a/tests/parserTests.txt
+++ b/tests/parserTests.txt
@@ -22912,6 +22912,43 @@
 foo<ol class="mw-references" typeof="mw:Extension/references" about="#mwt2" 
data-mw='{"name":"references","attrs":{}}'></ol>
 !! end
 
+#### ----------------------------------------------------------------
+#### Parsoid-only testing of Parsoid's impl of LST
+#### Not implemented yet, see
+#### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
+#### ----------------------------------------------------------------
+
+## We still need to support serializing the older format while content is 
stored.
+!! test
+LST Sections: Backwards compatibility
+!! options
+parsoid={
+  "suppressErrors": true,
+  "modes": ["html2wt"]
+}
+!! wikitext
+<section begin="2011-05-16" />
+<section end="2014-04-10 (MW 1.23wmf22)" />
+!! html/parsoid
+<p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" 
content="2011-05-16"/>
+<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>
+!! end
+
 #--------- Test stripping of empty nodes in template content ----------
 !!test
 Empty LI and TR nodes should be stripped from template content

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

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