mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Added tracking of dependencies between tiddlers
This commit is contained in:
parent
3d507c3bab
commit
82a83bd714
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user