Hides todo when requested, do not show list when no todos, todos can be marked as done

main
dorianx 2024-03-21 16:22:54 +01:00
parent d4b11cd25c
commit f7ddb12910
1 changed files with 14 additions and 10 deletions

24
lib.typ
View File

@ -1,20 +1,24 @@
#import "@preview/gviz:0.1.0": * #import "@preview/gviz:0.1.0": *
#let todo-list = state("todo-list",()) #let todo-list = state("todo-list",())
#let show-todos = state("show-todos", true)
#let todo(content) = context { #let todo(done: false, content) = context {
let todonum = todo-list.get().len() + 1 if (not done) and (show-todos.get()) {
text(weight: "bold", fill: red, [TODO n°#todonum #label("todo-"+str(todonum)): #content]) let todonum = todo-list.get().len() + 1
todo-list.update(x => x + (("todo-"+str(x.len()+1),x.len()+1, content),)) text(weight: "bold", fill: red, [TODO n°#todonum #label("todo-"+str(todonum)): #content])
todo-list.update(x => x + (("todo-"+str(x.len()+1),x.len()+1, content),))
}
} }
#let todos() = context { #let todos() = context {
pagebreak(weak: true) if (todo-list.final().len() != 0) and (show-todos.get()) {
[= TO-DOs] pagebreak(weak: true)
for t in todo-list.final() { [= TO-DOs]
let l = label(t.first()) for t in todo-list.final() {
list.item(link(l)[TODO n°#t.at(1) p.#locate(l).page() : #t.last()]) let l = label(t.first())
list.item(link(l)[TODO n°#t.at(1) p.#locate(l).page() : #t.last()])
}
} }
} }