Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loose task list #1535

Merged
merged 2 commits into from
Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
12 changes: 12 additions & 0 deletions test/specs/new/list_loose_tasks.html
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Tasks
- [x] Task1

- [ ] <pre>Task2</pre>