1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Added support for macros with embedded content

This commit is contained in:
Jeremy Ruston 2012-06-05 17:01:17 +01:00
parent 03da553c3b
commit ee7fba9297
2 changed files with 10 additions and 3 deletions

View File

@ -17,16 +17,21 @@ exports.name = "macro";
exports.runParser = true; exports.runParser = true;
exports.blockParser = true; exports.blockParser = true;
exports.regExpString = "<<"; exports.regExpString = "<<(?:(?:[!@£\\$%\\^\\&\\*\\(\\)`\\~'\"\\|\\\\\\/;\\:\\.\\,\\+\\=\\-\\_\\{\\}])|(?:[^>\\s]+))(?:\\s*)(?:(?:[^>]|(?:>(?!>|<)))*)>(?:>|<)";
exports.parse = function(match,isBlock) { exports.parse = function(match,isBlock) {
var regExp = /<<(?:([!@£\$%\^\&\*\(\)`\~'"\|\\\/;\:\.\,\+\=\-\_\{\}])|([^>\s]+))(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg; var regExp = /<<(?:([!@£\$%\^\&\*\(\)`\~'"\|\\\/;\:\.\,\+\=\-\_\{\}])|([^>\s]+))(?:\s*)((?:[^>]|(?:>(?!>|<)))*)>(?:(>)|(<))/mg,
content = [];
regExp.lastIndex = this.pos; regExp.lastIndex = this.pos;
match = regExp.exec(this.source); match = regExp.exec(this.source);
if(match && match.index === this.pos) { if(match && match.index === this.pos) {
this.pos = match.index + match[0].length; this.pos = match.index + match[0].length;
if(match[5]) {
content = this.parseRun(/(>>)/mg);
}
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,
isBlock: isBlock, isBlock: isBlock,
wiki: this.wiki wiki: this.wiki
}); });

View File

@ -23,7 +23,9 @@ Here is some ''bold face'', and __some underlining__ and of course some --strike
Here's an unterminated ''bit of bold face. And also some entities like &#xc7; &#199; &quot;HTML Entity&quot;. Here's an unterminated ''bit of bold face. And also some entities like &#xc7; &#199; &quot;HTML Entity&quot;.
Here is a macro <<list all>> Here is a macro <<version>>.
This is a macro with content <<link to:"HelloThere"><This is a //link// to something.>>
! This is a new heading ! This is a new heading
This is a paragraph This is a paragraph