Skip to content

Commit

Permalink
Merge pull request #1674 from UziTech/task-no-tokens
Browse files Browse the repository at this point in the history
fix loose task list with no tokens
  • Loading branch information
styfle committed May 12, 2020
2 parents 0cd8598 + 369bf41 commit cec5f5e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Parser.js
Expand Up @@ -130,7 +130,7 @@ module.exports = class Parser {
if (item.task) {
checkbox = this.renderer.checkbox(checked);
if (loose) {
if (item.tokens[0].type === 'text') {
if (item.tokens.length > 0 && item.tokens[0].type === 'text') {
item.tokens[0].text = checkbox + ' ' + item.tokens[0].text;
if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === 'text') {
item.tokens[0].tokens[0].text = checkbox + ' ' + item.tokens[0].tokens[0].text;
Expand Down
3 changes: 3 additions & 0 deletions test/specs/new/list_loose_tasks.html
Expand Up @@ -9,4 +9,7 @@
<p><input type="checkbox" disabled=""></p>
<pre>Task2</pre>
</li>
<li>
<p><input type="checkbox" disabled=""></p>
</li>
</ul>
2 changes: 2 additions & 0 deletions test/specs/new/list_loose_tasks.md
Expand Up @@ -2,3 +2,5 @@
- [x] Task1

- [ ] <pre>Task2</pre>

- [ ]

1 comment on commit cec5f5e

@vercel
Copy link

@vercel vercel bot commented on cec5f5e May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.