Skip to content

Commit

Permalink
Merge pull request #1535 from UziTech/loose-task-list
Browse files Browse the repository at this point in the history
Loose task list
  • Loading branch information
joshbruce committed Aug 19, 2019
2 parents 2df12a7 + d5767ac commit f569637
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/marked.js
Expand Up @@ -1265,7 +1265,19 @@ Parser.prototype.tok = function() {
var task = this.token.task;

if (this.token.task) {
body += this.renderer.checkbox(checked);
if (loose) {
if (this.peek().type === 'text') {
var nextToken = this.peek();
nextToken.text = this.renderer.checkbox(checked) + ' ' + nextToken.text;
} else {
this.tokens.push({
type: 'text',
text: this.renderer.checkbox(checked)
});
}
} else {
body += this.renderer.checkbox(checked);
}
}

while (this.next().type !== 'list_item_end') {
Expand Down
12 changes: 12 additions & 0 deletions test/specs/new/list_loose_tasks.html
@@ -0,0 +1,12 @@
<ul>
<li>
<p>Tasks</p>
</li>
<li>
<p><input type="checkbox" checked="" disabled=""> Task1</p>
</li>
<li>
<p><input type="checkbox" disabled=""></p>
<pre>Task2</pre>
</li>
</ul>
4 changes: 4 additions & 0 deletions test/specs/new/list_loose_tasks.md
@@ -0,0 +1,4 @@
- Tasks
- [x] Task1

- [ ] <pre>Task2</pre>

1 comment on commit f569637

@vercel
Copy link

@vercel vercel bot commented on f569637 Aug 19, 2019

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.