mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +00:00
Made the class block rule do it's own class assignment
This commit is contained in:
parent
abd510442a
commit
fa279514c7
@ -71,10 +71,7 @@ WikiTextRenderer.prototype.parseBlock = function(terminatorRegExpString,options)
|
||||
/*
|
||||
Parse blocks of text until a terminating regexp is encountered or the end of the text
|
||||
terminatorRegExpString: terminating regular expression
|
||||
options: see below
|
||||
|
||||
Options are:
|
||||
addClass: optional CSS class to add to each block
|
||||
options: none at present
|
||||
*/
|
||||
WikiTextRenderer.prototype.parseBlocks = function(terminatorRegExpString,options) {
|
||||
if(terminatorRegExpString) {
|
||||
@ -110,12 +107,7 @@ WikiTextRenderer.prototype.parseBlocksTerminated = function(terminatorRegExpStri
|
||||
// Parse the text into blocks
|
||||
while(this.pos < this.sourceLength && !(match && match.index === this.pos)) {
|
||||
var blocks = this.parseBlock(terminatorRegExpString,{leaveTerminator: true});
|
||||
for(var t=0; t<blocks.length; t++) {
|
||||
if(options.addClass) {
|
||||
blocks[t].addClass(options.addClass);
|
||||
}
|
||||
tree.push(blocks[t]);
|
||||
}
|
||||
tree.push.apply(tree,blocks);
|
||||
// Skip any whitespace
|
||||
this.skipWhitespace();
|
||||
// Check if we've got the end marker
|
||||
|
@ -39,7 +39,10 @@ exports.parse = function(match,isBlock) {
|
||||
match = reStart.exec(this.source);
|
||||
if(match) {
|
||||
this.pos = match.index + match[0].length;
|
||||
tree = this.parseBlocks(reEndString,{addClass: match[1]});
|
||||
tree = this.parseBlocks(reEndString);
|
||||
for(var t=0; t<tree.length; t++) {
|
||||
tree[t].addClass(match[1]);
|
||||
}
|
||||
}
|
||||
return tree;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user