From 4bc3b9b05b0398a03c593bed3b42e07480de606f Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Wed, 14 Aug 2019 08:53:31 -0500 Subject: [PATCH 1/2] add test for loose task list --- test/specs/new/list_loose_tasks.html | 12 ++++++++++++ test/specs/new/list_loose_tasks.md | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 test/specs/new/list_loose_tasks.html create mode 100644 test/specs/new/list_loose_tasks.md 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
From d5767ace211b6893b92b53c99da5fa2f5f51609f Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Wed, 14 Aug 2019 09:06:03 -0500 Subject: [PATCH 2/2] add checkbox to next token in loose task list --- lib/marked.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/marked.js b/lib/marked.js index 49a4153a4b..2ed8d8f326 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -1267,7 +1267,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') {