This repository was archived by the owner on Jun 24, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +26
-0
lines changed
docs/Release Notes/Release Notes Expand file tree Collapse file tree 3 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 3737* Basic Touch Bar support for macOS.
3838* [ Support Bearer Token] ( https://github.com/TriliumNext/Notes/issues/1701 )
3939* The tab bar is now scrollable when there are many tabs by @SiriusXT
40+ * Markdown export: support todo lists
4041
4142## 🌍 Internationalization
4243
Original file line number Diff line number Diff line change @@ -321,4 +321,25 @@ describe("Markdown export", () => {
321321 expect ( markdownExportService . toMarkdown ( html ) ) . toBe ( expected ) ;
322322 } ) ;
323323
324+ it ( "exports todo lists properly" , ( ) => {
325+ const html = trimIndentation /*html*/ `\
326+ <ul class="todo-list">
327+ <li>
328+ <label class="todo-list__label">
329+ <input type="checkbox" checked="checked" disabled="disabled"><span class="todo-list__label__description">Hello</span>
330+ </label>
331+ </li>
332+ <li>
333+ <label class="todo-list__label">
334+ <input type="checkbox" disabled="disabled"><span class="todo-list__label__description">World</span>
335+ </label>
336+ </li>
337+ </ul>
338+ ` ;
339+ const expected = trimIndentation `\
340+ - [x] Hello
341+ - [ ] World` ;
342+ expect ( markdownExportService . toMarkdown ( html ) ) . toBe ( expected ) ;
343+ } ) ;
344+
324345} ) ;
Original file line number Diff line number Diff line change @@ -230,7 +230,11 @@ function buildListItemFilter(): Rule {
230230 var start = parent . getAttribute ( 'start' )
231231 var index = Array . prototype . indexOf . call ( parent . children , node )
232232 prefix = ( start ? Number ( start ) + index : index + 1 ) + '. '
233+ } else if ( parent . classList . contains ( "todo-list" ) ) {
234+ const isChecked = node . querySelector ( "input[type=checkbox]:checked" ) ;
235+ prefix = ( isChecked ? "- [x] " : "- [ ] " ) ;
233236 }
237+
234238 const result = prefix + content + ( node . nextSibling && ! / \n $ / . test ( content ) ? '\n' : '' ) ;
235239 return result ;
236240 }
You can’t perform that action at this time.
0 commit comments