Skip to content

Commit

Permalink
Fix empty text node for emphasis after task
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 21, 2020
1 parent 3a33370 commit ec141d0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
10 changes: 7 additions & 3 deletions from-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ function exitParagraphWithTaskListItem(token) {
) {
// Must start with a space or a tab.
head.value = head.value.slice(1)
head.position.start.column++
head.position.start.offset++
node.position.start = Object.assign({}, head.position.start)
if (head.value.length === 0) {
node.children.shift()
} else {
head.position.start.column++
head.position.start.offset++
node.position.start = Object.assign({}, head.position.start)
}
}

this.exit(token)
Expand Down
22 changes: 22 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,28 @@ test('markdown -> mdast', function (t) {
'should not support a task list item when not in a list item'
)

t.deepEqual(
removePosition(
fromMarkdown('* [x] *b*', {
extensions: [syntax],
mdastExtensions: [taskListItem.fromMarkdown]
}),
true
).children[0].children[0],
{
type: 'listItem',
spread: false,
checked: true,
children: [
{
type: 'paragraph',
children: [{type: 'emphasis', children: [{type: 'text', value: 'b'}]}]
}
]
},
'should support a text construct after the checkbox'
)

t.end()
})

Expand Down

0 comments on commit ec141d0

Please sign in to comment.