Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
import type Turnish from "turnish";
export default function taskListItems (turndownService: Turnish) {
turndownService.addRule('taskListItems', {
filter: function (node) {
// `node` is turnish's ExtendedNode (Element + extra props), which doesn't overlap
// HTMLInputElement directly, so cast through `unknown` to read the input `type`.
return (node as unknown as HTMLInputElement).type === 'checkbox' && node.parentNode?.nodeName === 'LI'
},
replacement: function (content: string, node) {
return (node.checked ? '[x]' : '[ ]') + ' '
}
})
}