Made the class block rule do it's own class assignment

print-window-tiddler
Jeremy Ruston 2012-06-14 17:40:27 +01:00
rodzic abd510442a
commit fa279514c7
2 zmienionych plików z 6 dodań i 11 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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;
};