1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-30 13:29:56 +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,14 +44,19 @@ exports.parse = function(match,isBlock) {
content = this.parseRun(/(>>)/mg); content = this.parseRun(/(>>)/mg);
} }
} }
var macroNode = $tw.Tree.Macro(match[1] || match[2],{ var macroName = match[1] || match[2];
srcParams: match[3], if(macroName in $tw.wiki.macros) {
content: content, var macroNode = $tw.Tree.Macro(match[1] || match[2],{
isBlock: isBlock, srcParams: match[3],
wiki: this.wiki content: content,
}); isBlock: isBlock,
this.dependencies.mergeDependencies(macroNode.dependencies); wiki: this.wiki
return [macroNode]; });
this.dependencies.mergeDependencies(macroNode.dependencies);
return [macroNode];
} else {
console.log("Missing macro '" + macroName + "'");
}
} }
return []; return [];
}; };