1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-16 23:04:50 +00:00

Preparing to split getTransclusionTarget into two separate functions

This commit is contained in:
Jeremy Ruston 2023-07-29 15:03:46 +01:00
parent fd95a942aa
commit 091cc3c26e

View File

@ -48,26 +48,33 @@ TranscludeWidget.prototype.execute = function() {
} else if(this.transcludeMode === "block") { } else if(this.transcludeMode === "block") {
parseAsInline = false; parseAsInline = false;
} }
// Get the target text and parse tree nodes that we are transcluding
var target = this.getTransclusionTarget(parseAsInline),
parseTreeNodes;
this.sourceText = target.text;
this.parserType = target.type;
this.parseAsInline = target.parseAsInline;
// Set 'thisTiddler' // Set 'thisTiddler'
this.setVariable("thisTiddler",this.transcludeTitle); this.setVariable("thisTiddler",this.transcludeTitle);
var parseTreeNodes;
// Process the transclusion according to the output type // Process the transclusion according to the output type
switch(this.transcludeOutput || "text/html") { switch(this.transcludeOutput || "text/html") {
case "text/html": case "text/html":
// Return the parse tree nodes // Return the parse tree nodes of the target
var target = this.getTransclusionTarget(parseAsInline);
this.sourceText = target.text;
this.parserType = target.type;
this.parseAsInline = target.parseAsInline;
parseTreeNodes = target.parseTreeNodes; parseTreeNodes = target.parseTreeNodes;
break; break;
case "text/raw": case "text/raw":
// Just return the raw text // Just return the raw text
var target = this.getTransclusionTarget(parseAsInline);
this.sourceText = target.text;
this.parserType = target.type;
this.parseAsInline = target.parseAsInline;
parseTreeNodes = [{type: "text", text: this.sourceText}]; parseTreeNodes = [{type: "text", text: this.sourceText}];
break; break;
default: default:
// text/plain // text/plain is the plain text result of wikifying the text
var target = this.getTransclusionTarget(parseAsInline);
this.sourceText = target.text;
this.parserType = target.type;
this.parseAsInline = target.parseAsInline;
var plainText = this.wiki.renderText("text/plain",this.parserType,this.sourceText,{parentWidget: this}); var plainText = this.wiki.renderText("text/plain",this.parserType,this.sourceText,{parentWidget: this});
parseTreeNodes = [{type: "text", text: plainText}]; parseTreeNodes = [{type: "text", text: plainText}];
break; break;