Cscott has uploaded a new change for review.
https://gerrit.wikimedia.org/r/77064
Change subject: Advance TokenStreamPatcher ahead of WikiLinkHandler in the
pipeline.
......................................................................
Advance TokenStreamPatcher ahead of WikiLinkHandler in the pipeline.
We are going to use TokenStreamPatcher to reparse expanded templates
in certain circumstances, and we'd like to do so without breaking
links inside the templates.
Change-Id: I5873a94038963fc2a190d7a6bd984f722ae3455a
---
M js/lib/ext.core.TokenStreamPatcher.js
M js/lib/mediawiki.parser.js
2 files changed, 12 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid
refs/changes/64/77064/1
diff --git a/js/lib/ext.core.TokenStreamPatcher.js
b/js/lib/ext.core.TokenStreamPatcher.js
index 95ed483..043a4eb 100644
--- a/js/lib/ext.core.TokenStreamPatcher.js
+++ b/js/lib/ext.core.TokenStreamPatcher.js
@@ -34,9 +34,9 @@
this.reset();
}
-TokenStreamPatcher.prototype.nlRank = 2.001;
-TokenStreamPatcher.prototype.anyRank = 2.002;
-TokenStreamPatcher.prototype.endRank = 2.003;
+TokenStreamPatcher.prototype.nlRank = 1.141;
+TokenStreamPatcher.prototype.anyRank = 1.142;
+TokenStreamPatcher.prototype.endRank = 1.143;
TokenStreamPatcher.prototype.updateBuf = function() {
if (this.buf.length === 0) {
@@ -53,16 +53,16 @@
this.updateBuf();
};
-TokenStreamPatcher.prototype.onNewline = function(token) {
+TokenStreamPatcher.prototype.onNewline = function(token, frame, cb) {
this.sol = true;
this.srcOffset = (token.dataAttribs.tsr || [null,null])[1];
this.updateBuf();
- return {tokens: [token]};
+ cb ({tokens: [token]});
};
-TokenStreamPatcher.prototype.onEnd = function(token) {
+TokenStreamPatcher.prototype.onEnd = function(token, frame, cb) {
this.reset();
- return {tokens: [token]};
+ cb ({tokens: [token]});
};
TokenStreamPatcher.prototype.clearSOL = function() {
@@ -71,7 +71,7 @@
this.sol = false;
};
-TokenStreamPatcher.prototype.onAny = function(token) {
+TokenStreamPatcher.prototype.onAny = function(token, frame, cb) {
// console.warn("T: " + JSON.stringify(token));
var tokens = [token];
switch (token.constructor) {
@@ -126,7 +126,7 @@
break;
}
- return {tokens: tokens};
+ cb ({tokens: tokens});
};
if (typeof module === "object") {
diff --git a/js/lib/mediawiki.parser.js b/js/lib/mediawiki.parser.js
index 52c170d..a0ea9c9 100644
--- a/js/lib/mediawiki.parser.js
+++ b/js/lib/mediawiki.parser.js
@@ -114,6 +114,9 @@
// now all attributes expanded to tokens or
string
+ // reparse token streams where helpful
(templates, sol, etc)
+ TokenStreamPatcher, // 1.141 -- 1.143
+
// more convenient after attribute expansion
WikiLinkHandler, // 1.15
@@ -137,7 +140,6 @@
// PHASE RANGE: [2,3)
[ 3, 'tokens/x-mediawiki/expanded' ],
[
- TokenStreamPatcher, // 2.001 -- 2.003
// add <pre>s
PreHandler, // 2.051 -- 2.054
QuoteTransformer, // 2.1
--
To view, visit https://gerrit.wikimedia.org/r/77064
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5873a94038963fc2a190d7a6bd984f722ae3455a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits