diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-05-03 16:59:13 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-05-04 00:14:31 +0200 |
| commit | 507c5fc92563560426db0d86c0348880b0493467 (patch) | |
| tree | 45116b62fb0fffe8e88d6c96ae1fcf11c73f8ee9 /tests/typ/style | |
| parent | e18a896a93cae987aa30addd40e678bf0064fd31 (diff) | |
Text replacement show rules
Diffstat (limited to 'tests/typ/style')
| -rw-r--r-- | tests/typ/style/show-node.typ | 4 | ||||
| -rw-r--r-- | tests/typ/style/show-recursive.typ | 2 | ||||
| -rw-r--r-- | tests/typ/style/show-text.typ | 58 |
3 files changed, 63 insertions, 1 deletions
diff --git a/tests/typ/style/show-node.typ b/tests/typ/style/show-node.typ index 4fcee9aa..07c30f19 100644 --- a/tests/typ/style/show-node.typ +++ b/tests/typ/style/show-node.typ @@ -63,5 +63,9 @@ Another text. #show _: upper as {} --- +// Error: 7-10 expected function, string or regular expression, found color +#show red as [] + +--- // Error: 2-16 set, show and wrap are only allowed directly in markup {show list as a} diff --git a/tests/typ/style/show-recursive.typ b/tests/typ/style/show-recursive.typ index 423bbd80..9e93739c 100644 --- a/tests/typ/style/show-recursive.typ +++ b/tests/typ/style/show-recursive.typ @@ -43,7 +43,7 @@ --- // Test multi-recursion with nested lists. -#set rect(padding: 2pt) +#set rect(inset: 2pt) #show v: list as rect(stroke: blue, v) #show v: list as rect(stroke: red, v) diff --git a/tests/typ/style/show-text.typ b/tests/typ/style/show-text.typ new file mode 100644 index 00000000..3bc116f5 --- /dev/null +++ b/tests/typ/style/show-text.typ @@ -0,0 +1,58 @@ +// Test text replacement show rules. + +--- +// Test classic example. +#set text("Roboto") +#show phrase: "Der Spiegel" as text(smallcaps: true, [#phrase]) +Die Zeitung Der Spiegel existiert. + +--- +// Another classic example. +#show "TeX" as [T#h(-0.145em)#move(dy: 0.233em)[E]#h(-0.135em)X] +#show name: regex("(Lua)?(La)?TeX") as box(text("Latin Modern Roman")[#name]) + +TeX, LaTeX, LuaTeX and LuaLaTeX! + +--- +// Test out-of-order guarding. +#show "Good" as [Typst!] +#show "Typst" as [Fun!] +#show "Fun" as [Good!] +#show enum as [] + +Good \ +Fun \ +Typst \ + +--- +// Test that replacements happen exactly once. +#show "A" as [BB] +#show "B" as [CC] +AA (8) + +--- +// Test caseless match and word boundaries. +#show regex("(?i)\bworld\b") as [🌍] + +Treeworld, the World of worlds, is a world. + +--- +// This is a fun one. +#set par(justify: true) +#show letter: regex("\S") as rect(inset: 2pt)[#upper(letter)] +#lorem(5) + +--- +// See also: https://github.com/mTvare6/hello-world.rs +#show it: regex("(?i)rust") as [#it (🚀)] +Rust is memory-safe and blazingly fast. Let's rewrite everything in rust. + +--- +// Replace worlds but only in lists. +#show node: list as [ + #show "World" as [🌎] + #node +] + +World +- World |
