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

Display a chechbox for checkboxes. #102

Merged
merged 3 commits into from
Nov 12, 2024
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
13 changes: 10 additions & 3 deletions src/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,16 @@ class HTMLRenderer {
return this.inTags("li", node, 2);

case "task_list_item":
return this.inTags("li", node, 2,
{ class: node.checkbox === "checked"
? "checked" : "unchecked" });
let result = "<li>\n";
if (node.checkbox === "checked") {
result += '<input disabled="" type="checkbox" checked=""/>\n';
} else {
result += '<input disabled="" type="checkbox"/>\n';
}
result += this.renderChildren(node);
result += this.renderCloseTag("li");
result += "\n";
return result;

case "definition_list_item":
return this.renderChildren(node);
Expand Down
12 changes: 8 additions & 4 deletions test/task_lists.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
- [x] checked item
.
<ul class="task-list">
<li class="unchecked">
<li>
<input disabled="" type="checkbox"/>
an unchecked task list item
</li>
<li class="checked">
<li>
<input disabled="" type="checkbox" checked=""/>
checked item
</li>
</ul>
Expand All @@ -20,11 +22,13 @@ checked item
* [x] checked item
.
<ul class="task-list">
<li class="unchecked">
<li>
<input disabled="" type="checkbox"/>
<p>an unchecked task list item</p>
<p>with two paragraphs</p>
</li>
<li class="checked">
<li>
<input disabled="" type="checkbox" checked=""/>
<p>checked item</p>
</li>
</ul>
Expand Down
Loading