diff --git a/src/eval/dict.rs b/src/eval/dict.rs index bda433e15..6b4dbbd77 100644 --- a/src/eval/dict.rs +++ b/src/eval/dict.rs @@ -117,7 +117,7 @@ impl Dict { /// The missing key access error message. #[cold] fn missing_key(key: &EcoString) -> String { - format!("dictionary does not contain key: {:?}", key) + format!("dictionary does not contain key {:?}", key) } impl Debug for Dict { diff --git a/tests/ref/style/set-site.png b/tests/ref/style/set.png similarity index 100% rename from tests/ref/style/set-site.png rename to tests/ref/style/set.png diff --git a/tests/ref/style/show-node.png b/tests/ref/style/show-node.png new file mode 100644 index 000000000..3a48e3dbc Binary files /dev/null and b/tests/ref/style/show-node.png differ diff --git a/tests/ref/style/show-recursive.png b/tests/ref/style/show-recursive.png new file mode 100644 index 000000000..2c9239b8c Binary files /dev/null and b/tests/ref/style/show-recursive.png differ diff --git a/tests/ref/style/show.png b/tests/ref/style/show.png deleted file mode 100644 index 9539e4965..000000000 Binary files a/tests/ref/style/show.png and /dev/null differ diff --git a/tests/typ/code/dict.typ b/tests/typ/code/dict.typ index aa840eb35..23af145f3 100644 --- a/tests/typ/code/dict.typ +++ b/tests/typ/code/dict.typ @@ -23,7 +23,7 @@ // Test rvalue missing key. { let dict = (a: 1, b: 2) - // Error: 11-20 dictionary does not contain key: "c" + // Error: 11-20 dictionary does not contain key "c" let x = dict("c") } diff --git a/tests/typ/code/field.typ b/tests/typ/code/field.typ index ff1dad9ec..abccaedee 100644 --- a/tests/typ/code/field.typ +++ b/tests/typ/code/field.typ @@ -12,7 +12,7 @@ } --- -// Error: 6-13 dictionary does not contain key: "invalid" +// Error: 6-13 dictionary does not contain key "invalid" {(:).invalid} --- diff --git a/tests/typ/style/construct.typ b/tests/typ/style/construct.typ index 890c4b94f..4b0f966a4 100644 --- a/tests/typ/style/construct.typ +++ b/tests/typ/style/construct.typ @@ -1,4 +1,4 @@ -// Test class construction. +// Test node functions. --- // Ensure that constructor styles aren't passed down the tree. diff --git a/tests/typ/style/set-site.typ b/tests/typ/style/set-site.typ deleted file mode 100644 index b49d1027d..000000000 --- a/tests/typ/style/set-site.typ +++ /dev/null @@ -1,28 +0,0 @@ -// Test that set affects the instantiation site and not the -// definition site of a content. - ---- -// Test that text is affected by instantiation-site bold. -#let x = [World] -Hello *{x}* - ---- -// Test that lists are affected by correct indents. -#let fruit = [ - - Apple - - Orange - #list(body-indent: 20pt, [Pear]) -] - -- Fruit -[#set list(indent: 10pt) - #fruit] -- No more fruit - ---- -// Test that that par spacing and text style are respected from -// the outside, but the more specific fill is respected. -#set par(spacing: 4pt) -#set text(style: "italic", fill: eastern) -#let x = [And the forest #parbreak() lay silent!] -#text(fill: forest, x) diff --git a/tests/typ/style/set.typ b/tests/typ/style/set.typ index 927d8aa6e..249666126 100644 --- a/tests/typ/style/set.typ +++ b/tests/typ/style/set.typ @@ -1,5 +1,30 @@ // General tests for set. -// Ref: false + +--- +// Test that text is affected by instantiation-site bold. +#let x = [World] +Hello *{x}* + +--- +// Test that lists are affected by correct indents. +#let fruit = [ + - Apple + - Orange + #list(body-indent: 20pt, [Pear]) +] + +- Fruit +[#set list(indent: 10pt) + #fruit] +- No more fruit + +--- +// Test that that par spacing and text style are respected from +// the outside, but the more specific fill is respected. +#set par(spacing: 4pt) +#set text(style: "italic", fill: eastern) +#let x = [And the forest #parbreak() lay silent!] +#text(fill: forest, x) --- // Error: 2-10 set, show and wrap are only allowed directly in markup diff --git a/tests/typ/style/show-node.typ b/tests/typ/style/show-node.typ new file mode 100644 index 000000000..4fcee9aa4 --- /dev/null +++ b/tests/typ/style/show-node.typ @@ -0,0 +1,67 @@ +// Test node show rules. + +--- +// Override lists. +#set list(around: none) +#show v: list as "(" + v.items.join(", ") + ")" + +- A + - B + - C +- D +- E + +--- +// Test full reset. +#set heading(size: 1em, strong: false, around: none) +#show heading as [B] +A [= Heading] C + +--- +// Test full removal. +#show heading as [] +#set heading(around: none) + +Where is += There are not headings around here! +my heading? + +--- +// Test integrated example. +#set heading(size: 1em) +#show node: heading as { + move(dy: -1pt)[📖] + h(5pt) + if node.level == 1 { + underline(text(1.25em, blue, node.body)) + } else { + text(red, node.body) + } +} + += Task 1 +Some text. + +== Subtask +Some more text. + += Task 2 +Another text. + +--- +// Error: 18-22 expected content, found string +#show heading as "hi" += Heading + +--- +// Error: 25-29 unknown field "page" +#show it: heading as it.page += Heading + +--- +// Error: 10-15 this function cannot be customized with show +#show _: upper 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 new file mode 100644 index 000000000..423bbd80b --- /dev/null +++ b/tests/typ/style/show-recursive.typ @@ -0,0 +1,65 @@ +// Test recursive show rules. + +--- +// Test basic identity. +#show it: heading as it += Heading + +--- +// Test more recipes down the chain. +#show it: list as scale(origin: left, x: 80%, it) +#show heading as [] +#show enum as [] +- Actual +- Tight +- List + +--- +// Test recursive base recipe. (Burn it with fire!) +#set list(label: [- Hey]) +- Labelless +- List + +--- +// Test show rule in function. +#let starwars(body) = [ + #show v: list as { + stack(dir: ltr, + text(red, v), + 1fr, + scale(x: -100%, text(blue, v)), + ) + } + #body +] + +- Normal list +#starwars[ + - Star + - Wars + - List +] +- Normal list + +--- +// Test multi-recursion with nested lists. +#set rect(padding: 2pt) +#show v: list as rect(stroke: blue, v) +#show v: list as rect(stroke: red, v) + +- List + - Nested + - List +- Recursive! + +--- +// Inner heading is not finalized. Bug? +#set heading(around: none) +#show it: heading as it.body +#show heading as [ + = A [ + = B + ] +] + += Discarded diff --git a/tests/typ/style/show.typ b/tests/typ/style/show.typ deleted file mode 100644 index a71b8df20..000000000 --- a/tests/typ/style/show.typ +++ /dev/null @@ -1,52 +0,0 @@ -// Test show rules. - -#set page("a8", footer: p => v(-5pt) + align(right, [#p])) - -#let i = 1 -#set heading(size: 1em) -#show node: heading as { - if node.level == 1 { - v(10pt) - underline(text(1.5em, blue)[{i}. {node.body}]) - i += 1 - } else { - text(red, node.body) - } -} - -#v(-10pt) - -= Aufgabe -Some text. - -== Subtask -Some more text. - -== Another subtask -Some more text. - -= Aufgabe -Another text. - ---- -#set heading(size: 1em, strong: false, around: none) -#show _: heading as [B] -A [= Heading] C - ---- -// Error: 21-25 expected content, found string -#show _: heading as "hi" -= Heading - ---- -// Error: 22-29 dictionary does not contain key: "page" -#show it: heading as it.page -= Heading - ---- -// Error: 10-15 this function cannot be customized with show -#show _: upper as {} - ---- -// Error: 2-19 set, show and wrap are only allowed directly in markup -{show a: list as a}