Stop using triple curly braces for code

We'll use triple curly braces for filtered transclusions, and require
backtick for code.
print-window-tiddler
Jeremy Ruston 2012-12-22 23:09:10 +00:00
rodzic fa17eb1b96
commit 8f85ef94a6
2 zmienionych plików z 11 dodań i 18 usunięć

Wyświetl plik

@ -5,13 +5,11 @@ module-type: wikirule
Wiki text rule for code blocks. For example: Wiki text rule for code blocks. For example:
{{{ ```
{{{ ```
This text will not be //wikified// This text will not be //wikified//
}}} ```
}}} ```
Note that the opening curly braces and the closing curly braces must each be on a line of their own, and not be preceded or followed by white space.
\*/ \*/
(function(){ (function(){
@ -26,11 +24,11 @@ exports.types = {block: true};
exports.init = function(parser) { exports.init = function(parser) {
this.parser = parser; this.parser = parser;
// Regexp to match // Regexp to match
this.matchRegExp = /\{\{\{\r?\n/mg; this.matchRegExp = /```\r?\n/mg;
}; };
exports.parse = function() { exports.parse = function() {
var reEnd = /(\r?\n\}\}\}$)/mg; var reEnd = /(\r?\n```$)/mg;
// Move past the match // Move past the match
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
// Look for the end of the block // Look for the end of the block

Wyświetl plik

@ -5,9 +5,9 @@ module-type: wikirule
Wiki text inline rule for code runs. For example: Wiki text inline rule for code runs. For example:
{{{ ```
This is a {{{code run}}} and `so is this`. This is a `code run`.
}}} ```
\*/ \*/
(function(){ (function(){
@ -22,18 +22,13 @@ exports.types = {inline: true};
exports.init = function(parser) { exports.init = function(parser) {
this.parser = parser; this.parser = parser;
// Regexp to match // Regexp to match
this.matchRegExp = /(\{\{\{)|(`)/mg; this.matchRegExp = /`/mg;
}; };
exports.parse = function() { exports.parse = function() {
// Move past the match // Move past the match
this.parser.pos = this.matchRegExp.lastIndex; this.parser.pos = this.matchRegExp.lastIndex;
var reEnd; var reEnd = /`/mg;
if(this.match[0] === "{{{") {
reEnd = /(\}\}\})/mg;
} else {
reEnd = /(`)/mg;
}
// Look for the end marker // Look for the end marker
reEnd.lastIndex = this.parser.pos; reEnd.lastIndex = this.parser.pos;
var match = reEnd.exec(this.parser.source), var match = reEnd.exec(this.parser.source),