Skip to content

Commit dd3d497

Browse files
committed
Fix issue with nested lists
Closes remarkjs/remark#269.
1 parent 26d69c9 commit dd3d497

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

handlers/list.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function list(h, node) {
1010
var start = null;
1111
var loose = false;
1212
var content;
13+
var child;
1314
var length;
1415
var index;
1516

@@ -22,9 +23,20 @@ function list(h, node) {
2223
index = -1;
2324

2425
while (++index < length) {
25-
if (content[index].loose === true) {
26+
child = content[index];
27+
28+
if (child.type !== 'listItem') {
29+
child = {
30+
type: 'listItem',
31+
loose: false,
32+
checked: null,
33+
children: [child]
34+
};
35+
content[index] = child;
36+
}
37+
38+
if (child.loose === true) {
2639
loose = true;
27-
break;
2840
}
2941
}
3042

tests/fixtures/ul-ul/index.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<p>Filed on <a href="https://github.com/wooorm/remark/issues/269">remark’s repo</a>.</p>
2+
3+
<ul>
4+
<ul>
5+
<li>Alpha</li>
6+
</ul>
7+
</ul>

tests/fixtures/ul-ul/index.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"fragment": true
3+
}

tests/fixtures/ul-ul/index.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Filed on [remark’s repo](https://github.com/wooorm/remark/issues/269).
2+
3+
- - Alpha

0 commit comments

Comments
 (0)