kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Made the class block rule do it's own class assignment
rodzic
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
|
Parse blocks of text until a terminating regexp is encountered or the end of the text
|
||||||
terminatorRegExpString: terminating regular expression
|
terminatorRegExpString: terminating regular expression
|
||||||
options: see below
|
options: none at present
|
||||||
|
|
||||||
Options are:
|
|
||||||
addClass: optional CSS class to add to each block
|
|
||||||
*/
|
*/
|
||||||
WikiTextRenderer.prototype.parseBlocks = function(terminatorRegExpString,options) {
|
WikiTextRenderer.prototype.parseBlocks = function(terminatorRegExpString,options) {
|
||||||
if(terminatorRegExpString) {
|
if(terminatorRegExpString) {
|
||||||
|
@ -110,12 +107,7 @@ WikiTextRenderer.prototype.parseBlocksTerminated = function(terminatorRegExpStri
|
||||||
// Parse the text into blocks
|
// Parse the text into blocks
|
||||||
while(this.pos < this.sourceLength && !(match && match.index === this.pos)) {
|
while(this.pos < this.sourceLength && !(match && match.index === this.pos)) {
|
||||||
var blocks = this.parseBlock(terminatorRegExpString,{leaveTerminator: true});
|
var blocks = this.parseBlock(terminatorRegExpString,{leaveTerminator: true});
|
||||||
for(var t=0; t<blocks.length; t++) {
|
tree.push.apply(tree,blocks);
|
||||||
if(options.addClass) {
|
|
||||||
blocks[t].addClass(options.addClass);
|
|
||||||
}
|
|
||||||
tree.push(blocks[t]);
|
|
||||||
}
|
|
||||||
// Skip any whitespace
|
// Skip any whitespace
|
||||||
this.skipWhitespace();
|
this.skipWhitespace();
|
||||||
// Check if we've got the end marker
|
// Check if we've got the end marker
|
||||||
|
|
|
@ -39,7 +39,10 @@ exports.parse = function(match,isBlock) {
|
||||||
match = reStart.exec(this.source);
|
match = reStart.exec(this.source);
|
||||||
if(match) {
|
if(match) {
|
||||||
this.pos = match.index + match[0].length;
|
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;
|
return tree;
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue