Skip to content

Commit 3a218c1

Browse files
Fixes list-item-with-newline-before-content.
1 parent 1cf8ad2 commit 3a218c1

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ function parseOrderedListMarker(state: StateBlock, startLine: number): { bulletC
6060
let finalPos = start + match[0].length;
6161
const finalChar = state.src.charCodeAt(finalPos);
6262

63-
// requires once space after marker
64-
if (isSpace(finalChar) === false) {
63+
// requires once space after marker or eol
64+
if (isSpace(finalChar) === false && finalPos !== max) {
6565
return null;
6666
}
6767

test/index.ts

+35
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,41 @@ describe("markdownFancyLists", () => {
5454
await assertHTML(expectedHtml, markdown);
5555
});
5656

57+
it("does not not continue the list item if there is no list item content before the newline", async () => {
58+
const markdown = `
59+
1.
60+
foo
61+
62+
2.
63+
bar
64+
`;
65+
const expectedHtml = `
66+
<ol>
67+
<li></li>
68+
</ol>
69+
<p>foo</p>
70+
<ol start="2">
71+
<li></li>
72+
</ol>
73+
<p>bar</p>
74+
`;
75+
await assertHTML(expectedHtml, markdown);
76+
});
77+
78+
it("requires a space after list marker", async () => {
79+
const markdown = `
80+
1.2 foo
81+
2.3 bar
82+
`;
83+
const expectedHtml = `
84+
<p>
85+
1.2 foo
86+
2.3 bar
87+
</p>
88+
`;
89+
await assertHTML(expectedHtml, markdown);
90+
});
91+
5792
it("supports lowercase alphabetical numbering", async () => {
5893
const markdown = `
5994
a. foo

0 commit comments

Comments
 (0)