diff --git a/js/WikiTextParseTree.js b/js/WikiTextParseTree.js index fdc893014..bcc27c7c8 100644 --- a/js/WikiTextParseTree.js +++ b/js/WikiTextParseTree.js @@ -13,8 +13,9 @@ var ArgParser = require("./ArgParser.js").ArgParser, utils = require("./Utils.js"); // Intialise the parse tree object -var WikiTextParseTree = function(tree,store) { +var WikiTextParseTree = function(tree,dependencies,store) { this.tree = tree; + this.dependencies = dependencies; // An array of tiddler names, or null if this tiddler depends on too many to track this.store = store; }; diff --git a/js/WikiTextParser.js b/js/WikiTextParser.js index ad3a19eb8..b2c4b9a88 100644 --- a/js/WikiTextParser.js +++ b/js/WikiTextParser.js @@ -44,9 +44,10 @@ WikiTextParser.prototype.parse = function(text) { this.source = text; this.nextMatch = 0; this.children = []; + this.dependencies = []; this.output = null; this.subWikify(this.children); - return new WikiTextParseTree(this.children,this.store); + return new WikiTextParseTree(this.children,this.dependencies,this.store); }; WikiTextParser.prototype.outputText = function(place,startPos,endPos) { diff --git a/js/WikiTextRules.js b/js/WikiTextRules.js index 1864c3c85..c57f15256 100755 --- a/js/WikiTextRules.js +++ b/js/WikiTextRules.js @@ -113,20 +113,31 @@ var parseMacroCall = function(w,name,paramString) { params = {}; if(macro) { var args = new ArgParser(paramString,{defaultName: "anon"}), - insertParam = function(name,arg) { + insertParam = function(param,name,arg) { + if(param.type === "tiddler") { + if(arg.evaluated) { + w.dependencies = null; + } else { + if(w.dependencies) { + w.dependencies.push(arg.string); + } + } + } params[name] = {type: arg.evaluated ? "eval" : "string", value: arg.string}; }; for(var m in macro.params) { - var param = macro.params[m]; + var param = macro.params[m], + arg; if("byPos" in param && args.byPos[param.byPos]) { - insertParam(m,args.byPos[param.byPos].v); + arg = args.byPos[param.byPos].v; + insertParam(param,m,arg); } else if("byName" in param) { - var arg = args.getValueByName(m); + arg = args.getValueByName(m); if(!arg && param.byName === "default") { arg = args.getValueByName("anon"); } if(arg) { - insertParam(m,arg); + insertParam(param,m,arg); } } }