1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-02 18:23:28 +00:00

Fixed problem with missing macros throwing an error

This commit is contained in:
Jeremy Ruston 2012-11-18 13:43:06 +00:00
parent 5c87b437ee
commit 605a7a4124

View File

@ -3,15 +3,7 @@ title: $:/core/modules/parsers/wikitextparser/rules/macro.js
type: application/javascript
module-type: wikitextrule
Wiki text run rule for pretty links. For example:
{{{
<<version>>
<<link to:HelloThere><
A macro with a bunch of content inside it. The content can include //formatting//.
>>
}}}
Wiki text rule for macros
\*/
(function(){
@ -52,14 +44,19 @@ exports.parse = function(match,isBlock) {
content = this.parseRun(/(>>)/mg);
}
}
var macroNode = $tw.Tree.Macro(match[1] || match[2],{
srcParams: match[3],
content: content,
isBlock: isBlock,
wiki: this.wiki
});
this.dependencies.mergeDependencies(macroNode.dependencies);
return [macroNode];
var macroName = match[1] || match[2];
if(macroName in $tw.wiki.macros) {
var macroNode = $tw.Tree.Macro(match[1] || match[2],{
srcParams: match[3],
content: content,
isBlock: isBlock,
wiki: this.wiki
});
this.dependencies.mergeDependencies(macroNode.dependencies);
return [macroNode];
} else {
console.log("Missing macro '" + macroName + "'");
}
}
return [];
};