From 3ca5b238238e1128aa7bbfbd5db9e632045d8600 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 28 Feb 2022 15:50:48 +0100 Subject: Reorganize library --- tests/ref/elements/enum.png | Bin 0 -> 26118 bytes tests/ref/elements/heading.png | Bin 0 -> 25291 bytes tests/ref/elements/image.png | Bin 0 -> 183386 bytes tests/ref/elements/list.png | Bin 0 -> 21396 bytes tests/ref/elements/math.png | Bin 0 -> 3444 bytes tests/ref/elements/shape-aspect.png | Bin 0 -> 4663 bytes tests/ref/elements/shape-circle.png | Bin 0 -> 40653 bytes tests/ref/elements/shape-ellipse.png | Bin 0 -> 22046 bytes tests/ref/elements/shape-fill-stroke.png | Bin 0 -> 2893 bytes tests/ref/elements/shape-rect.png | Bin 0 -> 7261 bytes tests/ref/elements/shape-square.png | Bin 0 -> 18777 bytes tests/ref/elements/table.png | Bin 0 -> 1566 bytes tests/ref/layout/box-block.png | Bin 7628 -> 0 bytes tests/ref/layout/container.png | Bin 0 -> 7628 bytes tests/ref/layout/image.png | Bin 183386 -> 0 bytes tests/ref/layout/shape-aspect.png | Bin 4663 -> 0 bytes tests/ref/layout/shape-circle.png | Bin 40653 -> 0 bytes tests/ref/layout/shape-ellipse.png | Bin 22046 -> 0 bytes tests/ref/layout/shape-fill-stroke.png | Bin 2893 -> 0 bytes tests/ref/layout/shape-rect.png | Bin 7261 -> 0 bytes tests/ref/layout/shape-square.png | Bin 18777 -> 0 bytes tests/ref/layout/table.png | Bin 1566 -> 0 bytes tests/ref/markup/emph-strong.png | Bin 6988 -> 0 bytes tests/ref/markup/enums.png | Bin 26118 -> 0 bytes tests/ref/markup/escape.png | Bin 13675 -> 0 bytes tests/ref/markup/heading.png | Bin 25291 -> 0 bytes tests/ref/markup/linebreak.png | Bin 641 -> 0 bytes tests/ref/markup/lists.png | Bin 21396 -> 0 bytes tests/ref/markup/math.png | Bin 3444 -> 0 bytes tests/ref/markup/raw.png | Bin 22255 -> 0 bytes tests/ref/markup/shorthands.png | Bin 3838 -> 0 bytes tests/ref/text/deco.png | Bin 0 -> 29421 bytes tests/ref/text/decorations.png | Bin 29421 -> 0 bytes tests/ref/text/emph-strong.png | Bin 0 -> 6988 bytes tests/ref/text/escape.png | Bin 0 -> 13675 bytes tests/ref/text/linebreak.png | Bin 0 -> 14308 bytes tests/ref/text/linebreaks.png | Bin 14308 -> 0 bytes tests/ref/text/link.png | Bin 0 -> 35262 bytes tests/ref/text/links.png | Bin 35262 -> 0 bytes tests/ref/text/raw.png | Bin 0 -> 22255 bytes tests/ref/text/shorthands.png | Bin 0 -> 3838 bytes tests/typ/elements/enum.typ | 60 +++++++++++++++++++++++++++++++ tests/typ/elements/heading.typ | 50 ++++++++++++++++++++++++++ tests/typ/elements/image.typ | 59 ++++++++++++++++++++++++++++++ tests/typ/elements/list.typ | 51 ++++++++++++++++++++++++++ tests/typ/elements/math.typ | 12 +++++++ tests/typ/elements/shape-aspect.typ | 46 ++++++++++++++++++++++++ tests/typ/elements/shape-circle.typ | 51 ++++++++++++++++++++++++++ tests/typ/elements/shape-ellipse.typ | 23 ++++++++++++ tests/typ/elements/shape-fill-stroke.typ | 26 ++++++++++++++ tests/typ/elements/shape-rect.typ | 30 ++++++++++++++++ tests/typ/elements/shape-square.typ | 39 ++++++++++++++++++++ tests/typ/elements/table.typ | 13 +++++++ tests/typ/layout/box-block.typ | 22 ------------ tests/typ/layout/container.typ | 22 ++++++++++++ tests/typ/layout/image.typ | 59 ------------------------------ tests/typ/layout/shape-aspect.typ | 46 ------------------------ tests/typ/layout/shape-circle.typ | 51 -------------------------- tests/typ/layout/shape-ellipse.typ | 23 ------------ tests/typ/layout/shape-fill-stroke.typ | 26 -------------- tests/typ/layout/shape-rect.typ | 30 ---------------- tests/typ/layout/shape-square.typ | 39 -------------------- tests/typ/layout/table.typ | 13 ------- tests/typ/markup/emph-strong.typ | 33 ----------------- tests/typ/markup/enums.typ | 60 ------------------------------- tests/typ/markup/escape.typ | 38 -------------------- tests/typ/markup/heading.typ | 50 -------------------------- tests/typ/markup/linebreak.typ | 4 --- tests/typ/markup/lists.typ | 51 -------------------------- tests/typ/markup/math.typ | 12 ------- tests/typ/markup/raw.typ | 59 ------------------------------ tests/typ/markup/shorthands.typ | 8 ----- tests/typ/text/deco.typ | 31 ++++++++++++++++ tests/typ/text/decorations.typ | 31 ---------------- tests/typ/text/emph-strong.typ | 33 +++++++++++++++++ tests/typ/text/escape.typ | 38 ++++++++++++++++++++ tests/typ/text/linebreak.typ | 28 +++++++++++++++ tests/typ/text/linebreaks.typ | 28 --------------- tests/typ/text/link.typ | 35 ++++++++++++++++++ tests/typ/text/links.typ | 35 ------------------ tests/typ/text/raw.typ | 59 ++++++++++++++++++++++++++++++ tests/typ/text/shorthands.typ | 8 +++++ tests/typ/utility/collection.typ | 6 ---- tests/typ/utility/strings.typ | 12 ++++++- tests/typeset.rs | 3 +- 85 files changed, 727 insertions(+), 726 deletions(-) create mode 100644 tests/ref/elements/enum.png create mode 100644 tests/ref/elements/heading.png create mode 100644 tests/ref/elements/image.png create mode 100644 tests/ref/elements/list.png create mode 100644 tests/ref/elements/math.png create mode 100644 tests/ref/elements/shape-aspect.png create mode 100644 tests/ref/elements/shape-circle.png create mode 100644 tests/ref/elements/shape-ellipse.png create mode 100644 tests/ref/elements/shape-fill-stroke.png create mode 100644 tests/ref/elements/shape-rect.png create mode 100644 tests/ref/elements/shape-square.png create mode 100644 tests/ref/elements/table.png delete mode 100644 tests/ref/layout/box-block.png create mode 100644 tests/ref/layout/container.png delete mode 100644 tests/ref/layout/image.png delete mode 100644 tests/ref/layout/shape-aspect.png delete mode 100644 tests/ref/layout/shape-circle.png delete mode 100644 tests/ref/layout/shape-ellipse.png delete mode 100644 tests/ref/layout/shape-fill-stroke.png delete mode 100644 tests/ref/layout/shape-rect.png delete mode 100644 tests/ref/layout/shape-square.png delete mode 100644 tests/ref/layout/table.png delete mode 100644 tests/ref/markup/emph-strong.png delete mode 100644 tests/ref/markup/enums.png delete mode 100644 tests/ref/markup/escape.png delete mode 100644 tests/ref/markup/heading.png delete mode 100644 tests/ref/markup/linebreak.png delete mode 100644 tests/ref/markup/lists.png delete mode 100644 tests/ref/markup/math.png delete mode 100644 tests/ref/markup/raw.png delete mode 100644 tests/ref/markup/shorthands.png create mode 100644 tests/ref/text/deco.png delete mode 100644 tests/ref/text/decorations.png create mode 100644 tests/ref/text/emph-strong.png create mode 100644 tests/ref/text/escape.png create mode 100644 tests/ref/text/linebreak.png delete mode 100644 tests/ref/text/linebreaks.png create mode 100644 tests/ref/text/link.png delete mode 100644 tests/ref/text/links.png create mode 100644 tests/ref/text/raw.png create mode 100644 tests/ref/text/shorthands.png create mode 100644 tests/typ/elements/enum.typ create mode 100644 tests/typ/elements/heading.typ create mode 100644 tests/typ/elements/image.typ create mode 100644 tests/typ/elements/list.typ create mode 100644 tests/typ/elements/math.typ create mode 100644 tests/typ/elements/shape-aspect.typ create mode 100644 tests/typ/elements/shape-circle.typ create mode 100644 tests/typ/elements/shape-ellipse.typ create mode 100644 tests/typ/elements/shape-fill-stroke.typ create mode 100644 tests/typ/elements/shape-rect.typ create mode 100644 tests/typ/elements/shape-square.typ create mode 100644 tests/typ/elements/table.typ delete mode 100644 tests/typ/layout/box-block.typ create mode 100644 tests/typ/layout/container.typ delete mode 100644 tests/typ/layout/image.typ delete mode 100644 tests/typ/layout/shape-aspect.typ delete mode 100644 tests/typ/layout/shape-circle.typ delete mode 100644 tests/typ/layout/shape-ellipse.typ delete mode 100644 tests/typ/layout/shape-fill-stroke.typ delete mode 100644 tests/typ/layout/shape-rect.typ delete mode 100644 tests/typ/layout/shape-square.typ delete mode 100644 tests/typ/layout/table.typ delete mode 100644 tests/typ/markup/emph-strong.typ delete mode 100644 tests/typ/markup/enums.typ delete mode 100644 tests/typ/markup/escape.typ delete mode 100644 tests/typ/markup/heading.typ delete mode 100644 tests/typ/markup/linebreak.typ delete mode 100644 tests/typ/markup/lists.typ delete mode 100644 tests/typ/markup/math.typ delete mode 100644 tests/typ/markup/raw.typ delete mode 100644 tests/typ/markup/shorthands.typ create mode 100644 tests/typ/text/deco.typ delete mode 100644 tests/typ/text/decorations.typ create mode 100644 tests/typ/text/emph-strong.typ create mode 100644 tests/typ/text/escape.typ create mode 100644 tests/typ/text/linebreak.typ delete mode 100644 tests/typ/text/linebreaks.typ create mode 100644 tests/typ/text/link.typ delete mode 100644 tests/typ/text/links.typ create mode 100644 tests/typ/text/raw.typ create mode 100644 tests/typ/text/shorthands.typ (limited to 'tests') diff --git a/tests/ref/elements/enum.png b/tests/ref/elements/enum.png new file mode 100644 index 00000000..ecd1cf53 Binary files /dev/null and b/tests/ref/elements/enum.png differ diff --git a/tests/ref/elements/heading.png b/tests/ref/elements/heading.png new file mode 100644 index 00000000..09f3d7c7 Binary files /dev/null and b/tests/ref/elements/heading.png differ diff --git a/tests/ref/elements/image.png b/tests/ref/elements/image.png new file mode 100644 index 00000000..11a28980 Binary files /dev/null and b/tests/ref/elements/image.png differ diff --git a/tests/ref/elements/list.png b/tests/ref/elements/list.png new file mode 100644 index 00000000..503bfc9a Binary files /dev/null and b/tests/ref/elements/list.png differ diff --git a/tests/ref/elements/math.png b/tests/ref/elements/math.png new file mode 100644 index 00000000..77ec8d51 Binary files /dev/null and b/tests/ref/elements/math.png differ diff --git a/tests/ref/elements/shape-aspect.png b/tests/ref/elements/shape-aspect.png new file mode 100644 index 00000000..719c1e6e Binary files /dev/null and b/tests/ref/elements/shape-aspect.png differ diff --git a/tests/ref/elements/shape-circle.png b/tests/ref/elements/shape-circle.png new file mode 100644 index 00000000..040c6f0b Binary files /dev/null and b/tests/ref/elements/shape-circle.png differ diff --git a/tests/ref/elements/shape-ellipse.png b/tests/ref/elements/shape-ellipse.png new file mode 100644 index 00000000..740f005f Binary files /dev/null and b/tests/ref/elements/shape-ellipse.png differ diff --git a/tests/ref/elements/shape-fill-stroke.png b/tests/ref/elements/shape-fill-stroke.png new file mode 100644 index 00000000..12fcbd55 Binary files /dev/null and b/tests/ref/elements/shape-fill-stroke.png differ diff --git a/tests/ref/elements/shape-rect.png b/tests/ref/elements/shape-rect.png new file mode 100644 index 00000000..1fdb0dac Binary files /dev/null and b/tests/ref/elements/shape-rect.png differ diff --git a/tests/ref/elements/shape-square.png b/tests/ref/elements/shape-square.png new file mode 100644 index 00000000..00a0c848 Binary files /dev/null and b/tests/ref/elements/shape-square.png differ diff --git a/tests/ref/elements/table.png b/tests/ref/elements/table.png new file mode 100644 index 00000000..bc70d548 Binary files /dev/null and b/tests/ref/elements/table.png differ diff --git a/tests/ref/layout/box-block.png b/tests/ref/layout/box-block.png deleted file mode 100644 index 87484c25..00000000 Binary files a/tests/ref/layout/box-block.png and /dev/null differ diff --git a/tests/ref/layout/container.png b/tests/ref/layout/container.png new file mode 100644 index 00000000..87484c25 Binary files /dev/null and b/tests/ref/layout/container.png differ diff --git a/tests/ref/layout/image.png b/tests/ref/layout/image.png deleted file mode 100644 index 11a28980..00000000 Binary files a/tests/ref/layout/image.png and /dev/null differ diff --git a/tests/ref/layout/shape-aspect.png b/tests/ref/layout/shape-aspect.png deleted file mode 100644 index 719c1e6e..00000000 Binary files a/tests/ref/layout/shape-aspect.png and /dev/null differ diff --git a/tests/ref/layout/shape-circle.png b/tests/ref/layout/shape-circle.png deleted file mode 100644 index 040c6f0b..00000000 Binary files a/tests/ref/layout/shape-circle.png and /dev/null differ diff --git a/tests/ref/layout/shape-ellipse.png b/tests/ref/layout/shape-ellipse.png deleted file mode 100644 index 740f005f..00000000 Binary files a/tests/ref/layout/shape-ellipse.png and /dev/null differ diff --git a/tests/ref/layout/shape-fill-stroke.png b/tests/ref/layout/shape-fill-stroke.png deleted file mode 100644 index 12fcbd55..00000000 Binary files a/tests/ref/layout/shape-fill-stroke.png and /dev/null differ diff --git a/tests/ref/layout/shape-rect.png b/tests/ref/layout/shape-rect.png deleted file mode 100644 index 1fdb0dac..00000000 Binary files a/tests/ref/layout/shape-rect.png and /dev/null differ diff --git a/tests/ref/layout/shape-square.png b/tests/ref/layout/shape-square.png deleted file mode 100644 index 00a0c848..00000000 Binary files a/tests/ref/layout/shape-square.png and /dev/null differ diff --git a/tests/ref/layout/table.png b/tests/ref/layout/table.png deleted file mode 100644 index bc70d548..00000000 Binary files a/tests/ref/layout/table.png and /dev/null differ diff --git a/tests/ref/markup/emph-strong.png b/tests/ref/markup/emph-strong.png deleted file mode 100644 index cce98812..00000000 Binary files a/tests/ref/markup/emph-strong.png and /dev/null differ diff --git a/tests/ref/markup/enums.png b/tests/ref/markup/enums.png deleted file mode 100644 index ecd1cf53..00000000 Binary files a/tests/ref/markup/enums.png and /dev/null differ diff --git a/tests/ref/markup/escape.png b/tests/ref/markup/escape.png deleted file mode 100644 index 3434d6e0..00000000 Binary files a/tests/ref/markup/escape.png and /dev/null differ diff --git a/tests/ref/markup/heading.png b/tests/ref/markup/heading.png deleted file mode 100644 index 09f3d7c7..00000000 Binary files a/tests/ref/markup/heading.png and /dev/null differ diff --git a/tests/ref/markup/linebreak.png b/tests/ref/markup/linebreak.png deleted file mode 100644 index 2304ab96..00000000 Binary files a/tests/ref/markup/linebreak.png and /dev/null differ diff --git a/tests/ref/markup/lists.png b/tests/ref/markup/lists.png deleted file mode 100644 index 503bfc9a..00000000 Binary files a/tests/ref/markup/lists.png and /dev/null differ diff --git a/tests/ref/markup/math.png b/tests/ref/markup/math.png deleted file mode 100644 index 77ec8d51..00000000 Binary files a/tests/ref/markup/math.png and /dev/null differ diff --git a/tests/ref/markup/raw.png b/tests/ref/markup/raw.png deleted file mode 100644 index 64402dae..00000000 Binary files a/tests/ref/markup/raw.png and /dev/null differ diff --git a/tests/ref/markup/shorthands.png b/tests/ref/markup/shorthands.png deleted file mode 100644 index ad09967d..00000000 Binary files a/tests/ref/markup/shorthands.png and /dev/null differ diff --git a/tests/ref/text/deco.png b/tests/ref/text/deco.png new file mode 100644 index 00000000..684532a1 Binary files /dev/null and b/tests/ref/text/deco.png differ diff --git a/tests/ref/text/decorations.png b/tests/ref/text/decorations.png deleted file mode 100644 index 684532a1..00000000 Binary files a/tests/ref/text/decorations.png and /dev/null differ diff --git a/tests/ref/text/emph-strong.png b/tests/ref/text/emph-strong.png new file mode 100644 index 00000000..cce98812 Binary files /dev/null and b/tests/ref/text/emph-strong.png differ diff --git a/tests/ref/text/escape.png b/tests/ref/text/escape.png new file mode 100644 index 00000000..3434d6e0 Binary files /dev/null and b/tests/ref/text/escape.png differ diff --git a/tests/ref/text/linebreak.png b/tests/ref/text/linebreak.png new file mode 100644 index 00000000..1498a845 Binary files /dev/null and b/tests/ref/text/linebreak.png differ diff --git a/tests/ref/text/linebreaks.png b/tests/ref/text/linebreaks.png deleted file mode 100644 index 1498a845..00000000 Binary files a/tests/ref/text/linebreaks.png and /dev/null differ diff --git a/tests/ref/text/link.png b/tests/ref/text/link.png new file mode 100644 index 00000000..75ea19e8 Binary files /dev/null and b/tests/ref/text/link.png differ diff --git a/tests/ref/text/links.png b/tests/ref/text/links.png deleted file mode 100644 index 75ea19e8..00000000 Binary files a/tests/ref/text/links.png and /dev/null differ diff --git a/tests/ref/text/raw.png b/tests/ref/text/raw.png new file mode 100644 index 00000000..64402dae Binary files /dev/null and b/tests/ref/text/raw.png differ diff --git a/tests/ref/text/shorthands.png b/tests/ref/text/shorthands.png new file mode 100644 index 00000000..ad09967d Binary files /dev/null and b/tests/ref/text/shorthands.png differ diff --git a/tests/typ/elements/enum.typ b/tests/typ/elements/enum.typ new file mode 100644 index 00000000..8ba3cea6 --- /dev/null +++ b/tests/typ/elements/enum.typ @@ -0,0 +1,60 @@ +// Test enums. + +--- +. Embrace +. Extend +. Extinguish + +--- +1. First. + 2. Second. + +1. Back to first. + +--- +2. Second +1. First + . Indented + +--- +// Test automatic numbering in summed templates. +#for i in range(5) { + [. #roman(1 + i)] +} + +--- +// Test label pattern. +#set enum(label: "~ A:") +. First +. Second + +#set enum(label: "(*)") +. A +. B +. C + +#set enum(label: "i)") +. A +. B + +--- +// Test label closure. +#enum( + start: 4, + spacing: -3pt, + label: n => text(fill: (red, green, blue)(mod(n, 3)), [#upper(letter(n))]), + [Red], [Green], [Blue], +) + +--- +// Error: 18-20 invalid pattern +#set enum(label: "") + +--- +// Error: 18-24 invalid pattern +#set enum(label: "(())") + +--- +// Error: 18-28 expected template, found boolean +#set enum(label: n => false) +. A diff --git a/tests/typ/elements/heading.typ b/tests/typ/elements/heading.typ new file mode 100644 index 00000000..2ae97aa8 --- /dev/null +++ b/tests/typ/elements/heading.typ @@ -0,0 +1,50 @@ +// Test headings. + +--- +// Different number of hashtags. + +// Valid levels. += Level 1 +=== Level 2 +====== Level 6 + +// At some point, it should stop shrinking. +=========== Level 11 + +--- +// Heading vs. no heading. + +// Parsed as headings if at start of the context. +/**/ = Level 1 +{[== Level 2]} +#box[=== Level 3] + +// Not at the start of the context. +No = heading + +// Escaped. +\= No heading + +--- +// While indented at least as much as the start, the heading continues. + += This + is + indented. + += This +is not. + +// Code blocks continue heading. += A { + "B" +} + +--- +// Test styling. += Heading + +#set heading(family: "Roboto", fill: eastern) + +===== Heading 🌍 +#heading(level: 5)[Heading] diff --git a/tests/typ/elements/image.typ b/tests/typ/elements/image.typ new file mode 100644 index 00000000..8817713f --- /dev/null +++ b/tests/typ/elements/image.typ @@ -0,0 +1,59 @@ +// Test the `image` function. + +--- +// Test loading different image formats. + +// Load an RGBA PNG image. +#image("../../res/rhino.png") + +// Load an RGB JPEG image. +#set page(height: 60pt) +#image("../../res/tiger.jpg") + +--- +// Test configuring the size and fitting behaviour of images. + +// Set width and height explicitly. +#image("../../res/rhino.png", width: 30pt) +#image("../../res/rhino.png", height: 30pt) + +// Set width and height explicitly and force stretching. +#image("../../res/monkey.svg", width: 100%, height: 20pt, fit: "stretch") + +// Make sure the bounding-box of the image is correct. +#align(bottom + right, image("../../res/tiger.jpg", width: 40pt)) + +--- +// Test all three fit modes. +#set page(height: 50pt, margins: 0pt) +#grid( + columns: (1fr, 1fr, 1fr), + rows: 100%, + gutter: 3pt, + image("../../res/tiger.jpg", width: 100%, height: 100%, fit: "contain"), + image("../../res/tiger.jpg", width: 100%, height: 100%, fit: "cover"), + image("../../res/monkey.svg", width: 100%, height: 100%, fit: "stretch"), +) + +--- +// Does not fit to remaining height of page. +#set page(height: 60pt) +Stuff \ +Stuff +#image("../../res/rhino.png") + +--- +// Test baseline. +A #image("../../res/tiger.jpg", height: 1cm, width: 80%) B + +--- +// Test advanced SVG features. +#image("../../res/pattern.svg") + +--- +// Error: 8-29 file not found +#image("path/does/not/exist") + +--- +// Error: 8-21 failed to load image (unknown image format) +#image("./image.typ") diff --git a/tests/typ/elements/list.typ b/tests/typ/elements/list.typ new file mode 100644 index 00000000..38fc2c63 --- /dev/null +++ b/tests/typ/elements/list.typ @@ -0,0 +1,51 @@ +// Test lists. + +--- +_Shopping list_ +- Apples +- Potatoes +- Juice + +--- +Tightly +- surrounded +- by two +paragraphs. + +--- +- First level. + + - Second level. + + There are multiple paragraphs. + - Third level. + Still the same bullet point. + + - Still level 2. + +- At the top. + +--- +- Level 1 + - Level [ +2 through template +] + +--- + - Top-level indent +- is fine. + +--- + - A + - B + - C +- D + +--- +// This works because tabs are used consistently. + - A with 1 tab + - B with 2 tabs + +// This doesn't work because of mixed tabs and spaces. + - A with 2 spaces + - B with 2 tabs diff --git a/tests/typ/elements/math.typ b/tests/typ/elements/math.typ new file mode 100644 index 00000000..cad01d10 --- /dev/null +++ b/tests/typ/elements/math.typ @@ -0,0 +1,12 @@ +// Test math formulas. + +--- +The sum of $a$ and $b$ is $a + b$. + +--- +We will show that: +$[ a^2 + b^2 = c^2 ]$ + +--- +// Error: 2:1 expected closing bracket and dollar sign +$[a diff --git a/tests/typ/elements/shape-aspect.typ b/tests/typ/elements/shape-aspect.typ new file mode 100644 index 00000000..2c3e9b0c --- /dev/null +++ b/tests/typ/elements/shape-aspect.typ @@ -0,0 +1,46 @@ +// Test that squares and circles respect their 1-1 aspect ratio. + +--- +// Test relative width and height and size that is smaller +// than default size. +#set page(width: 120pt, height: 70pt) +#square(width: 50%, align(bottom)[A]) +#square(height: 50%) +#box(stack(square(size: 10pt), 5pt, square(size: 10pt, [B]))) + +--- +// Test alignment in automatically sized square and circle. +#set text(8pt) +#square(padding: 4pt)[ + Hey there, #align(center + bottom, rotate(180deg, [you!])) +] +#circle(align(center + horizon, [Hey.])) + +--- +// Test that maximum wins if both width and height are given. +#square(width: 10pt, height: 20pt) +#circle(width: 20%, height: 10pt) + +--- +// Test square that is limited by region size. +#set page(width: 20pt, height: 10pt, margins: 0pt) +#stack(dir: ltr, square(fill: forest), square(fill: conifer)) + +--- +// Test different ways of sizing. +#set page(width: 120pt, height: 40pt) +#circle(radius: 5pt) +#circle(width: 10%) +#circle(height: 50%) + +--- +// Test square that is overflowing due to its aspect ratio. +#set page(width: 40pt, height: 20pt, margins: 5pt) +#square(width: 100%) +#square(width: 100%)[Hello] + +--- +// Size cannot be relative because we wouldn't know +// relative to which axis. +// Error: 15-18 expected length, found relative +#square(size: 50%) diff --git a/tests/typ/elements/shape-circle.typ b/tests/typ/elements/shape-circle.typ new file mode 100644 index 00000000..4b978e86 --- /dev/null +++ b/tests/typ/elements/shape-circle.typ @@ -0,0 +1,51 @@ +// Test the `circle` function. + +--- +// Default circle. +#circle() +#circle[Hey] + +--- +// Test auto sizing. + +Auto-sized circle. \ +#circle(fill: rgb("eb5278"), stroke: black, thickness: 2pt, + align(center + horizon)[But, soft!] +) + +Center-aligned rect in auto-sized circle. +#circle(fill: forest, stroke: conifer, + align(center + horizon, + rect(fill: conifer, padding: 5pt)[But, soft!] + ) +) + +Rect in auto-sized circle. \ +#circle(fill: forest, + rect(fill: conifer, stroke: white, padding: 4pt)[ + #set text(8pt) + But, soft! what light through yonder window breaks? + ] +) + +Expanded by height. +#circle(stroke: black, align(center)[A \ B \ C]) + +--- +// Ensure circle directly in rect works. +#rect(width: 40pt, height: 30pt, fill: forest, circle(fill: conifer)) + +--- +// Test relative sizing. +#let centered(body) = align(center + horizon, body) +#set text(fill: white) +#rect(width: 100pt, height: 50pt, fill: rgb("aaa"), centered[ + #circle(radius: 10pt, fill: eastern, centered[A]) // D=20pt + #circle(height: 60%, fill: eastern, centered[B]) // D=30pt + #circle(width: 20% + 20pt, fill: eastern, centered[C]) // D=40pt +]) + +--- +// Radius wins over width and height. +// Error: 23-34 unexpected argument +#circle(radius: 10pt, width: 50pt, height: 100pt, fill: eastern) diff --git a/tests/typ/elements/shape-ellipse.typ b/tests/typ/elements/shape-ellipse.typ new file mode 100644 index 00000000..154144c4 --- /dev/null +++ b/tests/typ/elements/shape-ellipse.typ @@ -0,0 +1,23 @@ +// Test the `ellipse` function. + +--- +// Default ellipse. +#ellipse() + +--- +Rect in ellipse in fixed rect. \ +#rect(width: 3cm, height: 2cm, fill: rgb("2a631a"), + ellipse(fill: forest, width: 100%, height: 100%, + rect(fill: conifer, width: 100%, height: 100%, + align(center + horizon)[ + Stuff inside an ellipse! + ] + ) + ) +) + +Auto-sized ellipse. \ +#ellipse(fill: conifer, stroke: forest, thickness: 3pt, padding: 3pt)[ + #set text(8pt) + But, soft! what light through yonder window breaks? +] diff --git a/tests/typ/elements/shape-fill-stroke.typ b/tests/typ/elements/shape-fill-stroke.typ new file mode 100644 index 00000000..935f3bc7 --- /dev/null +++ b/tests/typ/elements/shape-fill-stroke.typ @@ -0,0 +1,26 @@ +// Test shape fill & stroke. + +--- +#let rect with (width: 20pt, height: 10pt) +#let items = for i, rect in ( + rect(stroke: none), + rect(), + rect(fill: none), + rect(thickness: 2pt), + rect(stroke: eastern), + rect(stroke: eastern, thickness: 2pt), + rect(fill: eastern), + rect(fill: eastern, stroke: none), + rect(fill: forest, stroke: none, thickness: 2pt), + rect(fill: forest, stroke: conifer), + rect(fill: forest, stroke: black, thickness: 2pt), + rect(fill: forest, stroke: conifer, thickness: 2pt), +) { + (align(horizon)[{i + 1}.], rect, []) +} + +#grid( + columns: (auto, auto, 1fr, auto, auto, 0fr), + gutter: 5pt, + ..items, +) diff --git a/tests/typ/elements/shape-rect.typ b/tests/typ/elements/shape-rect.typ new file mode 100644 index 00000000..add39b80 --- /dev/null +++ b/tests/typ/elements/shape-rect.typ @@ -0,0 +1,30 @@ +// Test the `rect` function. + +--- +// Default rectangle. +#rect() + +--- +#set page(width: 150pt) + +// Fit to text. +#rect(fill: conifer, padding: 3pt)[Textbox] + +// Empty with fixed width and height. +#block(rect( + height: 15pt, + fill: rgb("46b3c2"), + stroke: rgb("234994"), + thickness: 2pt, +)) + +// Fixed width, text height. +#rect(width: 2cm, fill: rgb("9650d6"), padding: 5pt)[Fixed and padded] + +// Page width, fixed height. +#rect(height: 1cm, width: 100%, fill: rgb("734ced"))[Topleft] + +// These are inline with text. +\{#rect(width: 0.5in, height: 7pt, fill: rgb("d6cd67")) + #rect(width: 0.5in, height: 7pt, fill: rgb("edd466")) + #rect(width: 0.5in, height: 7pt, fill: rgb("e3be62"))\} diff --git a/tests/typ/elements/shape-square.typ b/tests/typ/elements/shape-square.typ new file mode 100644 index 00000000..c4ece778 --- /dev/null +++ b/tests/typ/elements/shape-square.typ @@ -0,0 +1,39 @@ +// Test the `square` function. + +--- +// Default square. +#square() +#square[hey!] + +--- +// Test auto-sized square. +#square(fill: eastern, padding: 5pt)[ + #set text(fill: white, weight: "bold") + Typst +] + +--- +// Test relative-sized child. +#square(fill: eastern)[ + #rect(width: 10pt, height: 5pt, fill: conifer) \ + #rect(width: 40%, height: 5pt, stroke: conifer) +] + +--- +// Test text overflowing height. +#set page(width: 75pt, height: 100pt) +#square(fill: conifer)[ + But, soft! what light through yonder window breaks? +] + +--- +// Test that square does not overflow page. +#set page(width: 100pt, height: 75pt) +#square(fill: conifer)[ + But, soft! what light through yonder window breaks? +] + +--- +// Size wins over width and height. +// Error: 09-20 unexpected argument +#square(width: 10cm, height: 20cm, size: 1cm, fill: rgb("eb5278")) diff --git a/tests/typ/elements/table.typ b/tests/typ/elements/table.typ new file mode 100644 index 00000000..0372951c --- /dev/null +++ b/tests/typ/elements/table.typ @@ -0,0 +1,13 @@ +#set page(height: 70pt) +#set table(primary: rgb("aaa"), secondary: none) + +#table( + columns: (1fr,) * 3, + stroke: rgb("333"), + thickness: 2pt, + [A], [B], [C], [], [], [D \ E \ F \ \ \ G], [H], +) + +--- +// Ref: false +#table() diff --git a/tests/typ/layout/box-block.typ b/tests/typ/layout/box-block.typ deleted file mode 100644 index c6928074..00000000 --- a/tests/typ/layout/box-block.typ +++ /dev/null @@ -1,22 +0,0 @@ -// Test the `box` and `block` containers. - ---- -// Test box in paragraph. -A #box[B \ C] D. - -// Test box with height. -Spaced \ -#box(height: 0.5cm) \ -Apart - ---- -// Test block over multiple pages. - -#set page(height: 60pt) - -First! - -#block[ - But, soft! what light through yonder window breaks? It is the east, and Juliet - is the sun. -] diff --git a/tests/typ/layout/container.typ b/tests/typ/layout/container.typ new file mode 100644 index 00000000..c6928074 --- /dev/null +++ b/tests/typ/layout/container.typ @@ -0,0 +1,22 @@ +// Test the `box` and `block` containers. + +--- +// Test box in paragraph. +A #box[B \ C] D. + +// Test box with height. +Spaced \ +#box(height: 0.5cm) \ +Apart + +--- +// Test block over multiple pages. + +#set page(height: 60pt) + +First! + +#block[ + But, soft! what light through yonder window breaks? It is the east, and Juliet + is the sun. +] diff --git a/tests/typ/layout/image.typ b/tests/typ/layout/image.typ deleted file mode 100644 index 8817713f..00000000 --- a/tests/typ/layout/image.typ +++ /dev/null @@ -1,59 +0,0 @@ -// Test the `image` function. - ---- -// Test loading different image formats. - -// Load an RGBA PNG image. -#image("../../res/rhino.png") - -// Load an RGB JPEG image. -#set page(height: 60pt) -#image("../../res/tiger.jpg") - ---- -// Test configuring the size and fitting behaviour of images. - -// Set width and height explicitly. -#image("../../res/rhino.png", width: 30pt) -#image("../../res/rhino.png", height: 30pt) - -// Set width and height explicitly and force stretching. -#image("../../res/monkey.svg", width: 100%, height: 20pt, fit: "stretch") - -// Make sure the bounding-box of the image is correct. -#align(bottom + right, image("../../res/tiger.jpg", width: 40pt)) - ---- -// Test all three fit modes. -#set page(height: 50pt, margins: 0pt) -#grid( - columns: (1fr, 1fr, 1fr), - rows: 100%, - gutter: 3pt, - image("../../res/tiger.jpg", width: 100%, height: 100%, fit: "contain"), - image("../../res/tiger.jpg", width: 100%, height: 100%, fit: "cover"), - image("../../res/monkey.svg", width: 100%, height: 100%, fit: "stretch"), -) - ---- -// Does not fit to remaining height of page. -#set page(height: 60pt) -Stuff \ -Stuff -#image("../../res/rhino.png") - ---- -// Test baseline. -A #image("../../res/tiger.jpg", height: 1cm, width: 80%) B - ---- -// Test advanced SVG features. -#image("../../res/pattern.svg") - ---- -// Error: 8-29 file not found -#image("path/does/not/exist") - ---- -// Error: 8-21 failed to load image (unknown image format) -#image("./image.typ") diff --git a/tests/typ/layout/shape-aspect.typ b/tests/typ/layout/shape-aspect.typ deleted file mode 100644 index 2c3e9b0c..00000000 --- a/tests/typ/layout/shape-aspect.typ +++ /dev/null @@ -1,46 +0,0 @@ -// Test that squares and circles respect their 1-1 aspect ratio. - ---- -// Test relative width and height and size that is smaller -// than default size. -#set page(width: 120pt, height: 70pt) -#square(width: 50%, align(bottom)[A]) -#square(height: 50%) -#box(stack(square(size: 10pt), 5pt, square(size: 10pt, [B]))) - ---- -// Test alignment in automatically sized square and circle. -#set text(8pt) -#square(padding: 4pt)[ - Hey there, #align(center + bottom, rotate(180deg, [you!])) -] -#circle(align(center + horizon, [Hey.])) - ---- -// Test that maximum wins if both width and height are given. -#square(width: 10pt, height: 20pt) -#circle(width: 20%, height: 10pt) - ---- -// Test square that is limited by region size. -#set page(width: 20pt, height: 10pt, margins: 0pt) -#stack(dir: ltr, square(fill: forest), square(fill: conifer)) - ---- -// Test different ways of sizing. -#set page(width: 120pt, height: 40pt) -#circle(radius: 5pt) -#circle(width: 10%) -#circle(height: 50%) - ---- -// Test square that is overflowing due to its aspect ratio. -#set page(width: 40pt, height: 20pt, margins: 5pt) -#square(width: 100%) -#square(width: 100%)[Hello] - ---- -// Size cannot be relative because we wouldn't know -// relative to which axis. -// Error: 15-18 expected length, found relative -#square(size: 50%) diff --git a/tests/typ/layout/shape-circle.typ b/tests/typ/layout/shape-circle.typ deleted file mode 100644 index 4b978e86..00000000 --- a/tests/typ/layout/shape-circle.typ +++ /dev/null @@ -1,51 +0,0 @@ -// Test the `circle` function. - ---- -// Default circle. -#circle() -#circle[Hey] - ---- -// Test auto sizing. - -Auto-sized circle. \ -#circle(fill: rgb("eb5278"), stroke: black, thickness: 2pt, - align(center + horizon)[But, soft!] -) - -Center-aligned rect in auto-sized circle. -#circle(fill: forest, stroke: conifer, - align(center + horizon, - rect(fill: conifer, padding: 5pt)[But, soft!] - ) -) - -Rect in auto-sized circle. \ -#circle(fill: forest, - rect(fill: conifer, stroke: white, padding: 4pt)[ - #set text(8pt) - But, soft! what light through yonder window breaks? - ] -) - -Expanded by height. -#circle(stroke: black, align(center)[A \ B \ C]) - ---- -// Ensure circle directly in rect works. -#rect(width: 40pt, height: 30pt, fill: forest, circle(fill: conifer)) - ---- -// Test relative sizing. -#let centered(body) = align(center + horizon, body) -#set text(fill: white) -#rect(width: 100pt, height: 50pt, fill: rgb("aaa"), centered[ - #circle(radius: 10pt, fill: eastern, centered[A]) // D=20pt - #circle(height: 60%, fill: eastern, centered[B]) // D=30pt - #circle(width: 20% + 20pt, fill: eastern, centered[C]) // D=40pt -]) - ---- -// Radius wins over width and height. -// Error: 23-34 unexpected argument -#circle(radius: 10pt, width: 50pt, height: 100pt, fill: eastern) diff --git a/tests/typ/layout/shape-ellipse.typ b/tests/typ/layout/shape-ellipse.typ deleted file mode 100644 index 154144c4..00000000 --- a/tests/typ/layout/shape-ellipse.typ +++ /dev/null @@ -1,23 +0,0 @@ -// Test the `ellipse` function. - ---- -// Default ellipse. -#ellipse() - ---- -Rect in ellipse in fixed rect. \ -#rect(width: 3cm, height: 2cm, fill: rgb("2a631a"), - ellipse(fill: forest, width: 100%, height: 100%, - rect(fill: conifer, width: 100%, height: 100%, - align(center + horizon)[ - Stuff inside an ellipse! - ] - ) - ) -) - -Auto-sized ellipse. \ -#ellipse(fill: conifer, stroke: forest, thickness: 3pt, padding: 3pt)[ - #set text(8pt) - But, soft! what light through yonder window breaks? -] diff --git a/tests/typ/layout/shape-fill-stroke.typ b/tests/typ/layout/shape-fill-stroke.typ deleted file mode 100644 index 935f3bc7..00000000 --- a/tests/typ/layout/shape-fill-stroke.typ +++ /dev/null @@ -1,26 +0,0 @@ -// Test shape fill & stroke. - ---- -#let rect with (width: 20pt, height: 10pt) -#let items = for i, rect in ( - rect(stroke: none), - rect(), - rect(fill: none), - rect(thickness: 2pt), - rect(stroke: eastern), - rect(stroke: eastern, thickness: 2pt), - rect(fill: eastern), - rect(fill: eastern, stroke: none), - rect(fill: forest, stroke: none, thickness: 2pt), - rect(fill: forest, stroke: conifer), - rect(fill: forest, stroke: black, thickness: 2pt), - rect(fill: forest, stroke: conifer, thickness: 2pt), -) { - (align(horizon)[{i + 1}.], rect, []) -} - -#grid( - columns: (auto, auto, 1fr, auto, auto, 0fr), - gutter: 5pt, - ..items, -) diff --git a/tests/typ/layout/shape-rect.typ b/tests/typ/layout/shape-rect.typ deleted file mode 100644 index add39b80..00000000 --- a/tests/typ/layout/shape-rect.typ +++ /dev/null @@ -1,30 +0,0 @@ -// Test the `rect` function. - ---- -// Default rectangle. -#rect() - ---- -#set page(width: 150pt) - -// Fit to text. -#rect(fill: conifer, padding: 3pt)[Textbox] - -// Empty with fixed width and height. -#block(rect( - height: 15pt, - fill: rgb("46b3c2"), - stroke: rgb("234994"), - thickness: 2pt, -)) - -// Fixed width, text height. -#rect(width: 2cm, fill: rgb("9650d6"), padding: 5pt)[Fixed and padded] - -// Page width, fixed height. -#rect(height: 1cm, width: 100%, fill: rgb("734ced"))[Topleft] - -// These are inline with text. -\{#rect(width: 0.5in, height: 7pt, fill: rgb("d6cd67")) - #rect(width: 0.5in, height: 7pt, fill: rgb("edd466")) - #rect(width: 0.5in, height: 7pt, fill: rgb("e3be62"))\} diff --git a/tests/typ/layout/shape-square.typ b/tests/typ/layout/shape-square.typ deleted file mode 100644 index c4ece778..00000000 --- a/tests/typ/layout/shape-square.typ +++ /dev/null @@ -1,39 +0,0 @@ -// Test the `square` function. - ---- -// Default square. -#square() -#square[hey!] - ---- -// Test auto-sized square. -#square(fill: eastern, padding: 5pt)[ - #set text(fill: white, weight: "bold") - Typst -] - ---- -// Test relative-sized child. -#square(fill: eastern)[ - #rect(width: 10pt, height: 5pt, fill: conifer) \ - #rect(width: 40%, height: 5pt, stroke: conifer) -] - ---- -// Test text overflowing height. -#set page(width: 75pt, height: 100pt) -#square(fill: conifer)[ - But, soft! what light through yonder window breaks? -] - ---- -// Test that square does not overflow page. -#set page(width: 100pt, height: 75pt) -#square(fill: conifer)[ - But, soft! what light through yonder window breaks? -] - ---- -// Size wins over width and height. -// Error: 09-20 unexpected argument -#square(width: 10cm, height: 20cm, size: 1cm, fill: rgb("eb5278")) diff --git a/tests/typ/layout/table.typ b/tests/typ/layout/table.typ deleted file mode 100644 index 0372951c..00000000 --- a/tests/typ/layout/table.typ +++ /dev/null @@ -1,13 +0,0 @@ -#set page(height: 70pt) -#set table(primary: rgb("aaa"), secondary: none) - -#table( - columns: (1fr,) * 3, - stroke: rgb("333"), - thickness: 2pt, - [A], [B], [C], [], [], [D \ E \ F \ \ \ G], [H], -) - ---- -// Ref: false -#table() diff --git a/tests/typ/markup/emph-strong.typ b/tests/typ/markup/emph-strong.typ deleted file mode 100644 index 9bdb5059..00000000 --- a/tests/typ/markup/emph-strong.typ +++ /dev/null @@ -1,33 +0,0 @@ -// Test emph and strong. - ---- -// Basic. -_Emphasized and *strong* words!_ - -// Inside of a word it's a normal underscore or star. -hello_world Nutzer*innen - -// Can contain paragraph in child template. -_Still [ - -] emphasized._ - ---- -// Inside of words can still use the functions. -P#strong[art]ly em#emph[phas]ized. - ---- -// Error: 13 expected underscore -#box[_Scoped] to body. - ---- -// Ends at paragraph break. -// Error: 7 expected underscore -_Hello - -World - ---- -// Error: 1:12 expected star -// Error: 2:1 expected star -_Cannot *be_ interleaved* diff --git a/tests/typ/markup/enums.typ b/tests/typ/markup/enums.typ deleted file mode 100644 index 8ba3cea6..00000000 --- a/tests/typ/markup/enums.typ +++ /dev/null @@ -1,60 +0,0 @@ -// Test enums. - ---- -. Embrace -. Extend -. Extinguish - ---- -1. First. - 2. Second. - -1. Back to first. - ---- -2. Second -1. First - . Indented - ---- -// Test automatic numbering in summed templates. -#for i in range(5) { - [. #roman(1 + i)] -} - ---- -// Test label pattern. -#set enum(label: "~ A:") -. First -. Second - -#set enum(label: "(*)") -. A -. B -. C - -#set enum(label: "i)") -. A -. B - ---- -// Test label closure. -#enum( - start: 4, - spacing: -3pt, - label: n => text(fill: (red, green, blue)(mod(n, 3)), [#upper(letter(n))]), - [Red], [Green], [Blue], -) - ---- -// Error: 18-20 invalid pattern -#set enum(label: "") - ---- -// Error: 18-24 invalid pattern -#set enum(label: "(())") - ---- -// Error: 18-28 expected template, found boolean -#set enum(label: n => false) -. A diff --git a/tests/typ/markup/escape.typ b/tests/typ/markup/escape.typ deleted file mode 100644 index 6ec469c1..00000000 --- a/tests/typ/markup/escape.typ +++ /dev/null @@ -1,38 +0,0 @@ -// Test escape sequences. - ---- -// Escapable symbols. -\\ \/ \[ \] \{ \} \# \* \_ \= \~ \` \$ - -// No need to escape. -( ) ; < > - -// Unescapable. -\a \: \; \( \) - -// Escaped comments. -\// -\/\* \*\/ -\/* \*/ * - -// Unicode escape sequence. -\u{1F3D5} == 🏕 - -// Escaped escape sequence. -\u{41} vs. \\u\{41\} - -// Some code stuff in text. -let f() , ; : | + - /= == 12 "string" - -// Escaped dot. -10\. May - ---- -// Unicode codepoint does not exist. -// Error: 1-11 invalid unicode escape sequence -\u{FFFFFF} - ---- -// Unterminated. -// Error: 6 expected closing brace -\u{41[*Bold*] diff --git a/tests/typ/markup/heading.typ b/tests/typ/markup/heading.typ deleted file mode 100644 index 2ae97aa8..00000000 --- a/tests/typ/markup/heading.typ +++ /dev/null @@ -1,50 +0,0 @@ -// Test headings. - ---- -// Different number of hashtags. - -// Valid levels. -= Level 1 -=== Level 2 -====== Level 6 - -// At some point, it should stop shrinking. -=========== Level 11 - ---- -// Heading vs. no heading. - -// Parsed as headings if at start of the context. -/**/ = Level 1 -{[== Level 2]} -#box[=== Level 3] - -// Not at the start of the context. -No = heading - -// Escaped. -\= No heading - ---- -// While indented at least as much as the start, the heading continues. - -= This - is - indented. - -= This -is not. - -// Code blocks continue heading. -= A { - "B" -} - ---- -// Test styling. -= Heading - -#set heading(family: "Roboto", fill: eastern) - -===== Heading 🌍 -#heading(level: 5)[Heading] diff --git a/tests/typ/markup/linebreak.typ b/tests/typ/markup/linebreak.typ deleted file mode 100644 index 7fe8a718..00000000 --- a/tests/typ/markup/linebreak.typ +++ /dev/null @@ -1,4 +0,0 @@ -// Test line breaks. - ---- -A \ B \ C diff --git a/tests/typ/markup/lists.typ b/tests/typ/markup/lists.typ deleted file mode 100644 index 38fc2c63..00000000 --- a/tests/typ/markup/lists.typ +++ /dev/null @@ -1,51 +0,0 @@ -// Test lists. - ---- -_Shopping list_ -- Apples -- Potatoes -- Juice - ---- -Tightly -- surrounded -- by two -paragraphs. - ---- -- First level. - - - Second level. - - There are multiple paragraphs. - - Third level. - Still the same bullet point. - - - Still level 2. - -- At the top. - ---- -- Level 1 - - Level [ -2 through template -] - ---- - - Top-level indent -- is fine. - ---- - - A - - B - - C -- D - ---- -// This works because tabs are used consistently. - - A with 1 tab - - B with 2 tabs - -// This doesn't work because of mixed tabs and spaces. - - A with 2 spaces - - B with 2 tabs diff --git a/tests/typ/markup/math.typ b/tests/typ/markup/math.typ deleted file mode 100644 index cad01d10..00000000 --- a/tests/typ/markup/math.typ +++ /dev/null @@ -1,12 +0,0 @@ -// Test math formulas. - ---- -The sum of $a$ and $b$ is $a + b$. - ---- -We will show that: -$[ a^2 + b^2 = c^2 ]$ - ---- -// Error: 2:1 expected closing bracket and dollar sign -$[a diff --git a/tests/typ/markup/raw.typ b/tests/typ/markup/raw.typ deleted file mode 100644 index 0e053a9b..00000000 --- a/tests/typ/markup/raw.typ +++ /dev/null @@ -1,59 +0,0 @@ -// Test raw blocks. - ---- -// No extra space. -`A``B` - ---- -// Typst syntax inside. -`#let x = 1` \ -`#f(1)` - ---- -// Multiline block splits paragraphs. - -First -``` -Second -``` -Third - ---- -// Lots of backticks inside. -```` -```backticks``` -```` - ---- -// Trimming. - -// Space between "rust" and "let" is trimmed. -The keyword ```rust let```. - -// Trimming depends on number backticks. -<``> \ -<` untrimmed `> \ -<``` trimmed` ```> \ -<``` trimmed ```> \ -<``` trimmed```> - -// Multiline trimming and dedenting. -#block[ - ```py - import this - - def hi(): - print("Hi!") - ``` -] - ---- -// First line is not dedented and leading space is still possible. - ``` A - B - C``` - ---- -// Unterminated. -// Error: 2:1 expected 1 backtick -`endless diff --git a/tests/typ/markup/shorthands.typ b/tests/typ/markup/shorthands.typ deleted file mode 100644 index ef0bf866..00000000 --- a/tests/typ/markup/shorthands.typ +++ /dev/null @@ -1,8 +0,0 @@ -// Test shorthands for unicode codepoints. - ---- -The non-breaking~space does work. - ---- -- En dash: -- -- Em dash: --- diff --git a/tests/typ/text/deco.typ b/tests/typ/text/deco.typ new file mode 100644 index 00000000..e0693ca3 --- /dev/null +++ b/tests/typ/text/deco.typ @@ -0,0 +1,31 @@ +// Test text decorations. + +--- +#let red = rgb("fc0030") + +// Basic strikethrough. +#strike[Statements dreamt up by the utterly deranged.] + +// Move underline down. +#underline(offset: 5pt)[Further below.] + +// Different color. +#underline(red, evade: false)[Critical information is conveyed here.] + +// Inherits font color. +#text(fill: red, underline[Change with the wind.]) + +// Both over- and underline. +#overline(underline[Running amongst the wolves.]) + +--- +#let redact = strike with (10pt, extent: 5%) +#let highlight = strike with ( + stroke: rgb("abcdef88"), + thickness: 10pt, + extent: 5%, +) + +// Abuse thickness and transparency for redacting and highlighting stuff. +Sometimes, we work #redact[in secret]. +There might be #highlight[redacted] things. diff --git a/tests/typ/text/decorations.typ b/tests/typ/text/decorations.typ deleted file mode 100644 index e0693ca3..00000000 --- a/tests/typ/text/decorations.typ +++ /dev/null @@ -1,31 +0,0 @@ -// Test text decorations. - ---- -#let red = rgb("fc0030") - -// Basic strikethrough. -#strike[Statements dreamt up by the utterly deranged.] - -// Move underline down. -#underline(offset: 5pt)[Further below.] - -// Different color. -#underline(red, evade: false)[Critical information is conveyed here.] - -// Inherits font color. -#text(fill: red, underline[Change with the wind.]) - -// Both over- and underline. -#overline(underline[Running amongst the wolves.]) - ---- -#let redact = strike with (10pt, extent: 5%) -#let highlight = strike with ( - stroke: rgb("abcdef88"), - thickness: 10pt, - extent: 5%, -) - -// Abuse thickness and transparency for redacting and highlighting stuff. -Sometimes, we work #redact[in secret]. -There might be #highlight[redacted] things. diff --git a/tests/typ/text/emph-strong.typ b/tests/typ/text/emph-strong.typ new file mode 100644 index 00000000..9bdb5059 --- /dev/null +++ b/tests/typ/text/emph-strong.typ @@ -0,0 +1,33 @@ +// Test emph and strong. + +--- +// Basic. +_Emphasized and *strong* words!_ + +// Inside of a word it's a normal underscore or star. +hello_world Nutzer*innen + +// Can contain paragraph in child template. +_Still [ + +] emphasized._ + +--- +// Inside of words can still use the functions. +P#strong[art]ly em#emph[phas]ized. + +--- +// Error: 13 expected underscore +#box[_Scoped] to body. + +--- +// Ends at paragraph break. +// Error: 7 expected underscore +_Hello + +World + +--- +// Error: 1:12 expected star +// Error: 2:1 expected star +_Cannot *be_ interleaved* diff --git a/tests/typ/text/escape.typ b/tests/typ/text/escape.typ new file mode 100644 index 00000000..6ec469c1 --- /dev/null +++ b/tests/typ/text/escape.typ @@ -0,0 +1,38 @@ +// Test escape sequences. + +--- +// Escapable symbols. +\\ \/ \[ \] \{ \} \# \* \_ \= \~ \` \$ + +// No need to escape. +( ) ; < > + +// Unescapable. +\a \: \; \( \) + +// Escaped comments. +\// +\/\* \*\/ +\/* \*/ * + +// Unicode escape sequence. +\u{1F3D5} == 🏕 + +// Escaped escape sequence. +\u{41} vs. \\u\{41\} + +// Some code stuff in text. +let f() , ; : | + - /= == 12 "string" + +// Escaped dot. +10\. May + +--- +// Unicode codepoint does not exist. +// Error: 1-11 invalid unicode escape sequence +\u{FFFFFF} + +--- +// Unterminated. +// Error: 6 expected closing brace +\u{41[*Bold*] diff --git a/tests/typ/text/linebreak.typ b/tests/typ/text/linebreak.typ new file mode 100644 index 00000000..ff8559d6 --- /dev/null +++ b/tests/typ/text/linebreak.typ @@ -0,0 +1,28 @@ +// Test line breaks. + +--- +// Test overlong word that is not directly after a hard break. +This is a spaceexceedinglylongy. + +--- +// Test two overlong words in a row. +Supercalifragilisticexpialidocious Expialigoricmetrioxidation. + +--- +// Test that there are no unwanted line break opportunities on run change. +This is partly emp#emph[has]ized. + +--- +Hard \ break. + +--- +// Test hard break directly after normal break. +Hard break directly after \ normal break. + +--- +// Test consecutive breaks. +Two consecutive \ \ breaks and three \ \ \ more. + +--- +// Test forcing an empty trailing line. +Trailing break \ \ diff --git a/tests/typ/text/linebreaks.typ b/tests/typ/text/linebreaks.typ deleted file mode 100644 index 25a8c5ab..00000000 --- a/tests/typ/text/linebreaks.typ +++ /dev/null @@ -1,28 +0,0 @@ -// Test line breaking special cases. - ---- -// Test overlong word that is not directly after a hard break. -This is a spaceexceedinglylongy. - ---- -// Test two overlong words in a row. -Supercalifragilisticexpialidocious Expialigoricmetrioxidation. - ---- -// Test that there are no unwanted line break opportunities on run change. -This is partly emp#emph[has]ized. - ---- -Hard \ break. - ---- -// Test hard break directly after normal break. -Hard break directly after \ normal break. - ---- -// Test consecutive breaks. -Two consecutive \ \ breaks and three \ \ \ more. - ---- -// Test forcing an empty trailing line. -Trailing break \ \ diff --git a/tests/typ/text/link.typ b/tests/typ/text/link.typ new file mode 100644 index 00000000..99037ee3 --- /dev/null +++ b/tests/typ/text/link.typ @@ -0,0 +1,35 @@ +// Test hyperlinking. + +--- +// Link without body. +#link("https://example.com/") + +// Link with body. +#link("https://typst.app/")[Some text text text] + +// With line break. +This link appears #link("https://google.com/")[in the middle of] a paragraph. + +// Prefix is trimmed. +Contact #link("mailto:hi@typst.app") or +call #link("tel:123") for more information. + +--- +// Styled with underline and color. +#set link(fill: rgb("283663")) +You could also make the +#link("https://html5zombo.com/")[link look way more typical.] + +--- +// Transformed link. +#set page(height: 60pt) +#set link(underline: false) +#let mylink = link("https://typst.app/")[LINK] +My cool #move(x: 0.7cm, y: 0.7cm, rotate(10deg, scale(200%, mylink))) + +--- +// Link containing a block. +#link("https://example.com/", underline: false, block[ + My cool rhino + #move(x: 10pt, image("../../res/rhino.png", width: 1cm)) +]) diff --git a/tests/typ/text/links.typ b/tests/typ/text/links.typ deleted file mode 100644 index 99037ee3..00000000 --- a/tests/typ/text/links.typ +++ /dev/null @@ -1,35 +0,0 @@ -// Test hyperlinking. - ---- -// Link without body. -#link("https://example.com/") - -// Link with body. -#link("https://typst.app/")[Some text text text] - -// With line break. -This link appears #link("https://google.com/")[in the middle of] a paragraph. - -// Prefix is trimmed. -Contact #link("mailto:hi@typst.app") or -call #link("tel:123") for more information. - ---- -// Styled with underline and color. -#set link(fill: rgb("283663")) -You could also make the -#link("https://html5zombo.com/")[link look way more typical.] - ---- -// Transformed link. -#set page(height: 60pt) -#set link(underline: false) -#let mylink = link("https://typst.app/")[LINK] -My cool #move(x: 0.7cm, y: 0.7cm, rotate(10deg, scale(200%, mylink))) - ---- -// Link containing a block. -#link("https://example.com/", underline: false, block[ - My cool rhino - #move(x: 10pt, image("../../res/rhino.png", width: 1cm)) -]) diff --git a/tests/typ/text/raw.typ b/tests/typ/text/raw.typ new file mode 100644 index 00000000..0e053a9b --- /dev/null +++ b/tests/typ/text/raw.typ @@ -0,0 +1,59 @@ +// Test raw blocks. + +--- +// No extra space. +`A``B` + +--- +// Typst syntax inside. +`#let x = 1` \ +`#f(1)` + +--- +// Multiline block splits paragraphs. + +First +``` +Second +``` +Third + +--- +// Lots of backticks inside. +```` +```backticks``` +```` + +--- +// Trimming. + +// Space between "rust" and "let" is trimmed. +The keyword ```rust let```. + +// Trimming depends on number backticks. +<``> \ +<` untrimmed `> \ +<``` trimmed` ```> \ +<``` trimmed ```> \ +<``` trimmed```> + +// Multiline trimming and dedenting. +#block[ + ```py + import this + + def hi(): + print("Hi!") + ``` +] + +--- +// First line is not dedented and leading space is still possible. + ``` A + B + C``` + +--- +// Unterminated. +// Error: 2:1 expected 1 backtick +`endless diff --git a/tests/typ/text/shorthands.typ b/tests/typ/text/shorthands.typ new file mode 100644 index 00000000..ef0bf866 --- /dev/null +++ b/tests/typ/text/shorthands.typ @@ -0,0 +1,8 @@ +// Test shorthands for unicode codepoints. + +--- +The non-breaking~space does work. + +--- +- En dash: -- +- Em dash: --- diff --git a/tests/typ/utility/collection.typ b/tests/typ/utility/collection.typ index 92ec2867..a4bc817e 100644 --- a/tests/typ/utility/collection.typ +++ b/tests/typ/utility/collection.typ @@ -1,12 +1,6 @@ // Test collection functions. // Ref: false ---- -#let memes = "ArE mEmEs gReAt?"; -#test(lower(memes), "are memes great?") -#test(upper(memes), "ARE MEMES GREAT?") -#test(upper("Ελλάδα"), "ΕΛΛΆΔΑ") - --- // Test the `len` function. #test(len(()), 0) diff --git a/tests/typ/utility/strings.typ b/tests/typ/utility/strings.typ index 91be0faa..4222266b 100644 --- a/tests/typ/utility/strings.typ +++ b/tests/typ/utility/strings.typ @@ -1,7 +1,17 @@ -// Test string functions. +// Test string handling functions. +// Ref: false --- // Test the `upper`, `lower`, and number formatting functions. +#let memes = "ArE mEmEs gReAt?"; +#test(lower(memes), "are memes great?") +#test(upper(memes), "ARE MEMES GREAT?") +#test(upper("Ελλάδα"), "ΕΛΛΆΔΑ") + +--- +// Test numbering formatting functions. +// Ref: true + #upper("Abc 8") #upper[def] diff --git a/tests/typeset.rs b/tests/typeset.rs index 1b45a975..388d4516 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -12,7 +12,8 @@ use typst::diag::Error; use typst::eval::{Smart, StyleMap, Value}; use typst::frame::{Element, Frame}; use typst::geom::{Length, RgbaColor}; -use typst::library::{PageNode, TextNode}; +use typst::library::layout::PageNode; +use typst::library::text::TextNode; use typst::loading::FsLoader; use typst::parse::Scanner; use typst::source::SourceFile; -- cgit v1.2.3