Skip to content

Commit 3bf7406

Browse files
authored
outrageous:0.4.1 (#3296)
1 parent 3168049 commit 3bf7406

File tree

9 files changed

+1438
-0
lines changed

9 files changed

+1438
-0
lines changed

packages/preview/outrageous/0.4.1/LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# Outrageous
2+
3+
Easier customization of outline entries.
4+
5+
## Examples
6+
7+
For the full source see [`examples/basic.typ`](./examples/basic.typ) and for
8+
more examples see the [`examples` directory](./examples).
9+
10+
### Default Style
11+
12+
![Example: default style](./example-default.png)
13+
14+
```typ
15+
#import "@preview/outrageous:0.4.1"
16+
#show outline.entry: outrageous.show-entry
17+
```
18+
19+
### Custom Settings
20+
21+
![Example: custom settings](./example-custom.png)
22+
23+
```typ
24+
#import "@preview/outrageous:0.4.1"
25+
#show outline.entry: outrageous.show-entry.with(
26+
// the typst preset retains the normal Typst appearance
27+
..outrageous.presets.typst,
28+
// we only override a few things:
29+
// level-1 entries are italic, all others keep their font style
30+
font-style: ("italic", auto),
31+
// no fill for level-1 entries, a thin gray line for all deeper levels
32+
fill: (none, line(length: 100%, stroke: gray + .5pt)),
33+
)
34+
```
35+
36+
## Usage
37+
38+
### `show-entry`
39+
40+
Show the given outline entry with the provided styling. Should be used in a show
41+
rule like `#show outline.entry: outrageous.show-entry`.
42+
43+
```typ
44+
#let show-entry(
45+
entry,
46+
font-weight: presets.outrageous-toc.font-weight,
47+
font-style: presets.outrageous-toc.font-style,
48+
vspace: presets.outrageous-toc.vspace,
49+
font: presets.outrageous-toc.font,
50+
fill: presets.outrageous-toc.fill,
51+
gap: presets.outrageous-toc.gap,
52+
fill-right-pad: presets.outrageous-toc.fill-right-pad,
53+
fill-align: presets.outrageous-toc.fill-align,
54+
prefix-transform: presets.outrageous-toc.prefix-transform,
55+
body-transform: presets.outrageous-toc.body-transform,
56+
page-transform: presets.outrageous-toc.page-transform,
57+
state-key: "outline-page-number-max-width",
58+
) = { /* ... */ }
59+
```
60+
61+
**Arguments:**
62+
63+
For all the arguments that take arrays, the array's first item specifies the
64+
value for all level-one entries, the second item for level-two, and so on. The
65+
array's last item will be used for all deeper/following levels as well.
66+
67+
- `entry`: [`content`] — The
68+
[`outline.entry`](https://typst.app/docs/reference/model/outline/#definitions-entry)
69+
element from the show rule.
70+
- `font-weight`: [`array`] of ([`str`] or [`int`] or `auto` or `none`) —
71+
The entry's font weight. Setting to `auto` or `none` keeps the context's
72+
current style.
73+
- `font-style`: [`array`] of ([`str`] or `auto` or `none`) — The entry's
74+
font style. Setting to `auto` or `none` keeps the context's current style.
75+
- `vspace`: [`array`] of ([`relative`] or [`fraction`] or `auto` or `none`)
76+
— The vertical space above the entry. Setting to `auto` or `none` keeps
77+
the context's current setting.
78+
- `font`: [`array`] of ([`str`] or [`array`] or `auto` or `none`) — The
79+
entry's font. Setting to `auto` or `none` keeps the context's current font.
80+
- `fill`: [`array`] of ([`content`] or `auto` or `none`) — The entry's
81+
fill. Setting to `auto` keeps the context's current setting.
82+
- `gap`: [`array`] of ([`length`] or `auto` or `none`) — The gap between
83+
the entry's prefix and body. Setting to `auto` keeps the context's current
84+
setting. Setting to `none` is the same as `0pt`.
85+
- `fill-right-pad`: [`relative`] or `none` — Horizontal space to put
86+
between the fill and page number.
87+
- `fill-align`: [`bool`] — Whether `fill-right-pad` should be relative to
88+
the current page number or the widest page number. Setting this to `true` has
89+
the effect of all fills ending on the same vertical line.
90+
- `prefix-transform`: [`function`] or `none` — Callback for custom edits
91+
to the entry's prefix. It gets passed the entry's level ([`int`]) and prefix
92+
([`content`]) and should return [`content`] or `none`. If `none` is returned,
93+
no modifications are made.
94+
- `body-transform`: [`function`] or `none` — Callback for custom edits to
95+
the entry's body. It gets passed the entry's level ([`int`]), prefix
96+
([`content`]) and body ([`content`]) and should return [`content`] or `none`.
97+
If `none` is returned, no modifications are made.
98+
- `page-transform`: [`function`] or `none` — Callback for custom edits to
99+
the entry's page number. It gets passed the entry's level ([`int`]) and page
100+
number ([`content`]) and should return [`content`] or `none`. If `none` is
101+
returned, no modifications are made.
102+
- `state-key`: [`str`] — The key to use for the internal state which
103+
tracks the maximum page number width. The state is global for the entire
104+
document and thus applies to all outlines. If you wish to re-calculate the max
105+
page number width for `fill-align`, then you must provide a different key for
106+
each outline.
107+
108+
**Returns:** [`content`]
109+
110+
### `presets`
111+
112+
Presets for the arguments for [`show-entry()`](#show-entry). You can use them in
113+
your show rule with
114+
`#show outline.entry: outrageous.show-entry.with(..outrageous.presets.outrageous-figures)`.
115+
116+
```typ
117+
#let presets = (
118+
// outrageous preset for a Table of Contents
119+
outrageous-toc: (
120+
// ...
121+
),
122+
// outrageous preset for List of Figures/Tables/Listings
123+
outrageous-figures: (
124+
// ...
125+
),
126+
// preset without any style changes
127+
typst: (
128+
// ...
129+
),
130+
)
131+
```
132+
133+
### `repeat`
134+
135+
Utility function to repeat content to fill space with a fixed size gap.
136+
137+
```typ
138+
#let repeat(gap: none, justify: false, body) = { /* ... */ }
139+
```
140+
141+
**Arguments:**
142+
143+
- `gap`: [`length`] or `none` — The gap between repeated items.
144+
- `justify`: [`bool`] — Whether to increase the gap to justify the items.
145+
- `body`: [`content`] — The content to repeat.
146+
147+
**Returns:** [`content`]
148+
149+
### `align-helper`
150+
151+
Utility function to help with aligning multiple items.
152+
153+
```typ
154+
#let align-helper(state-key, what-to-measure, display) = { /* ... */ }
155+
```
156+
157+
**Arguments:**
158+
159+
- `state-key`: [`str`] — The key to use for the [`state`] that keeps track
160+
of the maximum encountered width.
161+
- `what-to-measure`: [`content`] — The content to measure at this call.
162+
- `display`: [`function`] — A callback which gets passed the maximum
163+
encountered width and the width of the current item (what was given to
164+
`what-to-measure`), both as [`length`], and should return [`content`] which
165+
can make use of these widths for alignment.
166+
167+
**Returns:** [`content`]
168+
169+
[`str`]: https://typst.app/docs/reference/foundations/str/
170+
[`int`]: https://typst.app/docs/reference/foundations/int/
171+
[`bool`]: https://typst.app/docs/reference/foundations/bool/
172+
[`content`]: https://typst.app/docs/reference/foundations/content/
173+
[`function`]: https://typst.app/docs/reference/foundations/function/
174+
[`array`]: https://typst.app/docs/reference/foundations/array/
175+
[`relative`]: https://typst.app/docs/reference/layout/relative/
176+
[`fraction`]: https://typst.app/docs/reference/layout/fraction/
177+
[`state`]: https://typst.app/docs/reference/introspection/state/
178+
[`length`]: https://typst.app/docs/reference/layout/length/
70 KB
Loading
83.3 KB
Loading
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#import "@preview/outrageous:0.4.1"
2+
3+
#set heading(numbering: "1.")
4+
#set outline(indent: auto)
5+
6+
#page(height: auto, width: 15cm, margin: 1cm)[
7+
#show outline.entry: outrageous.show-entry
8+
#outline()
9+
]
10+
11+
#page(height: auto, width: 15cm, margin: 1cm)[
12+
#show outline.entry: outrageous.show-entry.with(
13+
// the typst preset retains the normal Typst appearance
14+
..outrageous.presets.typst,
15+
// we only override a few things:
16+
// level-1 entries are italic, all others keep their font style
17+
font-style: ("italic", auto),
18+
// no fill for level-1 entries, a thin gray line for all deeper levels
19+
fill: (none, line(length: 100%, stroke: gray + .5pt)),
20+
)
21+
#outline()
22+
]
23+
24+
= Introduction
25+
#lorem(400)
26+
27+
#lorem(400)
28+
29+
== What is this About?
30+
#lorem(400)
31+
32+
#lorem(400)
33+
34+
== Why am I Here?
35+
#lorem(400)
36+
37+
#lorem(400)
38+
39+
= The Backstory
40+
#lorem(400)
41+
42+
#lorem(400)
43+
44+
== How it all Started
45+
#lorem(400)
46+
47+
#lorem(400)
48+
49+
=== Early Beginnings
50+
#lorem(400)
51+
52+
#lorem(400)
53+
54+
=== First Settlements
55+
#lorem(400)
56+
57+
#lorem(400)
58+
59+
= The Consequences
60+
#lorem(400)
61+
62+
#lorem(400)
63+
64+
= Happy Ending
65+
#lorem(400)
66+
67+
#lorem(400)
169 KB
Binary file not shown.

0 commit comments

Comments
 (0)