From cd0617f033e0f5ea9c7c73b184463af5a23a13ee Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Tue, 26 Apr 2022 12:45:05 +0100 Subject: [PATCH] Use the ubertransclude widget for the wikitext transclusion syntax --- .../parsers/wikiparser/rules/transcludeblock.js | 10 +++++----- .../parsers/wikiparser/rules/transcludeinline.js | 10 +++++----- core/modules/widgets/ubertransclude.js | 12 +++++------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/core/modules/parsers/wikiparser/rules/transcludeblock.js b/core/modules/parsers/wikiparser/rules/transcludeblock.js index 56a4f63b8..c33c074a8 100644 --- a/core/modules/parsers/wikiparser/rules/transcludeblock.js +++ b/core/modules/parsers/wikiparser/rules/transcludeblock.js @@ -34,7 +34,7 @@ exports.parse = function() { textRef = $tw.utils.trim(this.match[1]); // Prepare the transclude widget var transcludeNode = { - type: "transclude", + type: "ubertransclude", attributes: {}, isBlock: true }; @@ -55,7 +55,7 @@ exports.parse = function() { }; } if(template) { - transcludeNode.attributes.tiddler = {type: "string", value: template}; + transcludeNode.attributes["$tiddler"] = {type: "string", value: template}; if(textRef) { return [tiddlerNode]; } else { @@ -63,12 +63,12 @@ exports.parse = function() { } } else { if(textRef) { - transcludeNode.attributes.tiddler = {type: "string", value: targetTitle}; + transcludeNode.attributes["$tiddler"] = {type: "string", value: targetTitle}; if(targetField) { - transcludeNode.attributes.field = {type: "string", value: targetField}; + transcludeNode.attributes["$field"] = {type: "string", value: targetField}; } if(targetIndex) { - transcludeNode.attributes.index = {type: "string", value: targetIndex}; + transcludeNode.attributes["$index"] = {type: "string", value: targetIndex}; } return [tiddlerNode]; } else { diff --git a/core/modules/parsers/wikiparser/rules/transcludeinline.js b/core/modules/parsers/wikiparser/rules/transcludeinline.js index dbf39bfb6..21789081a 100644 --- a/core/modules/parsers/wikiparser/rules/transcludeinline.js +++ b/core/modules/parsers/wikiparser/rules/transcludeinline.js @@ -34,7 +34,7 @@ exports.parse = function() { textRef = $tw.utils.trim(this.match[1]); // Prepare the transclude widget var transcludeNode = { - type: "transclude", + type: "ubertransclude", attributes: {} }; // Prepare the tiddler widget @@ -53,7 +53,7 @@ exports.parse = function() { }; } if(template) { - transcludeNode.attributes.tiddler = {type: "string", value: template}; + transcludeNode.attributes["$tiddler"] = {type: "string", value: template}; if(textRef) { return [tiddlerNode]; } else { @@ -61,12 +61,12 @@ exports.parse = function() { } } else { if(textRef) { - transcludeNode.attributes.tiddler = {type: "string", value: targetTitle}; + transcludeNode.attributes["$tiddler"] = {type: "string", value: targetTitle}; if(targetField) { - transcludeNode.attributes.field = {type: "string", value: targetField}; + transcludeNode.attributes["$field"] = {type: "string", value: targetField}; } if(targetIndex) { - transcludeNode.attributes.index = {type: "string", value: targetIndex}; + transcludeNode.attributes["$index"] = {type: "string", value: targetIndex}; } return [tiddlerNode]; } else { diff --git a/core/modules/widgets/ubertransclude.js b/core/modules/widgets/ubertransclude.js index 31a76576e..1559ea2c4 100644 --- a/core/modules/widgets/ubertransclude.js +++ b/core/modules/widgets/ubertransclude.js @@ -134,17 +134,15 @@ UberTranscludeWidget.prototype.getTransclusionSlotValue = function(name,defaultP Compose a string comprising the title, field and/or index to identify this transclusion for recursion detection */ UberTranscludeWidget.prototype.makeRecursionMarker = function() { + var attributes = Object.create(null); + $tw.utils.each(this.attributes,function(value,name) { + attributes[name] = value; + }); var output = []; output.push("{"); output.push(this.getVariable("currentTiddler",{defaultValue: ""})); output.push("|"); - output.push(this.transcludeTitle || ""); - output.push("|"); - output.push(this.transcludeField || ""); - output.push("|"); - output.push(this.transcludeIndex || ""); - output.push("|"); - output.push(this.transcludeSubTiddler || ""); + output.push(JSON.stringify(attributes)); output.push("}"); return output.join(""); };