mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 18:59:42 +00:00
48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
/*\
|
|
title: $:/core/modules/parsers/newwikitextparser/rules/classblock.js
|
|
type: application/javascript
|
|
module-type: wikitextrule
|
|
|
|
Wiki text block rule for assigning classes to paragraphs and other blocks. For example:
|
|
|
|
{{{
|
|
{{myClass{
|
|
This paragraph will have the CSS class `myClass`.
|
|
|
|
* The `<ul>` around this list will also have the class `myClass`
|
|
* List item 2
|
|
|
|
}}}
|
|
}}}
|
|
|
|
Note that the opening and closing braces both must be immediately followed by a newline.
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
exports.name = "class";
|
|
|
|
exports.blockParser = true;
|
|
|
|
exports.regExpString = "\\{\\{(?:[^\\{\\r\\n]+)\\{$\\r?\\n";
|
|
|
|
exports.parse = function(match,isBlock) {
|
|
var tree = [],
|
|
reStart = /\{\{([^\{\r\n]+){\r?\n/mg,
|
|
reEndString = "(\\}\\}\\}$(?:\\r?\\n)?)",
|
|
endMatch;
|
|
reStart.lastIndex = this.pos;
|
|
match = reStart.exec(this.source);
|
|
if(match) {
|
|
this.pos = match.index + match[0].length;
|
|
tree = this.parseBlocks(reEndString,{addClass: match[1]});
|
|
}
|
|
return tree;
|
|
};
|
|
|
|
})();
|