Skip to content

Commit

Permalink
Release v0.1.1 (#11)
Browse files Browse the repository at this point in the history
* Simplify common arg handling

* Fix #10
- Ensure grid.kind is propagated down to super

* Fix #9
- Ensure supplement inference does not fail if it is set

* Release v0.1.1
  • Loading branch information
tingerrr authored Jul 3, 2024
1 parent cac5e07 commit eddf4d4
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 13 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# [unreleased](https://github.com/tingerrr/subpar/tags/)
## Added

## Removed

## Changed

## Fixed

---

# [v0.1.1](https://github.com/tingerrr/subpar/tags/v0.1.1)
## Added
- Default implementations for figure show rules
- Manual examples about changing the figure appearances

## Removed

## Changed

## Fixed
- non-image kinds are correctly used in `subpar.grid`
- setting supplements manually no longer causes a panic

---

# [v0.1.0](https://github.com/tingerrr/subpar/releases/tag/v0.1.0)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Subpar is a [Typst] package for creating sub figures.

```typst
#import "@preview/subpar:0.1.0"
#import "@preview/subpar:0.1.1"
#set page(height: auto)
#set par(justify: true)
Expand Down
Binary file modified doc/manual.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion doc/manual.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@local/mantys:0.1.3" as mantys
#import "@local/mantys:0.1.4" as mantys
#import "@preview/hydra:0.4.0": hydra

#import "/src/lib.typ" as subpar
Expand Down
24 changes: 14 additions & 10 deletions src/lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@
) = {
_pkg.t4t.assert.any-type(str, function, kind)

_pkg.t4t.assert.any-type(str, function, numbering)
_pkg.t4t.assert.any-type(str, function, numbering-sub)
_pkg.t4t.assert.any-type(str, function, numbering-sub-ref)
let assert-numbering = _pkg.t4t.assert.any-type.with(str, function)
assert-numbering(numbering)
assert-numbering(numbering-sub)
assert-numbering(numbering-sub-ref)

// adjust numberings to receive either both or the sub number
numbering-sub = _util.sparse-numbering(numbering-sub)
Expand All @@ -92,8 +93,8 @@
)

// NOTE: if we use no propagation, then we can fallback to the normal auto behavior, fixing #4.
if propagate-supplement {
if supplement == auto and repr(kind) in function-kinds {
if propagate-supplement and supplement == auto {
if repr(kind) in function-kinds {
supplement = context _util.i18n-kind(function-kinds.at(repr(kind)))
} else {
panic("Cannot infer `supplement`, must be set.")
Expand Down Expand Up @@ -219,11 +220,13 @@
show-sub-caption: auto,
..args,
) = {
_pkg.t4t.assert.any-type(type(auto), int, length, relative, fraction, array, columns)
_pkg.t4t.assert.any-type(type(auto), int, length, relative, fraction, array, rows)
_pkg.t4t.assert.any-type(type(auto), int, length, relative, fraction, array, gutter)
_pkg.t4t.assert.any-type(type(auto), int, length, relative, fraction, array, column-gutter)
_pkg.t4t.assert.any-type(type(auto), int, length, relative, fraction, array, row-gutter)
let assert-arg = _pkg.t4t.assert.any-type.with(type(auto), int, length, relative, fraction, array)
assert-arg(columns)
assert-arg(rows)
assert-arg(gutter)
assert-arg(column-gutter)
assert-arg(row-gutter)

_pkg.t4t.assert.any-type(type(auto), array, alignment, function, align)
_pkg.t4t.assert.any-type(length, relative, array, dictionary, function, inset)

Expand Down Expand Up @@ -252,6 +255,7 @@
}

super(
kind: kind,
numbering: numbering,
numbering-sub: numbering-sub,
numbering-sub-ref: numbering-sub-ref,
Expand Down
1 change: 1 addition & 0 deletions test/kind/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# added by typst-test
Binary file added test/kind/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions test/kind/test.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Synopsis:
// - default kind is figure and is not inferred from content
// - the super supplement is propagated down by default
// - same kind correctly usese same counter

#import "/test/util.typ": *
#import "/src/lib.typ" as subpar

// figure by default regardless of inner content
#subpar.grid(
figure(```typst = Hello World```, caption: [Inner Caption]), <1a>,
figure(```typst = Hello World```, caption: [Inner Caption]), <1b>,
columns: (1fr, 1fr),
caption: [Super],
label: <1>,
)

// setting it propagates the inferred supplement down
#subpar.grid(
figure(```typst = Hello World```, caption: [Inner Caption]), <2a>,
figure(```typst = Hello World```, caption: [Inner Caption]), <2b>,
columns: (1fr, 1fr),
caption: [Super],
kind: raw,
label: <2>,
)

// turning off propagation causes different supplements for super and sub figures
#subpar.grid(
figure(table[A], caption: [Inner Caption]), <3a>,
figure(table[A], caption: [Inner Caption]), <3b>,
columns: (1fr, 1fr),
caption: [Super],
propagate-supplement: false,
label: <3>,
)

@1, @1a, @1b

@2, @2a, @2b

@3, @3a, @3b
1 change: 1 addition & 0 deletions test/supplement/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# added by typst-test
Binary file added test/supplement/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions test/supplement/test.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Synopsis:
// - default supplement is figure
// - supplement is inferred from kind
// - set supplement is used and propagated by default
// - propagation works as expected

#import "/test/util.typ": *
#import "/src/lib.typ" as subpar

// default supplement is figure
#subpar.grid(
figure(fake-image, caption: [Inner Caption]), <1a>,
figure(fake-image, caption: [Inner Caption]), <1b>,
columns: (1fr, 1fr),
caption: [Super],
label: <1>,
)

// supplement is inferred from kind
#subpar.grid(
figure(fake-image, caption: [Inner Caption]), <2a>,
figure(fake-image, caption: [Inner Caption]), <2b>,
columns: (1fr, 1fr),
caption: [Super],
kind: raw,
label: <2>,
)

// set supplement is used and propagated
#subpar.grid(
figure(fake-image, caption: [Inner Caption]), <3a>,
figure(fake-image, caption: [Inner Caption]), <3b>,
columns: (1fr, 1fr),
caption: [Super],
supplement: "Image",
label: <3>,
)

// set supplement is used and not propagated
#subpar.grid(
figure(fake-image, caption: [Inner Caption]), <4a>,
figure(fake-image, caption: [Inner Caption]), <4b>,
columns: (1fr, 1fr),
caption: [Super],
supplement: "Image",
propagate-supplement: false,
label: <4>,
)

@1, @1a, @1b

@2, @2a, @2b

@3, @3a, @3b

@4, @4a, @4b
2 changes: 1 addition & 1 deletion typst.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
entrypoint = "src/lib.typ"
name = "subpar"
version = "0.1.0"
version = "0.1.1"
compiler = "0.11.0"
authors = ["tinger <[email protected]>"]
repository = "https://github.com/tingerrr/subpar"
Expand Down

0 comments on commit eddf4d4

Please sign in to comment.