Skip to content

Commit 263b9bd

Browse files
committed
Merge pull request #190 from eviltrout/shift_error
FIX: Uncaught TypeError: Cannot call method 'shift' of undefined
2 parents 3acdf70 + 8e3e65b commit 263b9bd

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

src/dialects/gruber.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -334,22 +334,24 @@ define(['../markdown_helpers', './dialect_helpers', '../parser'], function (Mark
334334
} // tight_search
335335

336336
if ( li_accumulate.length ) {
337-
337+
338338
var contents = this.processBlock(li_accumulate, []),
339339
firstBlock = contents[0];
340340

341-
firstBlock.shift();
342-
contents.splice.apply(contents, [0, 1].concat(firstBlock));
343-
add( last_li, loose, contents, nl );
341+
if (firstBlock) {
342+
firstBlock.shift();
343+
contents.splice.apply(contents, [0, 1].concat(firstBlock));
344+
add( last_li, loose, contents, nl );
344345

345-
// Let's not creating a trailing \n after content in the li
346-
if(last_li[last_li.length-1] === "\n") {
347-
last_li.pop();
348-
}
346+
// Let's not creating a trailing \n after content in the li
347+
if(last_li[last_li.length-1] === "\n") {
348+
last_li.pop();
349+
}
349350

350-
// Loose mode will have been dealt with. Reset it
351-
loose = false;
352-
li_accumulate = "";
351+
// Loose mode will have been dealt with. Reset it
352+
loose = false;
353+
li_accumulate = "";
354+
}
353355
}
354356

355357
// Look at the next block - we might have a loose list. Or an extra
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
["html",
2+
["p",
3+
["a",
4+
{ "href" : "http://example.com" },
5+
"hi"
6+
]
7+
],
8+
["ul", ["li"]]
9+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[hi][link]
2+
3+
- [link]: http://example.com

0 commit comments

Comments
 (0)