-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.qmd
More file actions
89 lines (64 loc) · 2.44 KB
/
Copy pathexample.qmd
File metadata and controls
89 lines (64 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
title: "typst-function Example"
format:
typst:
keep-typ: false
filters:
- typst-function
functions:
- align
- scale
- highlight
- stack
- link
- highlight-red
---
This filter allows you to use Typst functions using divs from Quarto.
To demonstrate it, let's first use raw Typst to show we can use that to set up functions and other rules.
```{=typst}
#show "Typst": set text(fill: gradient.linear(..color.map.rainbow))
```
You can do things just using raw Typst.
```{=typst}
#quote("This just gets passed to Typst directly.")
```
Then we can introduce a div `.align` which will call `#align()`. To pass it an argument, we use the arugments command.
::: {.align arguments="center"}
This text gets `center`ed from Typst without breaking things like code processing.
:::
:::: {.align arguments="right"}
We can stack the divs too.
::: {.scale arguments="x: -100%"}
So the inner gets aligned right *and* displays inverted.
:::
Named arguments are passed using `name: value` syntax.
::::
::: {.some-other-fn}
This gets placed in a block, since it is in a div. But, it isn't listed in the `functions` key in the metadata, so nothing else changes.
:::
This filter also *experimentally* supports adding a label to the output, such as below:
::: {.highlight label=block-highlight}
Look at how yellow this gets.
:::
We can then link to it `#link(<block-highlight>)[like so]`{=typst}.
This filter *experimentally* supports spreading arguments. This will place the block after the last argument and insert
::: {.stack arguments="dir: ltr, spacing:1fr, ..range(16).map(i=>rotate(24deg*i)" spread=true}
Hi
:::
Finally, this filter also supports spans. Unlike the `latex-environment`, both spans and divs map onto functions.
Currently, the *span* approach does not support arguments to `label` or `spread`.
Please use divs if you need those.
If you think that spans should support those arguments, please open an issue on GitHub.
These look like this:
[text]{.align arguments=right}
Why do we have this?
While we have `label`s as Typst labels, we can do links this way.
[The link text]{.link arguments=<block-highlight>}, again to the highlighted text.
These can also be defined within the document in `typst` blocks, if desirable.
They must be defined before they're used
For example:
```{=typst}
#let highlight-red(body) = highlight(fill: red, body)
```
[wow I'm angry]{.highlight-red}
This is particularly beneficial if you want to repeatedly redefine a function.