1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 21:39:57 +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 type: application/javascript
module-type: wikitextrule module-type: wikitextrule
Wiki text run rule for pretty links. For example: Wiki text rule for macros
{{{
<<version>>
<<link to:HelloThere><
A macro with a bunch of content inside it. The content can include //formatting//.
>>
}}}
\*/ \*/
(function(){ (function(){
@ -52,6 +44,8 @@ exports.parse = function(match,isBlock) {
content = this.parseRun(/(>>)/mg); content = this.parseRun(/(>>)/mg);
} }
} }
var macroName = match[1] || match[2];
if(macroName in $tw.wiki.macros) {
var macroNode = $tw.Tree.Macro(match[1] || match[2],{ var macroNode = $tw.Tree.Macro(match[1] || match[2],{
srcParams: match[3], srcParams: match[3],
content: content, content: content,
@ -60,6 +54,9 @@ exports.parse = function(match,isBlock) {
}); });
this.dependencies.mergeDependencies(macroNode.dependencies); this.dependencies.mergeDependencies(macroNode.dependencies);
return [macroNode]; return [macroNode];
} else {
console.log("Missing macro '" + macroName + "'");
}
} }
return []; return [];
}; };