1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-27 14:48:19 +00:00

Completed code blocks and runs

This commit is contained in:
Jeremy Ruston 2012-06-02 10:15:52 +01:00
parent 80b2d9c9fe
commit ec933eb1b5
3 changed files with 31 additions and 4 deletions

View File

@ -20,7 +20,18 @@ exports.regExpString = "\\{\\{\\{\\s*\\r?\\n";
exports.parse = function(match,isBlock) {
this.pos = match.index + match[0].length;
return [$tw.Tree.Element("pre",{},this.parseRun(/(\}\}\})/mg))];
var regExp = /(\r?\n\}\}\})/mg,
text;
regExp.lastIndex = this.pos;
match = regExp.exec(this.source);
if(match) {
text = this.source.substring(this.pos,match.index);
this.pos = match.index + match[0].length;
} else {
text = this.source.substr(this.pos);
this.pos = this.sourceLength;
}
return [$tw.Tree.Element("code",{},[$tw.Tree.Text(text)])];
};
})();

View File

@ -16,11 +16,27 @@ exports.name = "coderun";
exports.runParser = true;
exports.regExpString = "\\{\\{\\{";
exports.regExpString = "(?:\\{\\{\\{)|(?:`)";
exports.parse = function(match,isBlock) {
this.pos = match.index + match[0].length;
return [$tw.Tree.Element("code",{},this.parseRun(/(\}\}\})/mg))];
var regExp,
text;
if(match[0] === "{{{") {
regExp = /(\}\}\})/mg;
} else {
regExp = /(`)/mg;
}
regExp.lastIndex = this.pos;
match = regExp.exec(this.source);
if(match) {
text = this.source.substring(this.pos,match.index);
this.pos = match.index + match[0].length;
} else {
text = this.source.substr(this.pos);
this.pos = this.sourceLength;
}
return [$tw.Tree.Element("code",{},[$tw.Tree.Text(text)])];
};
})();

View File

@ -13,7 +13,7 @@ Here's a paragraph with an embedded macro <<image "Motovun Jack.jpg">> and that
This will be mono
}}}
And this will be {{{inline and monospaced}}}.
And this will be {{{inline and monospaced}}} and `so will this` little bit.
Here is a macro <<list all>>