2012-06-02 08:41:21 +00:00
|
|
|
/*\
|
2012-06-02 08:54:00 +00:00
|
|
|
title: $:/core/modules/parsers/newwikitextparser/rules/codeblock.js
|
2012-06-02 08:41:21 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: wikitextrule
|
|
|
|
|
2012-06-05 21:54:36 +00:00
|
|
|
Wiki text run rule for code blocks. For example:
|
|
|
|
|
|
|
|
{{{
|
|
|
|
{{{
|
|
|
|
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.
|
2012-06-02 08:41:21 +00:00
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
2012-06-02 08:54:00 +00:00
|
|
|
exports.name = "codeblock";
|
2012-06-02 08:41:21 +00:00
|
|
|
|
|
|
|
exports.blockParser = true;
|
|
|
|
|
2012-06-05 21:54:36 +00:00
|
|
|
exports.regExpString = "\\{\\{\\{\\r?\\n";
|
2012-06-02 08:41:21 +00:00
|
|
|
|
|
|
|
exports.parse = function(match,isBlock) {
|
|
|
|
this.pos = match.index + match[0].length;
|
2012-06-05 21:54:36 +00:00
|
|
|
var regExp = /(\r?\n\}\}\}$)/mg,
|
2012-06-02 09:15:52 +00:00
|
|
|
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;
|
|
|
|
}
|
2012-06-04 11:25:08 +00:00
|
|
|
return [$tw.Tree.Element("pre",{},[$tw.Tree.Text(text)])];
|
2012-06-02 08:41:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|