Skip to content

Commit 14df623

Browse files
gkatsevBarryThePenguin
authored andcommitted
fix tight for all heading levels (#3)
Tight mode was failing for heading levels greater than 2
1 parent 1a45e5c commit 14df623

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

lib/insert.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ function insert(node, parent, tight) {
5858
} else if (last && last.type === LIST) {
5959
node.depth--;
6060

61-
insert(node, last);
61+
insert(node, last, tight);
6262
} else if (parent.type === LIST) {
6363
item = listItem();
6464

65-
insert(node, item);
65+
insert(node, item, tight);
6666

6767
children.push(item);
6868
} else {
6969
item = list();
7070
node.depth--;
7171

72-
insert(node, item);
72+
insert(node, item, tight);
7373

7474
children.push(item);
7575
}

test/fixtures/tight/input.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ Text.
66

77
## Something elsefi
88

9+
### Yet Another Thing
10+
11+
### And another thing
12+
913
# Something iffi

test/fixtures/tight/output.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,56 @@
7070
]
7171
}
7272
]
73+
},
74+
{
75+
"type": "list",
76+
"ordered": false,
77+
"children": [
78+
{
79+
"type": "listItem",
80+
"loose": false,
81+
"children": [
82+
{
83+
"type": "paragraph",
84+
"children": [
85+
{
86+
"type": "link",
87+
"title": null,
88+
"url": "#yet-another-thing",
89+
"children": [
90+
{
91+
"type": "text",
92+
"value": "Yet Another Thing"
93+
}
94+
]
95+
}
96+
]
97+
}
98+
]
99+
},
100+
{
101+
"type": "listItem",
102+
"loose": false,
103+
"children": [
104+
{
105+
"type": "paragraph",
106+
"children": [
107+
{
108+
"type": "link",
109+
"title": null,
110+
"url": "#and-another-thing",
111+
"children": [
112+
{
113+
"type": "text",
114+
"value": "And another thing"
115+
}
116+
]
117+
}
118+
]
119+
}
120+
]
121+
}
122+
]
73123
}
74124
]
75125
}

0 commit comments

Comments
 (0)