use for loop instead of each function
This commit is contained in:
parent
c5f2319702
commit
21d0acf145
@ -51,7 +51,11 @@ block.lexer = function(str) {
|
|||||||
block.token = function(str, tokens) {
|
block.token = function(str, tokens) {
|
||||||
var str = str.replace(/^ +$/gm, '')
|
var str = str.replace(/^ +$/gm, '')
|
||||||
, loose
|
, loose
|
||||||
, cap;
|
, cap
|
||||||
|
, item
|
||||||
|
, space
|
||||||
|
, i
|
||||||
|
, l;
|
||||||
|
|
||||||
while (str) {
|
while (str) {
|
||||||
if (cap = block.newline.exec(str)) {
|
if (cap = block.newline.exec(str)) {
|
||||||
@ -130,13 +134,15 @@ block.token = function(str, tokens) {
|
|||||||
/^( *)([*+-]|\d+\.)[^\n]*(?:\n(?!\1(?:\2|\d+\.))[^\n]*)*/gm
|
/^( *)([*+-]|\d+\.)[^\n]*(?:\n(?!\1(?:\2|\d+\.))[^\n]*)*/gm
|
||||||
);
|
);
|
||||||
|
|
||||||
each(cap, function(item) {
|
i = 0, l = cap.length;
|
||||||
|
|
||||||
|
for (; i < l; i++) {
|
||||||
// remove the list items sigil
|
// remove the list items sigil
|
||||||
// so its seen as the next token
|
// so its seen as the next token
|
||||||
item = item.replace(/^ *([*+-]|\d+\.) */, '');
|
item = cap[i].replace(/^ *([*+-]|\d+\.) */, '');
|
||||||
// outdent whatever the
|
// outdent whatever the
|
||||||
// list item contains, hacky
|
// list item contains, hacky
|
||||||
var space = /\n( +)/.exec(item);
|
space = /\n( +)/.exec(item);
|
||||||
if (space) {
|
if (space) {
|
||||||
space = new RegExp('^' + space[1], 'gm');
|
space = new RegExp('^' + space[1], 'gm');
|
||||||
item = item.replace(space, '');
|
item = item.replace(space, '');
|
||||||
@ -150,7 +156,7 @@ block.token = function(str, tokens) {
|
|||||||
tokens.push({
|
tokens.push({
|
||||||
type: 'list_item_end'
|
type: 'list_item_end'
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
tokens.push({
|
tokens.push({
|
||||||
type: 'list_end'
|
type: 'list_end'
|
||||||
@ -515,11 +521,6 @@ var mangle = function(str) {
|
|||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
var each = function(obj, func) {
|
|
||||||
var i = 0, l = obj.length;
|
|
||||||
for (; i < l; i++) func(obj[i]);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expose
|
* Expose
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user