From 30f7b37cba4e6c6c837bca4e83efc241b654cabe Mon Sep 17 00:00:00 2001
From: "jeremy@jermolene.com"
Date: Mon, 18 Jul 2022 19:44:37 +0100
Subject: [PATCH] Make use of type attribute consistent
---
core/modules/widgets/transclude.js | 5 ++-
core/modules/wiki.js | 5 ++-
.../tiddlers/tests/data/transclude/Typed.tid | 38 +++++++++++++++++++
3 files changed, 44 insertions(+), 4 deletions(-)
create mode 100644 editions/test/tiddlers/tests/data/transclude/Typed.tid
diff --git a/core/modules/widgets/transclude.js b/core/modules/widgets/transclude.js
index fd32d86cb..2ec3d7364 100755
--- a/core/modules/widgets/transclude.js
+++ b/core/modules/widgets/transclude.js
@@ -65,7 +65,7 @@ TranscludeWidget.prototype.execute = function() {
// Set the legacy transclusion context variables only if we're not transcluding a variable
if(!this.transcludeVariable) {
var recursionMarker = this.makeRecursionMarker();
- this.setVariable("transclusion",recursionMarker);
+ this.setVariable("transclusion",recursionMarker);
}
// Construct the child widgets
this.makeChildWidgets(parseTreeNodes);
@@ -231,7 +231,8 @@ TranscludeWidget.prototype.getTransclusionTarget = function() {
this.transcludeIndex,
{
parseAsInline: parseAsInline,
- subTiddler: this.transcludeSubTiddler
+ subTiddler: this.transcludeSubTiddler,
+ defaultType: this.transcludeType
});
}
// Return the parse tree
diff --git a/core/modules/wiki.js b/core/modules/wiki.js
index cd66288b4..6ae16a2b4 100755
--- a/core/modules/wiki.js
+++ b/core/modules/wiki.js
@@ -1029,10 +1029,11 @@ exports.parseTextReference = function(title,field,index,options) {
};
exports.getTextReferenceParserInfo = function(title,field,index,options) {
- var tiddler,
+ var defaultType = options.defaultType || "text/vnd.tiddlywiki",
+ tiddler,
parserInfo = {
sourceText : null,
- parserType : "text/vnd.tiddlywiki"
+ parserType : defaultType
};
if(options.subTiddler) {
tiddler = this.getSubTiddler(title,options.subTiddler);
diff --git a/editions/test/tiddlers/tests/data/transclude/Typed.tid b/editions/test/tiddlers/tests/data/transclude/Typed.tid
new file mode 100644
index 000000000..c99664b59
--- /dev/null
+++ b/editions/test/tiddlers/tests/data/transclude/Typed.tid
@@ -0,0 +1,38 @@
+title: Transclude/Typed
+description: Typed transclusion
+type: text/vnd.tiddlywiki-multiple
+tags: [[$:/tags/wiki-test-spec]]
+
+title: Output
+
+\procedure testproc()
+This is ''wikitext''
+\end
+
+<$transclude $variable="testproc"/>
+-
+<$transclude $variable="testproc" $type="text/plain"/>
+
+<$transclude $tiddler="Data" $index="testindex"/>
+-
+<$transclude $tiddler="Data" $index="testindex" $type="text/plain"/>
+
+<$transclude $tiddler="Data" $field="custom"/>
+-
+<$transclude $tiddler="Data" $field="custom" $type="text/plain"/>
++
+title: Data
+type: application/x-tiddler-dictionary
+custom: This is ''wikitext''
+
+testindex: This is ''wikitext''
++
+title: ExpectedResult
+
+This is wikitext
+-
+
This is ''wikitext''
This is wikitext
+-
+
This is ''wikitext''
This is wikitext
+-
+
This is ''wikitext''
\ No newline at end of file