Skip to content

Commit 70b1fa5

Browse files
committed
Fix bug with trailing indented lines after lists
Closes micromarkGH-114.
1 parent 8ee4727 commit 70b1fa5

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

example.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/micromark-util-subtokenize/dev/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ export function subtokenize(eventsArray) {
109109
otherEvent[1].type = types.lineEnding
110110
lineIndex = otherIndex
111111
}
112-
} else if (otherEvent[1].type === types.linePrefix) {
112+
} else if (
113+
otherEvent[1].type === types.linePrefix ||
114+
otherEvent[1].type === types.listItemIndent
115+
) {
113116
// Move past.
114117
} else {
115118
break

test/io/document/list-item.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,34 @@ test('list-item', async function (t) {
795795
}
796796
)
797797

798+
await t.test('should ignore trailing whitespace (1)', async function () {
799+
assert.equal(
800+
micromark('* a\n* b\n\n\n'),
801+
'<ul>\n<li>a</li>\n<li>b</li>\n</ul>\n'
802+
)
803+
})
804+
805+
await t.test('should ignore trailing whitespace (2)', async function () {
806+
assert.equal(
807+
micromark('* a\n* b\n \n\n'),
808+
'<ul>\n<li>a</li>\n<li>b</li>\n</ul>\n'
809+
)
810+
})
811+
812+
await t.test('should ignore trailing whitespace (3)', async function () {
813+
assert.equal(
814+
micromark('* a\n* b\n\n \n'),
815+
'<ul>\n<li>a</li>\n<li>b</li>\n</ul>\n'
816+
)
817+
})
818+
819+
await t.test('should ignore trailing whitespace (4)', async function () {
820+
assert.equal(
821+
micromark('* a\n* b\n \n \n'),
822+
'<ul>\n<li>a</li>\n<li>b</li>\n</ul>\n'
823+
)
824+
})
825+
798826
await t.test('should support turning off lists', async function () {
799827
assert.equal(
800828
micromark('- one\n\n two', {extensions: [{disable: {null: ['list']}}]}),

0 commit comments

Comments
 (0)