diff --git a/CHANGELOG.md b/CHANGELOG.md index 16e597c..28207df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Added `definition` environment and `example` environment - Added task text handling - Added `begin-at-new-page` option for `task` and `subtask` +- Added `skip` option for `task` and `subtask` ## [0.4.0] - 2025-11-22 diff --git a/examples/task-config.typ b/examples/task-config.typ index 0280c9f..10816f8 100644 --- a/examples/task-config.typ +++ b/examples/task-config.typ @@ -37,4 +37,4 @@ #task(hidden: true, counter: 7)[This task is hidden in the score box.] -#task(counter: n => n + 1)[This would be task 8 but now it is task 9.] +#task(skip: 1)[This would be task 8 but now it is task 9.] diff --git a/src/task.typ b/src/task.typ index 335cfd8..ba36c3c 100644 --- a/src/task.typ +++ b/src/task.typ @@ -56,6 +56,12 @@ counter: auto, /// Whether to display the value of the task counter in the task's title. -> bool counter-show: true, + /// Step the task counter by the given number. + /// + /// This is applied after the general counter update (see `counter` parameter). + /// + /// -> none | int + skip: none, /// Whether to mark the task with a TODO box. -> bool todo: false, /// Whether to show a warning beside the title if there are any TODOs in the task. -> bool @@ -126,6 +132,9 @@ ) if counter != auto { c("sheetstorm-task").update(counter) } + if skip != none and type(skip) == int { + c("sheetstorm-task").update(n => n + skip) + } let (points-number, points-display) = _handle_points(points) @@ -228,6 +237,12 @@ /// /// -> auto | int | function counter: auto, + /// Step the subtask counter by the given number. + /// + /// This is applied after the general counter update (see `counter` parameter). + /// + /// -> none | int + skip: none, /// The numbering patterns to use for the subtask markers depending on depth. /// /// This is an array of strings where the n-th element is the numbering pattern for subtasks of depth n. @@ -304,6 +319,14 @@ }) } + if skip != none and type(skip) == int { + state("sheetstorm-subtask").update(xs => { + let x = xs.pop() + xs.push(x + skip) + xs + }) + } + let marker = if marker != auto { marker } else { context { let depth = state("sheetstorm-subtask").get().len() - 1 diff --git a/tests/examples/task-config/test.typ b/tests/examples/task-config/test.typ index 38222be..8b07012 100644 --- a/tests/examples/task-config/test.typ +++ b/tests/examples/task-config/test.typ @@ -37,4 +37,4 @@ #task(hidden: true, counter: 7)[This task is hidden in the score box.] -#task(counter: n => n + 1)[This would be task 8 but now it is task 9.] +#task(skip: 1)[This would be task 8 but now it is task 9.]