mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-05-08 10:24:08 +00:00
Added support for parameterised transclusions
Still no protection against infinite transclusion loops
This commit is contained in:
parent
a5a0567fe9
commit
ad5356f2f3
@ -7,6 +7,7 @@ Wiki text macro implementation
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var ArgParser = require("./ArgParser.js").ArgParser,
|
var ArgParser = require("./ArgParser.js").ArgParser,
|
||||||
|
WikiTextParserModule = require("./WikiTextParser.js"),
|
||||||
utils = require("./Utils.js"),
|
utils = require("./Utils.js"),
|
||||||
util = require("util");
|
util = require("util");
|
||||||
|
|
||||||
@ -69,17 +70,19 @@ wikiTextMacros.macros = {
|
|||||||
tiddler: {
|
tiddler: {
|
||||||
handler: function(macroNode,store,tiddler) {
|
handler: function(macroNode,store,tiddler) {
|
||||||
var args = new ArgParser(macroNode.params,{defaultName:"name"}),
|
var args = new ArgParser(macroNode.params,{defaultName:"name"}),
|
||||||
title = args.getValueByName("name",null),
|
targetTitle = args.getValueByName("name",null),
|
||||||
withTokens = args.getValuesByName("with",[]);
|
withTokens = args.getValuesByName("with",[]),
|
||||||
if(withTokens.length > 0) {
|
text = store.getTiddlerText(targetTitle,"");
|
||||||
|
for(t=0; t<withTokens.length; t++) {
|
||||||
} else {
|
var placeholderRegExp = new RegExp("\\$"+(t+1),"mg");
|
||||||
// There are no substitution tokens, so just copy the parse tree of the tiddler
|
text = text.replace(placeholderRegExp,withTokens[t]);
|
||||||
var copy = utils.deepCopy(store.getTiddler(title).getParseTree().tree);
|
|
||||||
for(var t=0; t<copy.length; t++) {
|
|
||||||
macroNode.output.push(copy[t]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
var parseTree = new WikiTextParserModule.WikiTextParser(text);
|
||||||
|
for(var t=0; t<parseTree.tree.length; t++) {
|
||||||
|
macroNode.output.push(parseTree.tree[t]);
|
||||||
|
}
|
||||||
|
// Execute any macros in the copy
|
||||||
|
wikiTextMacros.executeMacros(macroNode.output,store,tiddler);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeline: {
|
timeline: {
|
||||||
|
@ -1 +1 @@
|
|||||||
An image <img src="Something.jpg" /> and a couple of Ç Ç "HTML Entity"
|
An image <img src="Something.jpg" /> and a $1 couple of Ç Ç "HTML Entity" and macro 0.0.0
|
@ -1,3 +1,3 @@
|
|||||||
title: Fourth Tiddler
|
title: Fourth Tiddler
|
||||||
|
|
||||||
An image [img[Something.jpg]] and a couple of Ç Ç "HTML Entity"
|
An image [img[Something.jpg]] and a $1 couple of Ç Ç "HTML Entity" and macro <<version>>
|
@ -1 +1 @@
|
|||||||
An image and a couple of Ç Ç "HTML Entity"
|
An image and a $1 couple of Ç Ç "HTML Entity" and macro 0.0.0
|
@ -1 +1 @@
|
|||||||
An explicit link <a href="Fourth Tiddler">Fourth Tiddler</a> and <a href="Fourth Tiddler">a pretty link</a> and a transclusion An image <img src="Something.jpg" /> and a couple of Ç Ç "HTML Entity"
|
An explicit link <a href="Fourth Tiddler">Fourth Tiddler</a> and <a href="Fourth Tiddler">a pretty link</a> and a transclusion An image <img src="Something.jpg" /> and a Stringy couple of Ç Ç "HTML Entity" and macro 0.0.0
|
@ -1,3 +1,3 @@
|
|||||||
title: ThirdTiddler
|
title: ThirdTiddler
|
||||||
|
|
||||||
An explicit link [[Fourth Tiddler]] and [[a pretty link|Fourth Tiddler]] and a transclusion <<tiddler [[Fourth Tiddler]]>>
|
An explicit link [[Fourth Tiddler]] and [[a pretty link|Fourth Tiddler]] and a transclusion <<tiddler [[Fourth Tiddler]] with:Stringy>>
|
@ -1 +1 @@
|
|||||||
An explicit link Fourth Tiddler and a pretty link and a transclusion An image and a couple of Ç Ç "HTML Entity"
|
An explicit link Fourth Tiddler and a pretty link and a transclusion An image and a Stringy couple of Ç Ç "HTML Entity" and macro 0.0.0
|
Loading…
x
Reference in New Issue
Block a user