Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/task-config.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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.]
23 changes: 23 additions & 0 deletions src/task.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/examples/task-config/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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.]
Loading