From cb4317192a9bae1dfc5937d2f0ffa03c7891d57e Mon Sep 17 00:00:00 2001 From: Jean-Marie Mineau Date: Mon, 7 Jul 2025 10:33:31 +0200 Subject: [PATCH 1/3] try replacing locate with query --- lib/todos.typ | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/todos.typ b/lib/todos.typ index 6e879b2..b8bf364 100644 --- a/lib/todos.typ +++ b/lib/todos.typ @@ -27,7 +27,13 @@ text(size: 2em, weight: "bold", fill:red)[TO-DOs] for t in todo-list.final() { let l = label(t.first()) - list.item(link(l)[TODO n°#t.at(1) p.#locate(l).page() : #t.last()]) + let locs = query(l) + assert( + locs.len() >= 1, + message: "todo '" + t.first() + "' not found: " + + repr(t.last()) + " (query(" + repr(l) + ") = " + repr(locs) + ")" + ) + list.item(link(l)[TODO n°#t.at(1) p.#locs.first().location().page() : #t.last()]) } } } From acd42c4f622e9f48e573c598222dfebc6da63f61 Mon Sep 17 00:00:00 2001 From: Jean-Marie Mineau Date: Mon, 7 Jul 2025 12:37:53 +0200 Subject: [PATCH 2/3] anticipate a potential fallback for todos --- lib/todos.typ | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/todos.typ b/lib/todos.typ index b8bf364..6be7b6f 100644 --- a/lib/todos.typ +++ b/lib/todos.typ @@ -28,12 +28,18 @@ for t in todo-list.final() { let l = label(t.first()) let locs = query(l) + assert( locs.len() >= 1, message: "todo '" + t.first() + "' not found: " + repr(t.last()) + " (query(" + repr(l) + ") = " + repr(locs) + ")" - ) - list.item(link(l)[TODO n°#t.at(1) p.#locs.first().location().page() : #t.last()]) + ) + + if locs.len() >= 1 { + list.item(link(l)[TODO n°#t.at(1) p.#locs.first().location().page() : #t.last()]) + } else { + list.item(link(l)[TODO n°#t.at(1) p.??? : #t.last()]) + } } } } From 1652652d03cf66c5f562b01f5ba0f95272fe3ec7 Mon Sep 17 00:00:00 2001 From: Jean-Marie Mineau Date: Fri, 18 Jul 2025 15:35:44 +0200 Subject: [PATCH 3/3] use drafting module instead of custom todo --- lib/matisse-thesis.typ | 3 ++- lib/todos.typ | 26 +++++++++++++++++++++++++- template/main.typ | 2 ++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/matisse-thesis.typ b/lib/matisse-thesis.typ index 21c88d3..952455d 100644 --- a/lib/matisse-thesis.typ +++ b/lib/matisse-thesis.typ @@ -2,7 +2,7 @@ #import "cover.typ": cover #import "abstracts.typ": abstracts -#import "todos.typ": todos, show-todos +#import "todos.typ": todos, show-todos, show-notes #import "etablissements.typ": * #let matisse-thesis( @@ -45,6 +45,7 @@ todos() } else { show-todos.update(false) + show-notes.update(false) } // ---------- GENERAL ---------- diff --git a/lib/todos.typ b/lib/todos.typ index 6be7b6f..f5042bf 100644 --- a/lib/todos.typ +++ b/lib/todos.typ @@ -1,5 +1,28 @@ -#let todo-list = state("todo-list",()) +#import "@preview/drafting:0.2.2": inline-note, note-outline, margin-note + #let show-todos = state("show-todos", true) +#let show-notes = state("show-notes", true) + +#let todo(color: red, content) = context { + if show-todos.get() { + inline-note(par-break: false, stroke: (paint: color, dash: "dashed"))[#text(fill: color)[TODO]: #content] + } +} + +#let todos() = context { + if show-todos.get() or show-notes.get() { + note-outline() + } +} + +#let note(body, dy: auto, ..kwargs) = context { + if show-notes.get() { + margin-note(body, dy: dy, ..kwargs) + } +} + +/* +#let todo-list = state("todo-list",()) #let todo(color: red, content) = context { if show-todos.get() { @@ -43,3 +66,4 @@ } } } +*/ diff --git a/template/main.typ b/template/main.typ index b1a0561..8448c82 100644 --- a/template/main.typ +++ b/template/main.typ @@ -63,6 +63,8 @@ #todo[Write an introduction] +#note(stroke: aqua + 3pt)[Something to comment about][a note] + #lorem(200) #figure(