From 631bde16183e5c273149b97d60d494ab75e3fc8b Mon Sep 17 00:00:00 2001 From: 7ijme Date: Tue, 9 Sep 2025 20:28:21 +0000 Subject: [PATCH] tally:0.1.2 --- packages/preview/tally/0.1.2/.gitignore | 1 + packages/preview/tally/0.1.2/CHANGELOG.md | 8 ++++++ packages/preview/tally/0.1.2/LICENSE | 22 +++++++++++++++ packages/preview/tally/0.1.2/README.md | 22 +++++++++++++++ packages/preview/tally/0.1.2/src/lib.typ | 33 +++++++++++++++++++++++ packages/preview/tally/0.1.2/typst.toml | 18 +++++++++++++ 6 files changed, 104 insertions(+) create mode 100644 packages/preview/tally/0.1.2/.gitignore create mode 100644 packages/preview/tally/0.1.2/CHANGELOG.md create mode 100644 packages/preview/tally/0.1.2/LICENSE create mode 100644 packages/preview/tally/0.1.2/README.md create mode 100644 packages/preview/tally/0.1.2/src/lib.typ create mode 100644 packages/preview/tally/0.1.2/typst.toml diff --git a/packages/preview/tally/0.1.2/.gitignore b/packages/preview/tally/0.1.2/.gitignore new file mode 100644 index 0000000000..2c8c827adf --- /dev/null +++ b/packages/preview/tally/0.1.2/.gitignore @@ -0,0 +1 @@ +test.typ diff --git a/packages/preview/tally/0.1.2/CHANGELOG.md b/packages/preview/tally/0.1.2/CHANGELOG.md new file mode 100644 index 0000000000..7d5520f296 --- /dev/null +++ b/packages/preview/tally/0.1.2/CHANGELOG.md @@ -0,0 +1,8 @@ +# v0.1.2 +- Fix layout convergence error + +# v0.1.1 +- Made the `todo-list` a seperate variable instead of just putting it with the show rule + +# v0.1.0 +- Initial release diff --git a/packages/preview/tally/0.1.2/LICENSE b/packages/preview/tally/0.1.2/LICENSE new file mode 100644 index 0000000000..15bb172dc2 --- /dev/null +++ b/packages/preview/tally/0.1.2/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2025 Tijme + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/packages/preview/tally/0.1.2/README.md b/packages/preview/tally/0.1.2/README.md new file mode 100644 index 0000000000..3d007b0796 --- /dev/null +++ b/packages/preview/tally/0.1.2/README.md @@ -0,0 +1,22 @@ +# The `tally` Package + +The tally package automatically lists all todos in a document and highlights them. + +## Usage + +```typst +#import "@preview/tally:0.1.1": tally, todo-list +#set text(font: "Barlow") +#show: tally.with(color: red) + +#todo-list + += Introduction +#lorem(10) + +TODO: Create introduction +``` + +Output: + +![image](https://github.com/user-attachments/assets/bbe787ea-11c7-402f-9e54-b207499f5e00) diff --git a/packages/preview/tally/0.1.2/src/lib.typ b/packages/preview/tally/0.1.2/src/lib.typ new file mode 100644 index 0000000000..4b7e357f6a --- /dev/null +++ b/packages/preview/tally/0.1.2/src/lib.typ @@ -0,0 +1,33 @@ +#let tally(body, color: yellow) = { + let todo-list = state("todo-list", ()) + let reg = regex("TODO:(.+)") + show reg: it => context { + let todo = it.text.match(reg).captures.at(0).trim() + let here = here() + todo-list.update(lst => lst + ((todo, here),)) + highlight(fill: color)[TODO: #todo] + } + + body +} + +#let todo-list = context { + let todo-list = state("todo-list", ()) + if todo-list.final().len() > 0 { + heading(outlined: false, [Todo]) + } + list( + ..todo-list + .final() + .map(it => link( + it.last(), + [#{ + let headings = query(selector(heading).before(it.last())) + + if headings.len() > 1 { + [*#headings.last().body*:] + } + } #it.first()], + )), + ) +} diff --git a/packages/preview/tally/0.1.2/typst.toml b/packages/preview/tally/0.1.2/typst.toml new file mode 100644 index 0000000000..dfadfcb995 --- /dev/null +++ b/packages/preview/tally/0.1.2/typst.toml @@ -0,0 +1,18 @@ +[package] +name = "tally" +version = "0.1.2" +entrypoint = "src/lib.typ" +authors = ["Tijme"] +license = "MIT" +description = "Automatically handle todos in your document." +repository = "https://github.com/7ijme/tally" +keywords = ["todo", "list"] +categories = ["utility"] +exclude = [ + ".github", + "docs", + "scripts", + "tests", + ".typstignore", + "Justfile", +]