Skip to content

Commit c893b07

Browse files
authored
fix: support task lists (#106)
1 parent 1b535c3 commit c893b07

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

mod.ts

+5
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ export function render(markdown: string, opts: RenderOptions = {}): string {
156156
"del",
157157
"details",
158158
"summary",
159+
"input",
159160
]);
160161
if (opts.allowIframes) {
161162
defaultAllowedTags.push("iframe");
@@ -292,6 +293,10 @@ export function render(markdown: string, opts: RenderOptions = {}): string {
292293
annotation: ["encoding"], // Only enabled when math is enabled
293294
details: ["open"],
294295
section: ["data-footnotes"],
296+
input: ["checked", "disabled", {
297+
name: "type",
298+
values: ["checkbox"],
299+
}],
295300
};
296301

297302
return sanitizeHtml(html, {

test/fixtures/taskList.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ul>
2+
<li>Normal list</li>
3+
<li><input checked disabled type="checkbox" /> done</li>
4+
<li><input disabled type="checkbox" /> not done</li>
5+
</ul>

test/test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,13 @@ Deno.test("svg test", () => {
379379
const html = render(markdown);
380380
assertEquals(html, result);
381381
});
382+
383+
Deno.test("task list", () => {
384+
const markdown = `- Normal list
385+
- [x] done
386+
- [ ] not done`;
387+
const expected = Deno.readTextFileSync("./test/fixtures/taskList.html");
388+
389+
const html = render(markdown);
390+
assertEquals(html, expected);
391+
});

0 commit comments

Comments
 (0)