mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-29 07:20:47 +00:00
Split getTransclusionTarget into getTransclusionTargetIncludingParseTreeNodes
This commit is contained in:
parent
091cc3c26e
commit
fa5bae0150
@ -50,12 +50,12 @@ TranscludeWidget.prototype.execute = function() {
|
|||||||
}
|
}
|
||||||
// Set 'thisTiddler'
|
// Set 'thisTiddler'
|
||||||
this.setVariable("thisTiddler",this.transcludeTitle);
|
this.setVariable("thisTiddler",this.transcludeTitle);
|
||||||
var parseTreeNodes;
|
var parseTreeNodes, target;
|
||||||
// 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 of the target
|
// Return the parse tree nodes of the target
|
||||||
var target = this.getTransclusionTarget(parseAsInline);
|
target = this.getTransclusionTargetIncludingParseTreeNodes(parseAsInline);
|
||||||
this.sourceText = target.text;
|
this.sourceText = target.text;
|
||||||
this.parserType = target.type;
|
this.parserType = target.type;
|
||||||
this.parseAsInline = target.parseAsInline;
|
this.parseAsInline = target.parseAsInline;
|
||||||
@ -63,18 +63,16 @@ TranscludeWidget.prototype.execute = function() {
|
|||||||
break;
|
break;
|
||||||
case "text/raw":
|
case "text/raw":
|
||||||
// Just return the raw text
|
// Just return the raw text
|
||||||
var target = this.getTransclusionTarget(parseAsInline);
|
target = this.getTransclusionTarget();
|
||||||
this.sourceText = target.text;
|
this.sourceText = target.text;
|
||||||
this.parserType = target.type;
|
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 is the plain text result of wikifying the text
|
// text/plain is the plain text result of wikifying the text
|
||||||
var target = this.getTransclusionTarget(parseAsInline);
|
target = this.getTransclusionTarget();
|
||||||
this.sourceText = target.text;
|
this.sourceText = target.text;
|
||||||
this.parserType = target.type;
|
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;
|
||||||
@ -174,10 +172,44 @@ TranscludeWidget.prototype.collectSlotFillParameters = function() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Get transcluded details as an object {text:,type:}
|
||||||
|
*/
|
||||||
|
TranscludeWidget.prototype.getTransclusionTarget = function() {
|
||||||
|
var self = this;
|
||||||
|
var text;
|
||||||
|
// Return the text and type of the target
|
||||||
|
if(this.hasAttribute("$variable")) {
|
||||||
|
if(this.transcludeVariable) {
|
||||||
|
// Transcluding a variable
|
||||||
|
var variableInfo = this.getVariableInfo(this.transcludeVariable,{params: this.getOrderedTransclusionParameters()});
|
||||||
|
text = variableInfo.text;
|
||||||
|
return {
|
||||||
|
text: variableInfo.text,
|
||||||
|
type: this.transcludeType
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Transcluding a text reference
|
||||||
|
var parserInfo = this.wiki.getTextReferenceParserInfo(
|
||||||
|
this.transcludeTitle,
|
||||||
|
this.transcludeField,
|
||||||
|
this.transcludeIndex,
|
||||||
|
{
|
||||||
|
subTiddler: this.transcludeSubTiddler,
|
||||||
|
defaultType: this.transcludeType
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
text: parserInfo.text,
|
||||||
|
type: parserInfo.type
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Get transcluded parse tree nodes as an object {text:,type:,parseTreeNodes:,parseAsInline:}
|
Get transcluded parse tree nodes as an object {text:,type:,parseTreeNodes:,parseAsInline:}
|
||||||
*/
|
*/
|
||||||
TranscludeWidget.prototype.getTransclusionTarget = function(parseAsInline) {
|
TranscludeWidget.prototype.getTransclusionTargetIncludingParseTreeNodes = function(parseAsInline) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var parser;
|
var parser;
|
||||||
// Get the parse tree
|
// Get the parse tree
|
||||||
|
Loading…
Reference in New Issue
Block a user