Subramanya Sastry has uploaded a new change for review.

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


Change subject: Added detailed comment to document the nested-ref hack in 
a34dfb15
......................................................................

Added detailed comment to document the nested-ref hack in a34dfb15

Change-Id: Ia4fafb3394e3489743a99ca25b7a1dfc5c50aaa4
---
M js/lib/ext.core.TemplateHandler.js
1 file changed, 27 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/01/69501/1

diff --git a/js/lib/ext.core.TemplateHandler.js 
b/js/lib/ext.core.TemplateHandler.js
index a599825..91baf9a 100644
--- a/js/lib/ext.core.TemplateHandler.js
+++ b/js/lib/ext.core.TemplateHandler.js
@@ -542,7 +542,33 @@
        //console.log( "---------------------------------");
        //console.log( src );
 
-       // HACK! Needed to support nested <refs>s in #tag:ref
+       /* -----------------------------------------------------------------
+        * HACK! Bypass the "text/mediawiki" pipeline for "{{#tag:ref|...}}"
+        *
+        * We have to do this to support <ref> tags in #tag:ref (which is
+        * effectively nested ref tags). See Bug 49555 for additional details.
+        *
+        * Consider this wikitext: "{{#tag:ref|X <ref>foo</ref> Y}}"
+        * The PHP preprocessor returns "<ref>X <ref>foo</ref> Y</ref>"
+        *
+        * If we pass this through the regular pipeline, the tokenizer
+        * will parse this into 2 tokens:
+        * [ <extension name="ref" source="<ref>X <ref>foo</ref>" />,
+        *   " Y &lt/ref&gt;" ]
+        * which is absolutely not what we want!
+        *
+        * Since we know this can be a nested-ref token and has to parse
+        * into a single extension-token, we do the work of the tokenizer
+        * and convert it to an ext-token ourselves.
+        *
+        * Since this is a single ext-token, we know it wouldn't have been
+        * processed by any other handlers in stage 1 or stage 2 except
+        * template encapsulation which we directly handle below.
+        *
+        * So, this hack effectively bypasses the normal stage 1 and stage 2
+        * pipeline processing and shortcircuits it below with exactly the
+        * tokens we want.
+        * ----------------------------------------------------------------- */
        var tplName = (state.token.attribs[0].k || '');
        var inTagRef = tplName.constructor === String && tplName.toLowerCase() 
=== "#tag:ref";
        if (inTagRef) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia4fafb3394e3489743a99ca25b7a1dfc5c50aaa4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>

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

Reply via email to