diff --git a/lib/marked.js b/lib/marked.js index c156309ccf..c0db7ee6b5 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -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') { diff --git a/test/specs/new/list_loose_tasks.html b/test/specs/new/list_loose_tasks.html new file mode 100644 index 0000000000..ae4e8c58b2 --- /dev/null +++ b/test/specs/new/list_loose_tasks.html @@ -0,0 +1,12 @@ + diff --git a/test/specs/new/list_loose_tasks.md b/test/specs/new/list_loose_tasks.md new file mode 100644 index 0000000000..cb1cab5b0d --- /dev/null +++ b/test/specs/new/list_loose_tasks.md @@ -0,0 +1,4 @@ +- Tasks +- [x] Task1 + +- [ ]
Task2