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) {
|
||||
var str = str.replace(/^ +$/gm, '')
|
||||
, loose
|
||||
, cap;
|
||||
, cap
|
||||
, item
|
||||
, space
|
||||
, i
|
||||
, l;
|
||||
|
||||
while (str) {
|
||||
if (cap = block.newline.exec(str)) {
|
||||
@ -130,13 +134,15 @@ block.token = function(str, tokens) {
|
||||
/^( *)([*+-]|\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
|
||||
// so its seen as the next token
|
||||
item = item.replace(/^ *([*+-]|\d+\.) */, '');
|
||||
item = cap[i].replace(/^ *([*+-]|\d+\.) */, '');
|
||||
// outdent whatever the
|
||||
// list item contains, hacky
|
||||
var space = /\n( +)/.exec(item);
|
||||
space = /\n( +)/.exec(item);
|
||||
if (space) {
|
||||
space = new RegExp('^' + space[1], 'gm');
|
||||
item = item.replace(space, '');
|
||||
@ -150,7 +156,7 @@ block.token = function(str, tokens) {
|
||||
tokens.push({
|
||||
type: 'list_item_end'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
tokens.push({
|
||||
type: 'list_end'
|
||||
@ -515,11 +521,6 @@ var mangle = function(str) {
|
||||
return out;
|
||||
};
|
||||
|
||||
var each = function(obj, func) {
|
||||
var i = 0, l = obj.length;
|
||||
for (; i < l; i++) func(obj[i]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expose
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user