diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-04-13 10:39:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-13 08:39:45 +0000 |
| commit | 020294fca9a7065d4b9cf4e677f606ebaaa29b00 (patch) | |
| tree | c0027ad22046e2726c22298461327823d6b88d53 /tests/typ/layout | |
| parent | 72dd79210602ecc799726fc096b078afbb47f299 (diff) | |
Better test runner (#3922)
Diffstat (limited to 'tests/typ/layout')
76 files changed, 0 insertions, 5044 deletions
diff --git a/tests/typ/layout/align.typ b/tests/typ/layout/align.typ deleted file mode 100644 index 98ee8da5..00000000 --- a/tests/typ/layout/align.typ +++ /dev/null @@ -1,52 +0,0 @@ -// Test alignment. - ---- -#set page(height: 100pt) -#stack(dir: ltr, - align(left, square(size: 15pt, fill: eastern)), - align(center, square(size: 20pt, fill: eastern)), - align(right, square(size: 15pt, fill: eastern)), -) -#align(center + horizon, rect(fill: eastern, height: 10pt)) -#align(bottom, stack( - align(center, rect(fill: conifer, height: 10pt)), - rect(fill: forest, height: 10pt, width: 100%), -)) - ---- -// Test that multiple paragraphs in subflow also respect alignment. -#align(center)[ - Lorem Ipsum - - Dolor -] - ---- -// Test start and end alignment. -#rotate(-30deg, origin: end + horizon)[Hello] - -#set text(lang: "de") -#align(start)[Start] -#align(end)[Ende] - -#set text(lang: "ar") -#align(start)[يبدأ] -#align(end)[نهاية] - ---- -// Ref: false -#test(type(center), alignment) -#test(type(horizon), alignment) -#test(type(center + horizon), alignment) - ---- -// Error: 8-22 cannot add two horizontal alignments -#align(center + right, [A]) - ---- -// Error: 8-20 cannot add two vertical alignments -#align(top + bottom, [A]) - ---- -// Error: 8-30 cannot add a vertical and a 2D alignment -#align(top + (bottom + right), [A]) diff --git a/tests/typ/layout/block-sizing.typ b/tests/typ/layout/block-sizing.typ deleted file mode 100644 index 181bbe31..00000000 --- a/tests/typ/layout/block-sizing.typ +++ /dev/null @@ -1,24 +0,0 @@ -// Test blocks with fixed height. - ---- -#set page(height: 100pt) -#set align(center) - -#lorem(10) -#block(width: 80%, height: 60pt, fill: aqua) -#lorem(6) -#block( - breakable: false, - width: 100%, - inset: 4pt, - fill: aqua, - lorem(8) + colbreak(), -) - ---- -// Layout inside a block with certain dimensions should provide those dimensions. - -#set page(height: 120pt) -#block(width: 60pt, height: 80pt, layout(size => [ - This block has a width of #size.width and height of #size.height -])) diff --git a/tests/typ/layout/block-spacing.typ b/tests/typ/layout/block-spacing.typ deleted file mode 100644 index 2c636676..00000000 --- a/tests/typ/layout/block-spacing.typ +++ /dev/null @@ -1,9 +0,0 @@ -// Test block spacing. - ---- -#set block(spacing: 10pt) -Hello - -There - -#block(spacing: 20pt)[Further down] diff --git a/tests/typ/layout/cjk-latin-spacing.typ b/tests/typ/layout/cjk-latin-spacing.typ deleted file mode 100644 index c6fff5d7..00000000 --- a/tests/typ/layout/cjk-latin-spacing.typ +++ /dev/null @@ -1,29 +0,0 @@ -// Test CJK-Latin spacing. - -#set page(width: 50pt + 10pt, margin: (x: 5pt)) -#set text(lang: "zh", font: "Noto Serif CJK SC", cjk-latin-spacing: auto) -#set par(justify: true) - -中文,中12文1中,文12中文 - -中文,中ab文a中,文ab中文 - -#set text(cjk-latin-spacing: none) - -中文,中12文1中,文12中文 - -中文,中ab文a中,文ab中文 - ---- -// Issue #2538 -#set text(cjk-latin-spacing: auto) - -abc字 - -abc字#linebreak() - -abc字#linebreak() -母 - -abc字\ -母 diff --git a/tests/typ/layout/cjk-punctuation-adjustment.typ b/tests/typ/layout/cjk-punctuation-adjustment.typ deleted file mode 100644 index 88ee9560..00000000 --- a/tests/typ/layout/cjk-punctuation-adjustment.typ +++ /dev/null @@ -1,44 +0,0 @@ -#set page(width: 15em) - -// In the following example, the space between 》! and ? should be squeezed. -// because zh-CN follows GB style -#set text(lang: "zh", region: "CN", font: "Noto Serif CJK SC") -原来,你也玩《原神》!? - -// However, in the following example, the space between 》! and ? should not be squeezed. -// because zh-TW does not follow GB style -#set text(lang: "zh", region: "TW", font: "Noto Serif CJK TC") -原來,你也玩《原神》! ? - -#set text(lang: "zh", region: "CN", font: "Noto Serif CJK SC") -「真的吗?」 - -#set text(lang: "ja", font: "Noto Serif CJK JP") -「本当に?」 ---- - -#set text(lang: "zh", region: "CN", font: "Noto Serif CJK SC") -《书名〈章节〉》 // the space between 〉 and 》 should be squeezed - -〔茸毛〕:很细的毛 // the space between 〕 and : should be squeezed - ---- -#set page(width: 21em) -#set text(lang: "zh", region: "CN", font: "Noto Serif CJK SC") - -// These examples contain extensive use of Chinese punctuation marks, -// from 《Which parentheses should be used when applying parentheses?》. -// link: https://archive.md/2bb1N - - -(〔中〕医、〔中〕药、技)系列评审 - -(长三角[长江三角洲])(GB/T 16159—2012《汉语拼音正词法基本规则》) - -【爱因斯坦(Albert Einstein)】物理学家 - -〔(2009)民申字第1622号〕 - -“江南海北长相忆,浅水深山独掩扉。”([唐]刘长卿《会赦后酬主簿所问》) - -参看1378页〖象形文字〗。(《现代汉语词典》修订本) diff --git a/tests/typ/layout/clip.typ b/tests/typ/layout/clip.typ deleted file mode 100644 index 3ca74556..00000000 --- a/tests/typ/layout/clip.typ +++ /dev/null @@ -1,68 +0,0 @@ -// Test clipping with the `box` and `block` containers. - ---- -// Test box clipping with a rectangle -Hello #box(width: 1em, height: 1em, clip: false)[#rect(width: 3em, height: 3em, fill: red)] -world 1 - -Space - -Hello #box(width: 1em, height: 1em, clip: true)[#rect(width: 3em, height: 3em, fill: red)] -world 2 - ---- -// Test cliping text -#block(width: 5em, height: 2em, clip: false, stroke: 1pt + black)[ - But, soft! what light through -] - -#v(2em) - -#block(width: 5em, height: 2em, clip: true, stroke: 1pt + black)[ - But, soft! what light through yonder window breaks? It is the east, and Juliet - is the sun. -] - ---- -// Test clipping svg glyphs -Emoji: #box(height: 0.5em, stroke: 1pt + black)[🐪, 🌋, 🏞] - -Emoji: #box(height: 0.5em, clip: true, stroke: 1pt + black)[🐪, 🌋, 🏞] - ---- -// Test block clipping over multiple pages. - -#set page(height: 60pt) - -First! - -#block(height: 4em, clip: true, stroke: 1pt + black)[ - But, soft! what light through yonder window breaks? It is the east, and Juliet - is the sun. -] - ---- -// Test clipping with `radius`. - -#set page(height: 60pt) - -#box( - radius: 5pt, - stroke: 2pt + black, - width: 20pt, - height: 20pt, - clip: true, - image("/assets/images/rhino.png", width: 30pt) -) ---- -// Test clipping with `radius`, but without `stroke`. - -#set page(height: 60pt) - -#box( - radius: 5pt, - width: 20pt, - height: 20pt, - clip: true, - image("/assets/images/rhino.png", width: 30pt) -) diff --git a/tests/typ/layout/code-indent-shrink.typ b/tests/typ/layout/code-indent-shrink.typ deleted file mode 100644 index 1527e061..00000000 --- a/tests/typ/layout/code-indent-shrink.typ +++ /dev/null @@ -1,28 +0,0 @@ -// Spaces in raw blocks should not be shrunk -// as it would mess up the indentation of code -// https://github.com/typst/typst/issues/3191 - ---- -#set par(justify: true) - -#show raw.where(block: true): block.with( - fill: luma(240), - inset: 10pt, -) - -#block( - width: 60%, - ```py - for x in xs: - print("x=",x) - ``` -) - ---- -// In normal paragraphs, spaces should still be shrunk. -// The first line here serves as a reference, while the second -// uses non-breaking spaces to create an overflowing line -// (which should shrink). -~~~~No shrinking here - -~~~~The~spaces~on~this~line~shrink
\ No newline at end of file diff --git a/tests/typ/layout/columns.typ b/tests/typ/layout/columns.typ deleted file mode 100644 index ecf636e7..00000000 --- a/tests/typ/layout/columns.typ +++ /dev/null @@ -1,112 +0,0 @@ -// Test the column layouter. - ---- -// Test normal operation and RTL directions. -#set page(height: 3.25cm, width: 7.05cm, columns: 2) -#set text(lang: "ar", font: ("Noto Sans Arabic", "Linux Libertine")) -#set columns(gutter: 30pt) - -#box(fill: conifer, height: 8pt, width: 6pt) وتحفيز -العديد من التفاعلات الكيميائية. (DNA) من أهم الأحماض النووية التي تُشكِّل -إلى جانب كل من البروتينات والليبيدات والسكريات المتعددة -#box(fill: eastern, height: 8pt, width: 6pt) -الجزيئات الضخمة الأربعة الضرورية للحياة. - ---- -// Test the `columns` function. -#set page(width: auto) - -#rect(width: 180pt, height: 100pt, inset: 8pt, columns(2, [ - A special plight has befallen our document. - Columns in text boxes reigned down unto the soil - to waste a year's crop of rich layouts. - The columns at least were graciously balanced. -])) - ---- -// Test columns for a sized page. -#set page(height: 5cm, width: 7.05cm, columns: 2) - -Lorem ipsum dolor sit amet is a common blind text -and I again am in need of filling up this page -#align(bottom, rect(fill: eastern, width: 100%, height: 12pt)) -#colbreak() - -so I'm returning to this trusty tool of tangible terror. -Sure, it is not the most creative way of filling up -a page for a test but it does get the job done. - ---- -// Test the expansion behaviour. -#set page(height: 2.5cm, width: 7.05cm) - -#rect(inset: 6pt, columns(2, [ - ABC \ - BCD - #colbreak() - DEF -])) - ---- -// Test setting a column gutter and more than two columns. -#set page(height: 3.25cm, width: 7.05cm, columns: 3) -#set columns(gutter: 30pt) - -#rect(width: 100%, height: 2.5cm, fill: conifer) #parbreak() -#rect(width: 100%, height: 2cm, fill: eastern) #parbreak() -#circle(fill: eastern) - ---- -// Test the `colbreak` and `pagebreak` functions. -#set page(height: 1cm, width: 7.05cm, columns: 2) - -A -#colbreak() -#colbreak() -B -#pagebreak() -C -#colbreak() -D - ---- -// Test an empty second column. -#set page(width: 7.05cm, columns: 2) - -#rect(width: 100%, inset: 3pt)[So there isn't anything in the second column?] - ---- -// Test columns when one of them is empty. -#set page(width: auto, columns: 3) - -Arbitrary horizontal growth. - ---- -// Test columns in an infinitely high frame. -#set page(width: 7.05cm, columns: 2) - -There can be as much content as you want in the left column -and the document will grow with it. - -#rect(fill: conifer, width: 100%, height: 30pt) - -Only an explicit #colbreak() `#colbreak()` can put content in the -second column. - ---- -// Test a page with a single column. -#set page(height: auto, width: 7.05cm, columns: 1) - -This is a normal page. Very normal. - ---- -// Test a page with zero columns. -// Error: 49-50 number must be positive -#set page(height: auto, width: 7.05cm, columns: 0) - ---- -// Test colbreak after only out-of-flow elements. -#set page(width: 7.05cm, columns: 2) -#place[OOF] -#colbreak() -In flow. diff --git a/tests/typ/layout/container-fill.typ b/tests/typ/layout/container-fill.typ deleted file mode 100644 index f5947e06..00000000 --- a/tests/typ/layout/container-fill.typ +++ /dev/null @@ -1,7 +0,0 @@ -#set page(height: 100pt) -#let words = lorem(18).split() -#block(inset: 8pt, width: 100%, fill: aqua, stroke: aqua.darken(30%))[ - #words.slice(0, 13).join(" ") - #box(fill: teal, outset: 2pt)[tempor] - #words.slice(13).join(" ") -] diff --git a/tests/typ/layout/container.typ b/tests/typ/layout/container.typ deleted file mode 100644 index 8d4ec34b..00000000 --- a/tests/typ/layout/container.typ +++ /dev/null @@ -1,50 +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 sizing. -#set page(height: 120pt) -#set block(spacing: 0pt) -#block(width: 90pt, height: 80pt, fill: red)[ - #block(width: 60%, height: 60%, fill: green) - #block(width: 50%, height: 60%, fill: blue) -] - ---- -// Test box sizing with layoutable child. -#box( - width: 50pt, - height: 50pt, - fill: yellow, - path( - fill: purple, - (0pt, 0pt), - (30pt, 30pt), - (0pt, 30pt), - (30pt, 0pt), - ), -) - ---- -// Test fr box. -Hello #box(width: 1fr, rect(height: 0.7em, width: 100%)) World - ---- -// 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/enum-align.typ b/tests/typ/layout/enum-align.typ deleted file mode 100644 index d64ee374..00000000 --- a/tests/typ/layout/enum-align.typ +++ /dev/null @@ -1,51 +0,0 @@ -// Test the alignment of enum numbers. - ---- -// Alignment shouldn't affect number -#set align(horizon) - -+ ABCDEF\ GHIJKL\ MNOPQR - + INNER\ INNER\ INNER -+ BACK\ HERE - ---- -// Enum number alignment should be 'end' by default -1. a -10. b -100. c - -#set enum(number-align: start) -1. a -8. b -16. c - ---- -#set enum(number-align: center + horizon) -1. #box(fill: teal, inset: 10pt )[a] -8. #box(fill: teal, inset: 10pt )[b] -16. #box(fill: teal,inset: 10pt )[c] - ---- -// Number align option should not be affected by the context. -#set align(center) -#set enum(number-align: start) - -4. c -8. d -16. e\ f - 2. f\ g - 32. g - 64. h - ---- -// Test valid number align values (horizontal and vertical) -// Ref: false -#set enum(number-align: start) -#set enum(number-align: end) -#set enum(number-align: left) -#set enum(number-align: center) -#set enum(number-align: right) -#set enum(number-align: top) -#set enum(number-align: horizon) -#set enum(number-align: bottom) - diff --git a/tests/typ/layout/enum-numbering.typ b/tests/typ/layout/enum-numbering.typ deleted file mode 100644 index 7efe195f..00000000 --- a/tests/typ/layout/enum-numbering.typ +++ /dev/null @@ -1,55 +0,0 @@ -// Test enum numbering styles. - ---- -// Test numbering pattern. -#set enum(numbering: "(1.a.*)") -+ First -+ Second - 2. Nested - + Deep -+ Normal - ---- -// Test full numbering. -#set enum(numbering: "1.a.", full: true) -+ First - + Nested - ---- -// Test numbering with closure. -#enum( - start: 3, - spacing: 0.65em - 3pt, - tight: false, - numbering: n => text( - fill: (red, green, blue).at(calc.rem(n, 3)), - numbering("A", n), - ), - [Red], [Green], [Blue], [Red], -) - ---- -// Test numbering with closure and nested lists. -#set enum(numbering: n => super[#n]) -+ A - + B -+ C - ---- -// Test numbering with closure and nested lists. -#set text(font: "New Computer Modern") -#set enum(numbering: (..args) => math.mat(args.pos()), full: true) -+ A - + B - + C - + D -+ E -+ F - ---- -// Error: 22-24 invalid numbering pattern -#set enum(numbering: "") - ---- -// Error: 22-28 invalid numbering pattern -#set enum(numbering: "(())") diff --git a/tests/typ/layout/enum.typ b/tests/typ/layout/enum.typ deleted file mode 100644 index f9fe2648..00000000 --- a/tests/typ/layout/enum.typ +++ /dev/null @@ -1,48 +0,0 @@ -// Test enumerations. - ---- -#enum[Embrace][Extend][Extinguish] - ---- -0. Before first! -1. First. - 2. Indented - -+ Second - ---- -// Test automatic numbering in summed content. -#for i in range(5) { - [+ #numbering("I", 1 + i)] -} - ---- -// Mix of different lists -- Bullet List -+ Numbered List -/ Term: List - ---- -// In the line. -1.2 \ -This is 0. \ -See 0.3. \ - ---- -// Edge cases. -+ -Empty \ -+Nope \ -a + 0. - ---- -// Test item number overriding. -1. first -+ second -5. fifth - -#enum( - enum.item(1)[First], - [Second], - enum.item(5)[Fifth] -) diff --git a/tests/typ/layout/flow-orphan.typ b/tests/typ/layout/flow-orphan.typ deleted file mode 100644 index 9c5c2399..00000000 --- a/tests/typ/layout/flow-orphan.typ +++ /dev/null @@ -1,30 +0,0 @@ -// Test that lines and headings doesn't become orphan. - ---- -#set page(height: 100pt) -#lorem(12) - -= Introduction -This is the start and it goes on. - ---- -#set page("a8", height: 140pt) -#set text(weight: 700) - -// Fits fully onto the first page. -#set text(blue) -#lorem(27) - -// The first line would fit, but is moved to the second page. -#lorem(20) - -// The second-to-last line is moved to the third page so that the last is isn't -// as lonely. -#set text(maroon) -#lorem(11) - -#lorem(13) - -// All three lines go to the next page. -#set text(olive) -#lorem(10) diff --git a/tests/typ/layout/grid-1.typ b/tests/typ/layout/grid-1.typ deleted file mode 100644 index 411fd8d0..00000000 --- a/tests/typ/layout/grid-1.typ +++ /dev/null @@ -1,41 +0,0 @@ -// Test grid layouts. - ---- -#let cell(width, color) = rect(width: width, height: 2cm, fill: color) -#set page(width: 100pt, height: 140pt) -#grid( - columns: (auto, 1fr, 3fr, 0.25cm, 3%, 2mm + 10%), - cell(0.5cm, rgb("2a631a")), - cell(100%, forest), - cell(100%, conifer), - cell(100%, rgb("ff0000")), - cell(100%, rgb("00ff00")), - cell(80%, rgb("00faf0")), - cell(1cm, rgb("00ff00")), - cell(0.5cm, rgb("2a631a")), - cell(100%, forest), - cell(100%, conifer), - cell(100%, rgb("ff0000")), - cell(100%, rgb("00ff00")), -) - ---- -#set rect(inset: 0pt) -#grid( - columns: (auto, auto, 40%), - column-gutter: 1fr, - row-gutter: 1fr, - rect(fill: eastern)[dddaa aaa aaa], - rect(fill: conifer)[ccc], - rect(fill: rgb("dddddd"))[aaa], -) - ---- -#set page(height: 3cm, margin: 0pt) -#grid( - columns: (1fr,), - rows: (1fr, auto, 2fr), - [], - align(center)[A bit more to the top], - [], -) diff --git a/tests/typ/layout/grid-2.typ b/tests/typ/layout/grid-2.typ deleted file mode 100644 index 66623878..00000000 --- a/tests/typ/layout/grid-2.typ +++ /dev/null @@ -1,29 +0,0 @@ -// Test using the `grid` function to create a finance table. - ---- -#set page(width: 11cm, height: 2.5cm) -#grid( - columns: 5, - column-gutter: (2fr, 1fr, 1fr), - row-gutter: 6pt, - [*Quarter*], - [Expenditure], - [External Revenue], - [Financial ROI], - [_total_], - [*Q1*], - [173,472.57 \$], - [472,860.91 \$], - [51,286.84 \$], - [_350,675.18 \$_], - [*Q2*], - [93,382.12 \$], - [439,382.85 \$], - [-1,134.30 \$], - [_344,866.43 \$_], - [*Q3*], - [96,421.49 \$], - [238,583.54 \$], - [3,497.12 \$], - [_145,659.17 \$_], -) diff --git a/tests/typ/layout/grid-3.typ b/tests/typ/layout/grid-3.typ deleted file mode 100644 index a6c72d6c..00000000 --- a/tests/typ/layout/grid-3.typ +++ /dev/null @@ -1,61 +0,0 @@ -// Test grid cells that overflow to the next region. - ---- -#set page(width: 5cm, height: 3cm) -#grid( - columns: 2, - row-gutter: 8pt, - [Lorem ipsum dolor sit amet. - - Aenean commodo ligula eget dolor. Aenean massa. Penatibus et magnis.], - [Text that is rather short], - [Fireflies], - [Critical], - [Decorum], - [Rampage], -) - ---- -// Test a column that starts overflowing right after another row/column did -// that. -#set page(width: 5cm, height: 2cm) -#grid( - columns: 4 * (1fr,), - row-gutter: 10pt, - column-gutter: (0pt, 10%), - align(top, image("/assets/images/rhino.png")), - align(top, rect(inset: 0pt, fill: eastern, align(right)[LoL])), - [rofl], - [\ A] * 3, - [Ha!\ ] * 3, -) - ---- -// Test two columns in the same row overflowing by a different amount. -#set page(width: 5cm, height: 2cm) -#grid( - columns: 3 * (1fr,), - row-gutter: 8pt, - column-gutter: (0pt, 10%), - [A], [B], [C], - [Ha!\ ] * 6, - [rofl], - [\ A] * 3, - [hello], - [darkness], - [my old] -) - ---- -// Test grid within a grid, overflowing. -#set page(width: 5cm, height: 2.25cm) -#grid( - columns: 4 * (1fr,), - row-gutter: 10pt, - column-gutter: (0pt, 10%), - [A], [B], [C], [D], - grid(columns: 2, [A], [B], [C\ ]*3, [D]), - align(top, rect(inset: 0pt, fill: eastern, align(right)[LoL])), - [rofl], - [E\ ]*4, -) diff --git a/tests/typ/layout/grid-4.typ b/tests/typ/layout/grid-4.typ deleted file mode 100644 index c7ae7649..00000000 --- a/tests/typ/layout/grid-4.typ +++ /dev/null @@ -1,33 +0,0 @@ -// Test relative sizing inside grids. - ---- -// Test that auto and relative columns use the correct base. -#grid( - columns: (auto, 60%), - rows: (auto, auto), - rect(width: 50%, height: 0.5cm, fill: conifer), - rect(width: 100%, height: 0.5cm, fill: eastern), - rect(width: 50%, height: 0.5cm, fill: forest), -) - ---- -// Test that fr columns use the correct base. -#grid( - columns: (1fr,) * 4, - rows: (1cm,), - rect(width: 50%, fill: conifer), - rect(width: 50%, fill: forest), - rect(width: 50%, fill: conifer), - rect(width: 50%, fill: forest), -) - ---- -// Test that all three kinds of rows use the correct bases. -#set page(height: 4cm, margin: 0cm) -#grid( - rows: (1cm, 1fr, 1fr, auto), - rect(height: 50%, width: 100%, fill: conifer), - rect(height: 50%, width: 100%, fill: forest), - rect(height: 50%, width: 100%, fill: conifer), - rect(height: 25%, width: 100%, fill: forest), -) diff --git a/tests/typ/layout/grid-5.typ b/tests/typ/layout/grid-5.typ deleted file mode 100644 index 66272421..00000000 --- a/tests/typ/layout/grid-5.typ +++ /dev/null @@ -1,40 +0,0 @@ - ---- -// Test that trailing linebreak doesn't overflow the region. -#set page(height: 2cm) -#grid[ - Hello \ - Hello \ - Hello \ - - World -] - ---- -// Test that broken cell expands vertically. -#set page(height: 2.25cm) -#grid( - columns: 2, - gutter: 10pt, - align(bottom)[A], - [ - Top - #align(bottom)[ - Bottom \ - Bottom \ - #v(0pt) - Top - ] - ], - align(top)[B], -) - ---- -// Ensure grids expand enough for the given rows. -#grid( - columns: (2em, 2em), - rows: (2em,) * 4, - fill: red, - stroke: aqua, - [a] -) diff --git a/tests/typ/layout/grid-auto-shrink.typ b/tests/typ/layout/grid-auto-shrink.typ deleted file mode 100644 index 4d9ef0d8..00000000 --- a/tests/typ/layout/grid-auto-shrink.typ +++ /dev/null @@ -1,12 +0,0 @@ -// Test iterative auto column shrinking. - ---- -#set page(width: 210mm - 2 * 2.5cm + 2 * 10pt) -#set text(11pt) -#table( - columns: 4, - [Hello!], - [Hello there, my friend!], - [Hello there, my friends! Hi!], - [Hello there, my friends! Hi! What is going on right now?], -) diff --git a/tests/typ/layout/grid-cell.typ b/tests/typ/layout/grid-cell.typ deleted file mode 100644 index a812fefc..00000000 --- a/tests/typ/layout/grid-cell.typ +++ /dev/null @@ -1,133 +0,0 @@ -// Test basic styling using the grid.cell element. - ---- -// Cell override -#grid( - align: left, - fill: red, - stroke: blue, - inset: 5pt, - columns: 2, - [AAAAA], [BBBBB], - [A], [B], - grid.cell(align: right)[C], [D], - align(right)[E], [F], - align(horizon)[G], [A\ A\ A], - grid.cell(align: horizon)[G2], [A\ A\ A], - grid.cell(inset: 0pt)[I], [F], - [H], grid.cell(fill: blue)[J] -) - ---- -// Cell show rule -#show grid.cell: it => [Zz] - -#grid( - align: left, - fill: red, - stroke: blue, - inset: 5pt, - columns: 2, - [AAAAA], [BBBBB], - [A], [B], - grid.cell(align: right)[C], [D], - align(right)[E], [F], - align(horizon)[G], [A\ A\ A] -) - ---- -#show grid.cell: it => (it.align, it.fill) -#grid( - align: left, - row-gutter: 5pt, - [A], - grid.cell(align: right)[B], - grid.cell(fill: aqua)[B], -) - ---- -// Cell set rules -#set grid.cell(align: center) -#show grid.cell: it => (it.align, it.fill, it.inset) -#set grid.cell(inset: 20pt) -#grid( - align: left, - row-gutter: 5pt, - [A], - grid.cell(align: right)[B], - grid.cell(fill: aqua)[B], -) - ---- -// Test folding per-cell properties (align and inset) -#grid( - columns: (1fr, 1fr), - rows: (2.5em, auto), - align: right, - inset: 5pt, - fill: (x, y) => (green, aqua).at(calc.rem(x + y, 2)), - [Top], grid.cell(align: bottom)[Bot], - grid.cell(inset: (bottom: 0pt))[Bot], grid.cell(inset: (bottom: 0pt))[Bot] -) - ---- -// Test overriding outside alignment -#set align(bottom + right) -#grid( - columns: (1fr, 1fr), - rows: 2em, - align: auto, - fill: green, - [BR], [BR], - grid.cell(align: left, fill: aqua)[BL], grid.cell(align: top, fill: red.lighten(50%))[TR] -) - ---- -// First doc example -#grid( - columns: 2, - fill: red, - align: left, - inset: 5pt, - [ABC], [ABC], - grid.cell(fill: blue)[C], [D], - grid.cell(align: center)[E], [F], - [G], grid.cell(inset: 0pt)[H] -) - ---- -#{ - show grid.cell: emph - grid( - columns: 2, - gutter: 3pt, - [Hello], [World], - [Sweet], [Italics] - ) -} - ---- -// Style based on position -#{ - show grid.cell: it => { - if it.y == 0 { - strong(it) - } else if it.x == 1 { - emph(it) - } else { - it - } - } - grid( - columns: 3, - gutter: 3pt, - [Name], [Age], [Info], - [John], [52], [Nice], - [Mary], [50], [Cool], - [Jake], [49], [Epic] - ) -} - ---- -// Error: 7-19 cannot use `table.cell` as a grid cell; use `grid.cell` instead -#grid(table.cell[]) diff --git a/tests/typ/layout/grid-colspan.typ b/tests/typ/layout/grid-colspan.typ deleted file mode 100644 index 1bdadcf1..00000000 --- a/tests/typ/layout/grid-colspan.typ +++ /dev/null @@ -1,141 +0,0 @@ -#grid( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - grid.cell(colspan: 4)[*Full Header*], - grid.cell(colspan: 2, fill: orange)[*Half*], - grid.cell(colspan: 2, fill: orange.darken(10%))[*Half*], - [*A*], [*B*], [*C*], [*D*], - [1], [2], [3], [4], - [5], grid.cell(colspan: 3, fill: orange.darken(10%))[6], - grid.cell(colspan: 2, fill: orange)[7], [8], [9], - [10], grid.cell(colspan: 2, fill: orange.darken(10%))[11], [12] -) - -#table( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - table.cell(colspan: 4)[*Full Header*], - table.cell(colspan: 2, fill: orange)[*Half*], - table.cell(colspan: 2, fill: orange.darken(10%))[*Half*], - [*A*], [*B*], [*C*], [*D*], - [1], [2], [3], [4], - [5], table.cell(colspan: 3, fill: orange.darken(10%))[6], - table.cell(colspan: 2, fill: orange)[7], [8], [9], - [10], table.cell(colspan: 2, fill: orange.darken(10%))[11], [12] -) - ---- -#grid( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - gutter: 3pt, - grid.cell(colspan: 4)[*Full Header*], - grid.cell(colspan: 2, fill: orange)[*Half*], - grid.cell(colspan: 2, fill: orange.darken(10%))[*Half*], - [*A*], [*B*], [*C*], [*D*], - [1], [2], [3], [4], - [5], grid.cell(colspan: 3, fill: orange.darken(10%))[6], - grid.cell(colspan: 2, fill: orange)[7], [8], [9], - [10], grid.cell(colspan: 2, fill: orange.darken(10%))[11], [12] -) - -#table( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - gutter: 3pt, - table.cell(colspan: 4)[*Full Header*], - table.cell(colspan: 2, fill: orange)[*Half*], - table.cell(colspan: 2, fill: orange.darken(10%))[*Half*], - [*A*], [*B*], [*C*], [*D*], - [1], [2], [3], [4], - [5], table.cell(colspan: 3, fill: orange.darken(10%))[6], - table.cell(colspan: 2, fill: orange)[7], [8], [9], - [10], table.cell(colspan: 2, fill: orange.darken(10%))[11], [12] -) - ---- -#set page(width: 300pt) -#table( - columns: (2em, 2em, auto, auto), - stroke: 5pt, - [A], [B], [C], [D], - table.cell(colspan: 4, lorem(20)), - [A], table.cell(colspan: 2)[BCBCBCBC], [D] -) - ---- -// Error: 3:8-3:32 cell's colspan would cause it to exceed the available column(s) -// Hint: 3:8-3:32 try placing the cell in another position or reducing its colspan -#grid( - columns: 3, - [a], grid.cell(colspan: 3)[b] -) - ---- -// Error: 4:8-4:32 cell would span a previously placed cell at column 2, row 0 -// Hint: 4:8-4:32 try specifying your cells in a different order or reducing the cell's rowspan or colspan -#grid( - columns: 3, - grid.cell(x: 2, y: 0)[x], - [a], grid.cell(colspan: 2)[b] -) - ---- -// Colspan over all fractional columns shouldn't expand auto columns on finite pages -#table( - columns: (1fr, 1fr, auto), - [A], [B], [C], - [D], [E], [F] -) -#table( - columns: (1fr, 1fr, auto), - table.cell(colspan: 3, lorem(8)), - [A], [B], [C], - [D], [E], [F] -) - ---- -// Colspan over only some fractional columns will not trigger the heuristic, and -// the auto column will expand more than it should. The table looks off, as a result. -#table( - columns: (1fr, 1fr, auto), - [], table.cell(colspan: 2, lorem(8)), - [A], [B], [C], - [D], [E], [F] -) - ---- -// On infinite pages, colspan over all fractional columns SHOULD expand auto columns -#set page(width: auto) -#table( - columns: (1fr, 1fr, auto), - [A], [B], [C], - [D], [E], [F] -) -#table( - columns: (1fr, 1fr, auto), - table.cell(colspan: 3, lorem(8)), - [A], [B], [C], - [D], [E], [F] -) - ---- -// Test multiple regions -#set page(height: 5em) -#grid( - stroke: red, - fill: aqua, - columns: 4, - [a], [b], [c], [d], - [a], grid.cell(colspan: 2)[e, f, g, h, i], [f], - [e], [g], grid.cell(colspan: 2)[eee\ e\ e\ e], - grid.cell(colspan: 4)[eeee e e e] -) diff --git a/tests/typ/layout/grid-footers-1.typ b/tests/typ/layout/grid-footers-1.typ deleted file mode 100644 index c7a59e60..00000000 --- a/tests/typ/layout/grid-footers-1.typ +++ /dev/null @@ -1,192 +0,0 @@ -#set page(width: auto, height: 15em) -#set text(6pt) -#set table(inset: 2pt, stroke: 0.5pt) -#table( - columns: 5, - align: center + horizon, - table.header( - table.cell(colspan: 5)[*Cool Zone*], - table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], - table.hline(start: 2, end: 3, stroke: yellow) - ), - ..range(0, 5).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten(), - table.footer( - table.hline(start: 2, end: 3, stroke: yellow), - table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], - table.cell(colspan: 5)[*Cool Zone*] - ) -) - ---- -// Gutter & no repetition -#set page(width: auto, height: 16em) -#set text(6pt) -#set table(inset: 2pt, stroke: 0.5pt) -#table( - columns: 5, - gutter: 2pt, - align: center + horizon, - table.header( - table.cell(colspan: 5)[*Cool Zone*], - table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], - table.hline(start: 2, end: 3, stroke: yellow) - ), - ..range(0, 5).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten(), - table.footer( - repeat: false, - table.hline(start: 2, end: 3, stroke: yellow), - table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], - table.cell(colspan: 5)[*Cool Zone*] - ) -) - ---- -#table( - table.header(table.cell(stroke: red)[Hello]), - table.footer(table.cell(stroke: aqua)[Bye]), -) - ---- -#table( - gutter: 3pt, - table.header(table.cell(stroke: red)[Hello]), - table.footer(table.cell(stroke: aqua)[Bye]), -) - ---- -// Footer's top stroke should win when repeated, but lose at the last page. -#set page(height: 10em) -#table( - stroke: green, - table.header(table.cell(stroke: red)[Hello]), - table.cell(stroke: yellow)[Hi], - table.cell(stroke: yellow)[Bye], - table.cell(stroke: yellow)[Ok], - table.footer[Bye], -) - ---- -// Relative lengths -#set page(height: 10em) -#table( - rows: (30%, 30%, auto), - [C], - [C], - table.footer[*A*][*B*], -) - ---- -#grid( - grid.footer(grid.cell(y: 2)[b]), - grid.cell(y: 0)[a], - grid.cell(y: 1)[c], -) - ---- -// Ensure footer properly expands -#grid( - columns: 2, - [a], [], - [b], [], - grid.cell(x: 1, y: 3, rowspan: 4)[b], - grid.cell(y: 2, rowspan: 2)[a], - grid.footer(), - grid.cell(y: 4)[d], - grid.cell(y: 5)[e], - grid.cell(y: 6)[f], -) - ---- -// Error: 2:3-2:19 footer must end at the last row -#grid( - grid.footer([a]), - [b], -) - ---- -// Error: 3:3-3:19 footer must end at the last row -#grid( - columns: 2, - grid.footer([a]), - [b], -) - ---- -// Error: 4:3-4:19 footer would conflict with a cell placed before it at column 1 row 0 -// Hint: 4:3-4:19 try reducing that cell's rowspan or moving the footer -#grid( - columns: 2, - grid.header(), - grid.footer([a]), - grid.cell(x: 1, y: 0, rowspan: 2)[a], -) - ---- -// Error: 4:3-4:19 cannot have more than one footer -#grid( - [a], - grid.footer([a]), - grid.footer([b]), -) - ---- -// Error: 3:3-3:20 cannot use `table.footer` as a grid footer; use `grid.footer` instead -#grid( - [a], - table.footer([a]), -) - ---- -// Error: 3:3-3:19 cannot use `grid.footer` as a table footer; use `table.footer` instead -#table( - [a], - grid.footer([a]), -) - ---- -// Error: 14-28 cannot place a grid footer within another footer or header -#grid.header(grid.footer[a]) - ---- -// Error: 14-29 cannot place a table footer within another footer or header -#grid.header(table.footer[a]) - ---- -// Error: 15-29 cannot place a grid footer within another footer or header -#table.header(grid.footer[a]) - ---- -// Error: 15-30 cannot place a table footer within another footer or header -#table.header(table.footer[a]) - ---- -// Error: 14-28 cannot place a grid footer within another footer or header -#grid.footer(grid.footer[a]) - ---- -// Error: 14-29 cannot place a table footer within another footer or header -#grid.footer(table.footer[a]) - ---- -// Error: 15-29 cannot place a grid footer within another footer or header -#table.footer(grid.footer[a]) - ---- -// Error: 15-30 cannot place a table footer within another footer or header -#table.footer(table.footer[a]) - ---- -// Error: 14-28 cannot place a grid header within another header or footer -#grid.footer(grid.header[a]) - ---- -// Error: 14-29 cannot place a table header within another header or footer -#grid.footer(table.header[a]) - ---- -// Error: 15-29 cannot place a grid header within another header or footer -#table.footer(grid.header[a]) - ---- -// Error: 15-30 cannot place a table header within another header or footer -#table.footer(table.header[a]) diff --git a/tests/typ/layout/grid-footers-2.typ b/tests/typ/layout/grid-footers-2.typ deleted file mode 100644 index df333434..00000000 --- a/tests/typ/layout/grid-footers-2.typ +++ /dev/null @@ -1,31 +0,0 @@ -#set page(height: 17em) -#table( - rows: (auto, 2.5em, auto), - table.header[*Hello*][*World*], - block(width: 2em, height: 10em, fill: red), - table.footer[*Bye*][*World*], -) - ---- -// Rowspan sizing algorithm doesn't do the best job at non-contiguous content -// ATM. -#set page(height: 20em) - -#table( - rows: (auto, 2.5em, 2em, auto, 5em, 2em, 2.5em), - table.header[*Hello*][*World*], - table.cell(rowspan: 3, lorem(20)), - table.footer[*Ok*][*Bye*], -) - ---- -// This should look right -#set page(height: 20em) - -#table( - rows: (auto, 2.5em, 2em, auto), - gutter: 3pt, - table.header[*Hello*][*World*], - table.cell(rowspan: 3, lorem(20)), - table.footer[*Ok*][*Bye*], -) diff --git a/tests/typ/layout/grid-footers-3.typ b/tests/typ/layout/grid-footers-3.typ deleted file mode 100644 index 070500f1..00000000 --- a/tests/typ/layout/grid-footers-3.typ +++ /dev/null @@ -1,44 +0,0 @@ -// Test lack of space for header + text. -#set page(height: 9em + 2.5em + 1.5em) - -#table( - rows: (auto, 2.5em, auto, auto, 10em, 2.5em, auto), - gutter: 3pt, - table.header[*Hello*][*World*], - table.cell(rowspan: 3, lorem(30)), - table.footer[*Ok*][*Bye*], -) - ---- -// Orphan header prevention test -#set page(height: 13em) -#v(8em) -#grid( - columns: 3, - gutter: 5pt, - grid.header( - [*Mui*], [*A*], grid.cell(rowspan: 2, fill: orange)[*B*], - [*Header*], [*Header* #v(0.1em)], - ), - ..([Test], [Test], [Test]) * 7, - grid.footer( - [*Mui*], [*A*], grid.cell(rowspan: 2, fill: orange)[*B*], - [*Footer*], [*Footer* #v(0.1em)], - ), -) - ---- -// Empty footer should just be a repeated blank row -#set page(height: 8em) -#table( - columns: 4, - align: center + horizon, - table.header(), - ..range(0, 2).map(i => ( - [John \##i], - table.cell(stroke: green)[123], - table.cell(stroke: blue)[456], - [789] - )).flatten(), - table.footer(), -) diff --git a/tests/typ/layout/grid-footers-4.typ b/tests/typ/layout/grid-footers-4.typ deleted file mode 100644 index b6d978e9..00000000 --- a/tests/typ/layout/grid-footers-4.typ +++ /dev/null @@ -1,42 +0,0 @@ -// When a footer has a rowspan with an empty row, it should be displayed -// properly -#set page(height: 14em, width: auto) - -#let count = counter("g") -#table( - rows: (auto, 2em, auto, auto), - table.header( - [eeec], - table.cell(rowspan: 2, count.step() + count.display()), - ), - [d], - block(width: 5em, fill: yellow, lorem(7)), - [d], - table.footer( - [eeec], - table.cell(rowspan: 2, count.step() + count.display()), - ) -) -#count.display() - ---- -// Nested table with footer should repeat both footers -#set page(height: 10em, width: auto) -#table( - table( - [a\ b\ c\ d], - table.footer[b], - ), - table.footer[a], -) - ---- -#set page(height: 12em, width: auto) -#table( - [a\ b\ c\ d], - table.footer(table( - [c], - [d], - table.footer[b], - )) -) diff --git a/tests/typ/layout/grid-footers-5.typ b/tests/typ/layout/grid-footers-5.typ deleted file mode 100644 index 16da940a..00000000 --- a/tests/typ/layout/grid-footers-5.typ +++ /dev/null @@ -1,87 +0,0 @@ -// General footer-only tests -#set page(height: 9em) -#table( - columns: 2, - [a], [], - [b], [], - [c], [], - [d], [], - [e], [], - table.footer( - [*Ok*], table.cell(rowspan: 2)[test], - [*Thanks*] - ) -) - ---- -#set page(height: 5em) -#table( - table.footer[a][b][c] -) - ---- -#table(table.footer[a][b][c]) - -#table( - gutter: 3pt, - table.footer[a][b][c] -) - ---- -// Test footer stroke priority edge case -#set page(height: 10em) -#table( - columns: 2, - stroke: black, - ..(table.cell(stroke: aqua)[d],) * 8, - table.footer( - table.cell(rowspan: 2, colspan: 2)[a], - [c], [d] - ) -) - ---- -// Footer should appear at the bottom. Red line should be above the footer. -// Green line should be on the left border. -#set page(margin: 2pt) -#set text(6pt) -#table( - columns: 2, - inset: 1.5pt, - table.cell(y: 0)[a], - table.cell(x: 1, y: 1)[a], - table.cell(y: 2)[a], - table.footer( - table.hline(stroke: red), - table.vline(stroke: green), - [b], - ), - table.cell(x: 1, y: 3)[c] -) - ---- -// Table should be just one row. [c] appears at the third column. -#set page(margin: 2pt) -#set text(6pt) -#table( - columns: 3, - inset: 1.5pt, - table.cell(y: 0)[a], - table.footer( - table.hline(stroke: red), - table.hline(y: 1, stroke: aqua), - table.cell(y: 0)[b], - [c] - ) -) - ---- -// Footer should go below the rowspans. -#set page(margin: 2pt) -#set text(6pt) -#table( - columns: 2, - inset: 1.5pt, - table.cell(rowspan: 2)[a], table.cell(rowspan: 2)[b], - table.footer() -) diff --git a/tests/typ/layout/grid-headers-1.typ b/tests/typ/layout/grid-headers-1.typ deleted file mode 100644 index ac998029..00000000 --- a/tests/typ/layout/grid-headers-1.typ +++ /dev/null @@ -1,162 +0,0 @@ -#set page(width: auto, height: 12em) -#table( - columns: 5, - align: center + horizon, - table.header( - table.cell(colspan: 5)[*Cool Zone*], - table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], - table.hline(start: 2, end: 3, stroke: yellow) - ), - ..range(0, 6).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten() -) - ---- -// Disable repetition -#set page(width: auto, height: 12em) -#table( - columns: 5, - align: center + horizon, - table.header( - table.cell(colspan: 5)[*Cool Zone*], - table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], - table.hline(start: 2, end: 3, stroke: yellow), - repeat: false - ), - ..range(0, 6).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten() -) - ---- -#set page(width: auto, height: 12em) -#table( - columns: 5, - align: center + horizon, - gutter: 3pt, - table.header( - table.cell(colspan: 5)[*Cool Zone*], - table.cell(stroke: red)[*Name*], table.cell(stroke: aqua)[*Number*], [*Data 1*], [*Data 2*], [*Etc*], - table.hline(start: 2, end: 3, stroke: yellow), - ), - ..range(0, 6).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten() -) - ---- -// Relative lengths -#set page(height: 10em) -#table( - rows: (30%, 30%, auto), - table.header( - [*A*], - [*B*] - ), - [C], - [C] -) - ---- -#grid( - grid.cell(y: 1)[a], - grid.header(grid.cell(y: 0)[b]), - grid.cell(y: 2)[c] -) - ---- -// When the header is the last grid child, it shouldn't include the gutter row -// after it, because there is none. -#grid( - columns: 2, - gutter: 3pt, - grid.header( - [a], [b], - [c], [d] - ) -) - ---- -#set page(height: 14em) -#let t(n) = table( - columns: 3, - align: center + horizon, - gutter: 3pt, - table.header( - table.cell(colspan: 3)[*Cool Zone #n*], - [*Name*], [*Num*], [*Data*] - ), - ..range(0, 5).map(i => ([\##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456])).flatten() -) -#grid( - gutter: 3pt, - t(0), - t(1) -) - ---- -// Test line positioning in header -#table( - columns: 3, - stroke: none, - table.hline(stroke: red, end: 2), - table.vline(stroke: red, end: 3), - table.header( - table.hline(stroke: aqua, start: 2), - table.vline(stroke: aqua, start: 3), [*A*], table.hline(stroke: orange), table.vline(stroke: orange), [*B*], - [*C*], [*D*] - ), - [a], [b], - [c], [d], - [e], [f] -) - ---- -// Error: 3:3-3:19 header must start at the first row -// Hint: 3:3-3:19 remove any rows before the header -#grid( - [a], - grid.header([b]) -) - ---- -// Error: 4:3-4:19 header must start at the first row -// Hint: 4:3-4:19 remove any rows before the header -#grid( - columns: 2, - [a], - grid.header([b]) -) - ---- -// Error: 3:3-3:19 cannot have more than one header -#grid( - grid.header([a]), - grid.header([b]), - [a], -) - ---- -// Error: 2:3-2:20 cannot use `table.header` as a grid header; use `grid.header` instead -#grid( - table.header([a]), - [a], -) - ---- -// Error: 2:3-2:19 cannot use `grid.header` as a table header; use `table.header` instead -#table( - grid.header([a]), - [a], -) - ---- -// Error: 14-28 cannot place a grid header within another header or footer -#grid.header(grid.header[a]) - ---- -// Error: 14-29 cannot place a table header within another header or footer -#grid.header(table.header[a]) - ---- -// Error: 15-29 cannot place a grid header within another header or footer -#table.header(grid.header[a]) - ---- -// Error: 15-30 cannot place a table header within another header or footer -#table.header(table.header[a]) diff --git a/tests/typ/layout/grid-headers-2.typ b/tests/typ/layout/grid-headers-2.typ deleted file mode 100644 index 75c9b330..00000000 --- a/tests/typ/layout/grid-headers-2.typ +++ /dev/null @@ -1,52 +0,0 @@ -#set page(height: 15em) -#table( - rows: (auto, 2.5em, auto), - table.header( - [*Hello*], - [*World*] - ), - block(width: 2em, height: 20em, fill: red) -) - ---- -// Rowspan sizing algorithm doesn't do the best job at non-contiguous content -// ATM. -#set page(height: 15em) - -#table( - rows: (auto, 2.5em, 2em, auto, 5em), - table.header( - [*Hello*], - [*World*] - ), - table.cell(rowspan: 3, lorem(40)) -) - ---- -// Rowspan sizing algorithm doesn't do the best job at non-contiguous content -// ATM. -#set page(height: 15em) - -#table( - rows: (auto, 2.5em, 2em, auto, 5em), - gutter: 3pt, - table.header( - [*Hello*], - [*World*] - ), - table.cell(rowspan: 3, lorem(40)) -) - ---- -// This should look right -#set page(height: 15em) - -#table( - rows: (auto, 2.5em, 2em, auto), - gutter: 3pt, - table.header( - [*Hello*], - [*World*] - ), - table.cell(rowspan: 3, lorem(40)) -) diff --git a/tests/typ/layout/grid-headers-3.typ b/tests/typ/layout/grid-headers-3.typ deleted file mode 100644 index e7437cf7..00000000 --- a/tests/typ/layout/grid-headers-3.typ +++ /dev/null @@ -1,35 +0,0 @@ -// Test lack of space for header + text. -#set page(height: 9em) - -#table( - rows: (auto, 2.5em, auto, auto, 10em), - gutter: 3pt, - table.header( - [*Hello*], - [*World*] - ), - table.cell(rowspan: 3, lorem(80)) -) - ---- -// Orphan header prevention test -#set page(height: 12em) -#v(8em) -#grid( - columns: 3, - grid.header( - [*Mui*], [*A*], grid.cell(rowspan: 2, fill: orange)[*B*], - [*Header*], [*Header* #v(0.1em)] - ), - ..([Test], [Test], [Test]) * 20 -) - ---- -// Empty header should just be a repeated blank row -#set page(height: 12em) -#table( - columns: 4, - align: center + horizon, - table.header(), - ..range(0, 4).map(i => ([John \##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789])).flatten() -) diff --git a/tests/typ/layout/grid-headers-4.typ b/tests/typ/layout/grid-headers-4.typ deleted file mode 100644 index 6ab0d612..00000000 --- a/tests/typ/layout/grid-headers-4.typ +++ /dev/null @@ -1,112 +0,0 @@ -// When a header has a rowspan with an empty row, it should be displayed -// properly -#set page(height: 10em) - -#let count = counter("g") -#table( - rows: (auto, 2em, auto, auto), - table.header( - [eeec], - table.cell(rowspan: 2, count.step() + count.display()), - ), - [d], - block(width: 5em, fill: yellow, lorem(15)), - [d] -) -#count.display() - ---- -// Ensure header expands to fit cell placed in it after its declaration -#set page(height: 10em) -#table( - columns: 2, - table.header( - [a], [b], - [c], - ), - table.cell(x: 1, y: 1, rowspan: 2, lorem(80)) -) - ---- -// Nested table with header should repeat both headers -#set page(height: 10em) -#table( - table.header( - [a] - ), - table( - table.header( - [b] - ), - [a\ b\ c\ d] - ) -) - ---- -#set page(height: 12em) -#table( - table.header( - table( - table.header( - [b] - ), - [c], - [d] - ) - ), - [a\ b] -) - ---- -// Test header stroke priority edge case (last header row removed) -#set page(height: 8em) -#table( - columns: 2, - stroke: black, - gutter: (auto, 3pt), - table.header( - [c], [d], - ), - ..(table.cell(stroke: aqua)[d],) * 8, -) - ---- -// Yellow line should be kept here -#set text(6pt) -#table( - column-gutter: 3pt, - inset: 1pt, - table.header( - [a], - table.hline(stroke: yellow), - ), - table.cell(rowspan: 2)[b] -) - ---- -// Red line should be kept here -#set page(height: 6em) -#set text(6pt) -#table( - column-gutter: 3pt, - inset: 1pt, - table.header( - table.hline(stroke: red, position: bottom), - [a], - ), - [a], - table.cell(stroke: aqua)[b] -) - ---- -#set page(height: 7em) -#set text(6pt) -#let full-block = block(width: 2em, height: 100%, fill: red) -#table( - columns: 3, - inset: 1.5pt, - table.header( - [a], full-block, table.cell(rowspan: 2, full-block), - [b] - ) -) diff --git a/tests/typ/layout/grid-positioning.typ b/tests/typ/layout/grid-positioning.typ deleted file mode 100644 index 228fadf7..00000000 --- a/tests/typ/layout/grid-positioning.typ +++ /dev/null @@ -1,205 +0,0 @@ -// Test cell positioning in grids. - ---- -#{ - show grid.cell: it => (it.x, it.y) - grid( - columns: 2, - inset: 5pt, - fill: aqua, - gutter: 3pt, - [Hello], [World], - [Sweet], [Home] - ) -} -#{ - show table.cell: it => pad(rest: it.inset)[#(it.x, it.y)] - table( - columns: 2, - gutter: 3pt, - [Hello], [World], - [Sweet], [Home] - ) -} - ---- -// Positioning cells in a different order than they appear -#grid( - columns: 2, - [A], [B], - grid.cell(x: 1, y: 2)[C], grid.cell(x: 0, y: 2)[D], - grid.cell(x: 1, y: 1)[E], grid.cell(x: 0, y: 1)[F], -) - ---- -// Creating more rows by positioning out of bounds -#grid( - columns: 3, - rows: 1.5em, - inset: 5pt, - fill: (x, y) => if (x, y) == (0, 0) { blue } else if (x, y) == (2, 3) { red } else { green }, - [A], - grid.cell(x: 2, y: 3)[B] -) - -#table( - columns: (3em, 1em, 3em), - rows: 1.5em, - inset: (top: 0pt, bottom: 0pt, rest: 5pt), - fill: (x, y) => if (x, y) == (0, 0) { blue } else if (x, y) == (2, 3) { red } else { green }, - align: (x, y) => (left, center, right).at(x), - [A], - table.cell(x: 2, y: 3)[B] -) - ---- -// Error: 3:3-3:42 attempted to place a second cell at column 0, row 0 -// Hint: 3:3-3:42 try specifying your cells in a different order -#grid( - [A], - grid.cell(x: 0, y: 0)[This shall error] -) - ---- -// Error: 3:3-3:43 attempted to place a second cell at column 0, row 0 -// Hint: 3:3-3:43 try specifying your cells in a different order -#table( - [A], - table.cell(x: 0, y: 0)[This shall error] -) - ---- -// Automatic position cell skips custom position cell -#grid( - grid.cell(x: 0, y: 0)[This shall not error], - [A] -) - ---- -// Error: 4:3-4:36 cell could not be placed at invalid column 2 -#grid( - columns: 2, - [A], - grid.cell(x: 2)[This shall error] -) - ---- -// Partial positioning -#grid( - columns: 3, - rows: 1.5em, - inset: 5pt, - fill: aqua, - [A], grid.cell(y: 1, fill: green)[B], [C], grid.cell(x: auto, y: 1, fill: green)[D], [E], - grid.cell(y: 2, fill: green)[F], grid.cell(x: 0, fill: orange)[G], grid.cell(x: 0, y: auto, fill: orange)[H], - grid.cell(x: 1, fill: orange)[I] -) - -#table( - columns: 3, - rows: 1.5em, - inset: 5pt, - fill: aqua, - [A], table.cell(y: 1, fill: green)[B], [C], table.cell(x: auto, y: 1, fill: green)[D], [E], - table.cell(y: 2, fill: green)[F], table.cell(x: 0, fill: orange)[G], table.cell(x: 0, y: auto, fill: orange)[H], - table.cell(x: 1, fill: orange)[I] -) - ---- -// Error: 4:3-4:21 cell could not be placed in row 0 because it was full -// Hint: 4:3-4:21 try specifying your cells in a different order -#grid( - columns: 2, - [A], [B], - grid.cell(y: 0)[C] -) - ---- -// Error: 4:3-4:22 cell could not be placed in row 0 because it was full -// Hint: 4:3-4:22 try specifying your cells in a different order -#table( - columns: 2, - [A], [B], - table.cell(y: 0)[C] -) - ---- -// Doc example 1 -#set page(width: auto) -#show grid.cell: it => { - if it.y == 0 { - set text(white) - strong(it) - } else { - // For the second row and beyond, we will write the day number for each - // cell. - - // In general, a cell's index is given by cell.x + columns * cell.y. - // Days start in the second grid row, so we subtract 1 row. - // But the first day is day 1, not day 0, so we add 1. - let day = it.x + 7 * (it.y - 1) + 1 - if day <= 31 { - // Place the day's number at the top left of the cell. - // Only if the day is valid for this month (not 32 or higher). - place(top + left, dx: 2pt, dy: 2pt, text(8pt, red.darken(40%))[#day]) - } - it - } -} - -#grid( - fill: (x, y) => if y == 0 { gray.darken(50%) }, - columns: (30pt,) * 7, - rows: (auto, 30pt), - // Events will be written at the bottom of each day square. - align: bottom, - inset: 5pt, - stroke: (thickness: 0.5pt, dash: "densely-dotted"), - - [Sun], [Mon], [Tue], [Wed], [Thu], [Fri], [Sat], - - // This event will occur on the first Friday (sixth column). - grid.cell(x: 5, fill: yellow.darken(10%))[Call], - - // This event will occur every Monday (second column). - // We have to repeat it 5 times so it occurs every week. - ..(grid.cell(x: 1, fill: red.lighten(50%))[Meet],) * 5, - - // This event will occur at day 19. - grid.cell(x: 4, y: 3, fill: orange.lighten(25%))[Talk], - - // These events will occur at the second week, where available. - grid.cell(y: 2, fill: aqua)[Chat], - grid.cell(y: 2, fill: aqua)[Walk], -) - ---- -// Doc example 2 -#set page(width: auto) -#show table.cell: it => { - if it.x == 0 or it.y == 0 { - set text(white) - strong(it) - } else if it.body == [] { - // Replace empty cells with 'N/A' - pad(rest: it.inset)[_N/A_] - } else { - it - } -} - -#table( - fill: (x, y) => if x == 0 or y == 0 { gray.darken(50%) }, - columns: 4, - [], [Exam 1], [Exam 2], [Exam 3], - ..([John], [Mary], [Jake], [Robert]).map(table.cell.with(x: 0)), - - // Mary got grade A on Exam 3. - table.cell(x: 3, y: 2, fill: green)[A], - - // Everyone got grade A on Exam 2. - ..(table.cell(x: 2, fill: green)[A],) * 4, - - // Robert got grade B on other exams. - ..(table.cell(y: 4, fill: aqua)[B],) * 2, -) diff --git a/tests/typ/layout/grid-rowspan-basic.typ b/tests/typ/layout/grid-rowspan-basic.typ deleted file mode 100644 index bbd1c047..00000000 --- a/tests/typ/layout/grid-rowspan-basic.typ +++ /dev/null @@ -1,252 +0,0 @@ -#grid( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - grid.cell(rowspan: 2, fill: orange)[*Left*], - [Right A], [Right A], [Right A], - [Right B], grid.cell(colspan: 2, rowspan: 2, fill: orange.darken(10%))[B Wide], - [Left A], [Left A], - [Left B], [Left B], grid.cell(colspan: 2, rowspan: 3, fill: orange)[Wide and Long] -) - -#table( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - table.cell(rowspan: 2, fill: orange)[*Left*], - [Right A], [Right A], [Right A], - [Right B], table.cell(colspan: 2, rowspan: 2, fill: orange.darken(10%))[B Wide], - [Left A], [Left A], - [Left B], [Left B], table.cell(colspan: 2, rowspan: 3, fill: orange)[Wide and Long] -) - ---- -#grid( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - gutter: 3pt, - grid.cell(rowspan: 2, fill: orange)[*Left*], - [Right A], [Right A], [Right A], - [Right B], grid.cell(colspan: 2, rowspan: 2, fill: orange.darken(10%))[B Wide], - [Left A], [Left A], - [Left B], [Left B], grid.cell(colspan: 2, rowspan: 3, fill: orange)[Wide and Long] -) - -#table( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - gutter: 3pt, - table.cell(rowspan: 2, fill: orange)[*Left*], - [Right A], [Right A], [Right A], - [Right B], table.cell(colspan: 2, rowspan: 2, fill: orange.darken(10%))[B Wide], - [Left A], [Left A], - [Left B], [Left B], table.cell(colspan: 2, rowspan: 3, fill: orange)[Wide and Long] -) - ---- -// Fixed-size rows -#set page(height: 10em) -#grid( - columns: 2, - rows: 1.5em, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - grid.cell(rowspan: 3)[R1], [b], - [c], - [d], - [e], [f], - grid.cell(rowspan: 5)[R2], [h], - [i], - [j], - [k], - [l], - [m], [n] -) - ---- -// Cell coordinate tests -#set page(height: 10em) -#show table.cell: it => [(#it.x, #it.y)] -#table( - columns: 3, - fill: red, - [a], [b], table.cell(rowspan: 2)[c], - table.cell(colspan: 2)[d], - table.cell(colspan: 3, rowspan: 10)[a], - table.cell(colspan: 2)[b], -) -#table( - columns: 3, - gutter: 3pt, - fill: red, - [a], [b], table.cell(rowspan: 2)[c], - table.cell(colspan: 2)[d], - table.cell(colspan: 3, rowspan: 9)[a], - table.cell(colspan: 2)[b], -) - ---- -// Auto row expansion -#set page(height: 10em) -#grid( - columns: (1em, 1em), - rows: (0.5em, 0.5em, auto), - fill: orange, - gutter: 3pt, - grid.cell(rowspan: 4, [x x x x] + place(bottom)[*Bot*]), - [a], - [b], - [c], - [d] -) - ---- -// Excessive rowspan (no gutter) -#set page(height: 10em) -#table( - columns: 4, - fill: red, - [a], [b], table.cell(rowspan: 2)[c], [d], - table.cell(colspan: 2, stroke: (bottom: aqua + 2pt))[e], table.cell(stroke: (bottom: aqua))[f], - table.cell(colspan: 2, rowspan: 10)[R1], table.cell(colspan: 2, rowspan: 10)[R2], - [b], -) - ---- -// Excessive rowspan (with gutter) -#set page(height: 10em) -#table( - columns: 4, - gutter: 3pt, - fill: red, - [a], [b], table.cell(rowspan: 2)[c], [d], - table.cell(colspan: 2, stroke: (bottom: aqua + 2pt))[e], table.cell(stroke: (bottom: aqua))[f], - table.cell(colspan: 2, rowspan: 10)[R1], table.cell(colspan: 2, rowspan: 10)[R2], - [b], -) - ---- -// Fractional rows -// They cause the auto row to expand more than needed. -#set page(height: 10em) -#grid( - fill: red, - gutter: 3pt, - columns: 3, - rows: (1em, auto, 1fr), - [a], [b], grid.cell(rowspan: 3, block(height: 4em, width: 1em, fill: orange)), - [c], [d], - [e], [f] -) - ---- -// Fractional rows -#set page(height: 10em) -#grid( - fill: red, - gutter: 3pt, - columns: 3, - rows: (1fr, auto, 1em), - [a], [b], grid.cell(rowspan: 3, block(height: 4em, width: 1em, fill: orange)), - [c], [d], - [e], [f] -) - ---- -// Cell order -#let count = counter("count") -#show grid.cell: it => { - count.step() - count.display() -} - -#grid( - columns: (2em,) * 3, - stroke: aqua, - rows: 1.2em, - fill: (x, y) => if calc.odd(x + y) { red } else { orange }, - [a], grid.cell(rowspan: 2)[b], grid.cell(rowspan: 2)[c], - [d], - grid.cell(rowspan: 2)[f], [g], [h], - [i], [j], - [k], [l], [m], - grid.cell(rowspan: 2)[n], [o], [p], - [q], [r], - [s], [t], [u] -) - ---- -#table( - columns: 3, - rows: (auto, auto, auto, 2em), - gutter: 3pt, - table.cell(rowspan: 4)[a \ b\ c\ d\ e], [c], [d], - [e], table.cell(breakable: false, rowspan: 2)[f], - [g] -) - ---- -// Test cell breakability -#show grid.cell: it => { - assert.eq(it.breakable, (it.x, it.y) != (0, 6) and (it.y in (2, 5, 6) or (it.x, it.y) in ((0, 1), (2, 3), (1, 7)))) - it.breakable -} -#grid( - columns: 3, - rows: (6pt, 1fr, auto, 1%, 1em, auto, auto, 0.2in), - row-gutter: (0pt, 0pt, 0pt, auto), - [a], [b], [c], - grid.cell(rowspan: 3)[d], [e], [f], - [g], [h], - [i], grid.cell(rowspan: 2)[j], - [k], - grid.cell(y: 5)[l], - grid.cell(y: 6, breakable: false)[m], grid.cell(y: 6, breakable: true)[n], - grid.cell(y: 7, breakable: false)[o], grid.cell(y: 7, breakable: true)[p], grid.cell(y: 7, breakable: auto)[q] -) - ---- -#table( - columns: 2, - table.cell(stroke: (bottom: red))[a], [b], - table.hline(stroke: green), - table.cell(stroke: (top: yellow, left: green, right: aqua, bottom: blue), colspan: 1, rowspan: 2)[d], table.cell(colspan: 1, rowspan: 2)[e], - [f], - [g] -) - ---- -#table( - columns: 2, - gutter: 3pt, - table.cell(stroke: (bottom: red))[a], [b], - table.hline(stroke: green), - table.cell(stroke: (top: yellow, left: green, right: aqua, bottom: blue), colspan: 1, rowspan: 2)[d], table.cell(colspan: 1, rowspan: 2)[e], - [f], - [g] -) - ---- -// Block below shouldn't expand to the end of the page, but stay within its -// rows' boundaries. -#set page(height: 9em) -#table( - rows: (1em, 1em, 1fr, 1fr, auto), - table.cell(rowspan: 2, block(width: 2em, height: 100%, fill: red)), - table.cell(rowspan: 2, block(width: 2em, height: 100%, fill: red)), - [a] -) - ---- -#set page(height: 7em) -#table( - columns: 3, - [], [], table.cell(breakable: true, rowspan: 2, block(width: 2em, height: 100%, fill: red)), - table.cell(breakable: false, block(width: 2em, height: 100%, fill: red)), - table.cell(breakable: false, rowspan: 2, block(width: 2em, height: 100%, fill: red)), -) diff --git a/tests/typ/layout/grid-rowspan-split-1.typ b/tests/typ/layout/grid-rowspan-split-1.typ deleted file mode 100644 index e247fa80..00000000 --- a/tests/typ/layout/grid-rowspan-split-1.typ +++ /dev/null @@ -1,89 +0,0 @@ -// Rowspan split tests - ---- -#set page(height: 10em) -#table( - columns: 2, - rows: (auto, auto, 3em), - fill: red, - [a], table.cell(rowspan: 3, block(width: 50%, height: 10em, fill: orange) + place(bottom)[*ZD*]), - [e], - [f] -) - ---- -#set page(height: 10em) -#table( - columns: 2, - rows: (auto, auto, 3em), - row-gutter: 1em, - fill: red, - [a], table.cell(rowspan: 3, block(width: 50%, height: 10em, fill: orange) + place(bottom)[*ZD*]), - [e], - [f] -) - ---- -#set page(height: 5em) -#table( - columns: 2, - fill: red, - inset: 0pt, - table.cell(fill: orange, rowspan: 10, place(bottom)[*Z*] + [x\ ] * 10 + place(bottom)[*ZZ*]), - ..([y],) * 10, - [a], [b], -) - ---- -#set page(height: 5em) -#table( - columns: 2, - fill: red, - inset: 0pt, - gutter: 2pt, - table.cell(fill: orange, rowspan: 10, place(bottom)[*Z*] + [x\ ] * 10 + place(bottom)[*ZZ*]), - ..([y],) * 10, - [a], [b], -) - ---- -#set page(height: 5em) -#table( - columns: 2, - fill: red, - inset: 0pt, - table.cell(fill: orange, rowspan: 10, breakable: false, place(bottom)[*Z*] + [x\ ] * 10 + place(bottom)[*ZZ*]), - ..([y],) * 10, - [a], [b], -) - ---- -#set page(height: 5em) -#table( - columns: 2, - fill: red, - inset: 0pt, - gutter: 2pt, - table.cell(fill: orange, rowspan: 10, breakable: false, place(bottom)[*Z*] + [x\ ] * 10 + place(bottom)[*ZZ*]), - ..([y],) * 10, - [a], [b], -) - ---- -#set page(height: 5em) -#grid( - columns: 2, - stroke: red, - inset: 5pt, - grid.cell(rowspan: 5)[a\ b\ c\ d\ e] -) - ---- -#set page(height: 5em) -#table( - columns: 2, - gutter: 3pt, - stroke: red, - inset: 5pt, - table.cell(rowspan: 5)[a\ b\ c\ d\ e] -) diff --git a/tests/typ/layout/grid-rowspan-split-2.typ b/tests/typ/layout/grid-rowspan-split-2.typ deleted file mode 100644 index 189feed3..00000000 --- a/tests/typ/layout/grid-rowspan-split-2.typ +++ /dev/null @@ -1,37 +0,0 @@ -// Rowspan split without ending at the auto row - ---- -#set page(height: 6em) -#table( - rows: (4em,) * 7 + (auto,) + (4em,) * 7, - columns: 2, - column-gutter: 1em, - row-gutter: (1em, 2em) * 4, - fill: (x, y) => if calc.odd(x + y) { orange.lighten(20%) } else { red }, - table.cell(rowspan: 15, [a \ ] * 15), - [] * 15 -) - ---- -#set page(height: 6em) -#table( - rows: (4em,) * 7 + (auto,) + (4em,) * 7, - columns: 2, - column-gutter: 1em, - row-gutter: (1em, 2em) * 4, - fill: (x, y) => if calc.odd(x + y) { green } else { green.darken(40%) }, - table.cell(rowspan: 15, block(fill: blue, width: 2em, height: 4em * 14 + 3em)), - [] * 15 -) - ---- -#set page(height: 6em) -#table( - rows: (3em,) * 15, - columns: 2, - column-gutter: 1em, - row-gutter: (1em, 2em) * 4, - fill: (x, y) => if calc.odd(x + y) { aqua } else { blue }, - table.cell(breakable: true, rowspan: 15, [a \ ] * 15), - [] * 15 -) diff --git a/tests/typ/layout/grid-rowspan-split-3.typ b/tests/typ/layout/grid-rowspan-split-3.typ deleted file mode 100644 index 4c3ce7d8..00000000 --- a/tests/typ/layout/grid-rowspan-split-3.typ +++ /dev/null @@ -1,108 +0,0 @@ -// Some splitting corner cases - ---- -// Inside the larger rowspan's range, there's an unbreakable rowspan and a -// breakable rowspan. This should work normally. -// The auto row will also expand ignoring the last fractional row. -#set page(height: 10em) -#table( - gutter: 0.5em, - columns: 2, - rows: (2em,) * 10 + (auto, auto, 2em, 1fr), - fill: (_, y) => if calc.even(y) { aqua } else { blue }, - table.cell(rowspan: 14, block(width: 2em, height: 2em * 10 + 2em + 5em, fill: red)[]), - ..([a],) * 5, - table.cell(rowspan: 3)[a\ b], - table.cell(rowspan: 5, [a\ b\ c\ d\ e\ f\ g\ h]), - [z] -) - ---- -// Inset moving to next region bug -#set page(width: 10cm, height: 2.5cm, margin: 0.5cm) -#set text(size: 11pt) -#table( - columns: (1fr, 1fr, 1fr), - [A], - [B], - [C], - [D], - table.cell(rowspan: 2, lorem(4)), - [E], - [F], - [G], -) - ---- -// Second lorem must be sent to the next page, too big -#set page(width: 10cm, height: 9cm, margin: 1cm) -#set text(size: 11pt) -#table( - columns: (1fr, 1fr, 1fr), - align: center, - rows: (4cm, auto), - [A], [B], [C], - table.cell(rowspan: 4, breakable: false, lorem(10)), - [D], - table.cell(rowspan: 2, breakable: false, lorem(20)), - [E], -) - ---- -// Auto row must expand properly in both cases -#set text(10pt) -#show table.cell: it => if it.x == 0 { it } else { layout(size => size.height) } -#table( - columns: 2, - rows: (1em, auto, 2em, 3em, 4em), - gutter: 3pt, - table.cell(rowspan: 5, block(fill: orange, height: 15em)[a]), - [b], - [c], - [d], - [e], - [f] -) - -#table( - columns: 2, - rows: (1em, auto, 2em, 3em, 4em), - gutter: 3pt, - table.cell(rowspan: 5, breakable: false, block(fill: orange, height: 15em)[a]), - [b], - [c], - [d], - [e], - [f] -) - ---- -// Expanding on unbreakable auto row -#set page(height: 7em, margin: (bottom: 2em)) -#grid( - columns: 2, - rows: (1em, 1em, auto, 1em, 1em, 1em), - fill: (x, y) => if x == 0 { aqua } else { blue }, - stroke: black, - gutter: 2pt, - grid.cell(rowspan: 5, block(height: 10em)[a]), - [a], - [b], - grid.cell(breakable: false, v(3em) + [c]), - [d], - [e], - [f], [g] -) - ---- -#show table.cell.where(x: 0): strong -#show table.cell.where(y: 0): strong -#set page(height: 13em) -#let lets-repeat(thing, n) = ((thing + colbreak(),) * (calc.max(0, n - 1)) + (thing,)).join() -#table( - columns: 4, - fill: (x, y) => if x == 0 or y == 0 { gray }, - [], [Test 1], [Test 2], [Test 3], - table.cell(rowspan: 15, align: horizon, lets-repeat((rotate(-90deg, reflow: true)[*All Tests*]), 3)), - ..([123], [456], [789]) * 15 -) diff --git a/tests/typ/layout/grid-rtl.typ b/tests/typ/layout/grid-rtl.typ deleted file mode 100644 index cea67d96..00000000 --- a/tests/typ/layout/grid-rtl.typ +++ /dev/null @@ -1,195 +0,0 @@ -// Test RTL grid. - ---- -#set text(dir: rtl) -- מימין לשמאל - ---- -#set text(dir: rtl) -#table(columns: 2)[A][B][C][D] - ---- -// Test interaction between RTL and colspans -#set text(dir: rtl) -#grid( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - grid.cell(colspan: 4)[*Full Header*], - grid.cell(colspan: 2, fill: orange)[*Half*], - grid.cell(colspan: 2, fill: orange.darken(10%))[*Half*], - [*A*], [*B*], [*C*], [*D*], - [1], [2], [3], [4], - [5], grid.cell(colspan: 3, fill: orange.darken(10%))[6], - grid.cell(colspan: 2, fill: orange)[7], [8], [9], - [10], grid.cell(colspan: 2, fill: orange.darken(10%))[11], [12] -) - -#grid( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - gutter: 3pt, - grid.cell(colspan: 4)[*Full Header*], - grid.cell(colspan: 2, fill: orange)[*Half*], - grid.cell(colspan: 2, fill: orange.darken(10%))[*Half*], - [*A*], [*B*], [*C*], [*D*], - [1], [2], [3], [4], - [5], grid.cell(colspan: 3, fill: orange.darken(10%))[6], - grid.cell(colspan: 2, fill: orange)[7], [8], [9], - [10], grid.cell(colspan: 2, fill: orange.darken(10%))[11], [12] -) - ---- -#set text(dir: rtl) -#table( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - table.cell(colspan: 4)[*Full Header*], - table.cell(colspan: 2, fill: orange)[*Half*], - table.cell(colspan: 2, fill: orange.darken(10%))[*Half*], - [*A*], [*B*], [*C*], [*D*], - [1], [2], [3], [4], - [5], table.cell(colspan: 3, fill: orange.darken(10%))[6], - table.cell(colspan: 2, fill: orange)[7], [8], [9], - [10], table.cell(colspan: 2, fill: orange.darken(10%))[11], [12] -) - -#table( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - gutter: 3pt, - table.cell(colspan: 4)[*Full Header*], - table.cell(colspan: 2, fill: orange)[*Half*], - table.cell(colspan: 2, fill: orange.darken(10%))[*Half*], - [*A*], [*B*], [*C*], [*D*], - [1], [2], [3], [4], - [5], table.cell(colspan: 3, fill: orange.darken(10%))[6], - table.cell(colspan: 2, fill: orange)[7], [8], [9], - [10], table.cell(colspan: 2, fill: orange.darken(10%))[11], [12] -) - ---- -// Test multiple regions -#set page(height: 5em) -#set text(dir: rtl) -#grid( - stroke: red, - fill: aqua, - columns: 4, - [a], [b], [c], [d], - [a], grid.cell(colspan: 2)[e, f, g, h, i], [f], - [e], [g], grid.cell(colspan: 2)[eee\ e\ e\ e], - grid.cell(colspan: 4)[eeee e e e] -) - ---- -// Test left and right for vlines in RTL -#set text(dir: rtl) -#grid( - columns: 3, - inset: 5pt, - grid.vline(stroke: red, position: left), grid.vline(stroke: green, position: right), [a], - grid.vline(stroke: red, position: left), grid.vline(stroke: 2pt, position: right), [b], - grid.vline(stroke: red, position: left), grid.vline(stroke: 2pt, position: right), [c], - grid.vline(stroke: aqua, position: right) -) - -#grid( - columns: 3, - inset: 5pt, - gutter: 3pt, - grid.vline(stroke: green, position: left), grid.vline(stroke: red, position: right), [a], - grid.vline(stroke: blue, position: left), grid.vline(stroke: red, position: right), [b], - grid.vline(stroke: blue, position: left), grid.vline(stroke: red, position: right), [c], - grid.vline(stroke: 2pt, position: right) -) - -#grid( - columns: 3, - inset: 5pt, - grid.vline(stroke: green, position: start), grid.vline(stroke: red, position: end), [a], - grid.vline(stroke: 2pt, position: start), grid.vline(stroke: red, position: end), [b], - grid.vline(stroke: 2pt, position: start), grid.vline(stroke: red, position: end), [c], - grid.vline(stroke: 2pt, position: start) -) - -#grid( - columns: 3, - inset: 5pt, - gutter: 3pt, - grid.vline(stroke: green, position: start), grid.vline(stroke: red, position: end), [a], - grid.vline(stroke: blue, position: start), grid.vline(stroke: red, position: end), [b], - grid.vline(stroke: blue, position: start), grid.vline(stroke: red, position: end), [c], - grid.vline(stroke: 2pt, position: start) -) - ---- -// Error: 3:8-3:34 cannot place vertical line at the 'end' position of the end border (x = 1) -// Hint: 3:8-3:34 set the line's position to 'start' or place it at a smaller 'x' index -#set text(dir: rtl) -#grid( - [a], grid.vline(position: left) -) - ---- -#set text(dir: rtl) - -#grid( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - grid.cell(rowspan: 2, fill: orange)[*Left*], - [Right A], [Right A], [Right A], - [Right B], grid.cell(colspan: 2, rowspan: 2, fill: orange.darken(10%))[B Wide], - [Left A], [Left A], - [Left B], [Left B], grid.cell(colspan: 2, rowspan: 3, fill: orange)[Wide and Long] -) - -#table( - columns: 4, - fill: (x, y) => if calc.odd(x + y) { blue.lighten(50%) } else { blue.lighten(10%) }, - inset: 5pt, - align: center, - gutter: 3pt, - table.cell(rowspan: 2, fill: orange)[*Left*], - [Right A], [Right A], [Right A], - [Right B], table.cell(colspan: 2, rowspan: 2, fill: orange.darken(10%))[B Wide], - [Left A], [Left A], - [Left B], [Left B], table.cell(colspan: 2, rowspan: 3, fill: orange)[Wide and Long] -) - ---- -#set page(height: 10em) -#set text(dir: rtl) -#table( - columns: 2, - rows: (auto, auto, 3em), - row-gutter: 1em, - fill: red, - [a], table.cell(rowspan: 3, block(width: 50%, height: 10em, fill: orange) + place(bottom)[*ZD*]), - [e], - [f] -) - ---- -// Headers -#set page(height: 15em) -#set text(dir: rtl) -#table( - columns: 5, - align: center + horizon, - table.header( - table.cell(colspan: 5)[*Cool Zone*], - table.cell(stroke: red)[*N1*], table.cell(stroke: aqua)[*N2*], [*D1*], [*D2*], [*Etc*], - table.hline(start: 2, end: 3, stroke: yellow) - ), - ..range(0, 10).map(i => ([\##i], table.cell(stroke: green)[123], table.cell(stroke: blue)[456], [789], [?], table.hline(start: 4, end: 5, stroke: red))).flatten() -) diff --git a/tests/typ/layout/grid-stroke.typ b/tests/typ/layout/grid-stroke.typ deleted file mode 100644 index 35a65ae6..00000000 --- a/tests/typ/layout/grid-stroke.typ +++ /dev/null @@ -1,434 +0,0 @@ -#let double-line = pattern(size: (1.5pt, 1.5pt), { - place(line(stroke: .6pt, start: (0%, 50%), end: (100%, 50%))) -}) - -#table( - stroke: (_, y) => if y != 1 { (bottom: black) }, - columns: 3, - table.cell(colspan: 3, align: center)[*Epic Table*], - align(center)[*Name*], align(center)[*Age*], align(center)[*Data*], - table.hline(stroke: (paint: double-line, thickness: 2pt)), - [John], [30], [None], - [Martha], [20], [A], - [Joseph], [35], [D] -) - ---- -// Test folding -#set grid(stroke: red) -#set grid(stroke: 5pt) - -#grid( - inset: 10pt, - columns: 2, - stroke: stroke(dash: "loosely-dotted"), - grid.vline(start: 2, end: 3, stroke: (paint: green, dash: none)), - [a], [b], - grid.hline(end: 1, stroke: blue), - [c], [d], - [e], grid.cell(stroke: aqua)[f] -) - ---- -// Test set rules on cells and folding -#set table.cell(stroke: 4pt) -#set table.cell(stroke: blue) -#set table.hline(stroke: red) -#set table.hline(stroke: 0.75pt) -#set table.vline(stroke: 0.75pt) -#set table.vline(stroke: aqua) - -#table( - columns: 3, - gutter: 3pt, - inset: 5pt, - [a], [b], table.vline(position: end), [c], - [d], [e], [f], - table.hline(position: bottom), - [g], [h], [i], -) - ---- -// Test stroke field on cell show rules -#set grid.cell(stroke: (x: 4pt)) -#set grid.cell(stroke: (x: blue)) -#show grid.cell: it => { - test(it.stroke, (left: stroke(paint: blue, thickness: 4pt, dash: "loosely-dotted"), right: blue + 4pt, top: stroke(thickness: 1pt), bottom: none)) - it -} -#grid( - stroke: (left: (dash: "loosely-dotted")), - inset: 5pt, - grid.hline(stroke: red), - grid.cell(stroke: (top: 1pt))[a], grid.vline(stroke: yellow), -) - ---- -#table( - columns: 3, - [a], table.cell(colspan: 2)[b c], - table.cell(stroke: blue)[d], [e], [f], - [g], [h], table.cell(stroke: (left: yellow, top: green, right: aqua, bottom: red))[i], - [j], [k], [l], - table.cell(stroke: 3pt)[m], [n], table.cell(stroke: (dash: "loosely-dotted"))[o], -) - ---- -// Test per-column stroke array -#let t = table( - columns: 3, - stroke: (red, blue, green), - [a], [b], [c], - [d], [e], [f], - [h], [i], [j], -) -#t -#set text(dir: rtl) -#t - ---- -#grid( - columns: 3, - inset: 3pt, - stroke: (x, _) => (right: (5pt, (dash: "dotted")).at(calc.rem(x, 2)), bottom: (dash: "densely-dotted")), - grid.vline(x: 0, stroke: red), - grid.vline(x: 1, stroke: red), - grid.vline(x: 2, stroke: red), - grid.vline(x: 3, stroke: red), - grid.hline(y: 0, end: 1, stroke: blue), - grid.hline(y: 1, end: 1, stroke: blue), - grid.cell[a], - [b], [c] -) - ---- -#set page(height: 5em) -#table( - columns: 3, - inset: 3pt, - table.hline(y: 0, end: none, stroke: 3pt + blue), - table.vline(x: 0, end: none, stroke: 3pt + green), - table.hline(y: 5, end: none, stroke: 3pt + red), - table.vline(x: 3, end: none, stroke: 3pt + yellow), - [a], [b], [c], - [a], [b], [c], - [a], [b], [c], - [a], [b], [c], - [a], [b], [c], -) - ---- -// Automatically positioned lines -// Plus stroke thickness ordering -#table( - columns: 3, - table.hline(stroke: red + 5pt), - table.vline(stroke: blue + 5pt), - table.vline(stroke: 2pt), - [a], - table.vline(x: 1, stroke: aqua + 5pt), - [b], - table.vline(stroke: aqua + 5pt), - [c], - table.vline(stroke: yellow + 5.2pt), - table.hline(stroke: green + 5pt), - [a], [b], [c], - [a], table.hline(stroke: green + 2pt), table.vline(stroke: 2pt), [b], [c], -) - ---- -// Line specification order priority -// The last line should be blue, not red. -// The middle aqua line should be gone due to the 'none' override. -#grid( - columns: 2, - inset: 2pt, - grid.hline(y: 2, stroke: red + 5pt), - grid.vline(), - [a], [b], - grid.hline(stroke: red), - grid.hline(stroke: none), - [c], grid.cell(stroke: (top: aqua))[d], - grid.hline(stroke: blue), -) - ---- -// Position: bottom and position: end with gutter should have a visible effect -// of moving the lines after the next track. -#table( - columns: 3, - gutter: 3pt, - stroke: blue, - table.hline(end: 2, stroke: red), - table.hline(end: 2, stroke: aqua, position: bottom), - table.vline(end: 2, stroke: green), [a], table.vline(end: 2, stroke: green), table.vline(end: 2, position: end, stroke: orange), [b], table.vline(end: 2, stroke: aqua, position: end), table.vline(end: 2, stroke: green), [c], table.vline(end: 2, stroke: green), - [d], [e], [f], - table.hline(end: 2, stroke: red), - [g], [h], [ie], - table.hline(end: 2, stroke: green), -) - ---- -// Using position: bottom and position: end without gutter should be the same -// as placing a line after the next track. -#table( - columns: 3, - stroke: blue, - table.hline(end: 2, stroke: red), - table.hline(end: 2, stroke: aqua, position: bottom), - table.vline(end: 2, stroke: green), [a], table.vline(end: 2, stroke: green), [b], table.vline(end: 2, stroke: aqua, position: end), table.vline(end: 2, stroke: green), [c], table.vline(end: 2, stroke: green), - table.hline(end: 2, stroke: 5pt), - [d], [e], [f], - table.hline(end: 2, stroke: red), - [g], [h], [i], - table.hline(end: 2, stroke: red), -) - ---- -// Test left and right for grid vlines. -#grid( - columns: 3, - inset: 5pt, - grid.vline(stroke: green, position: left), grid.vline(stroke: red, position: right), [a], - grid.vline(stroke: 2pt, position: left), grid.vline(stroke: red, position: right), [b], - grid.vline(stroke: 2pt, position: left), grid.vline(stroke: red, position: right), [c], - grid.vline(stroke: 2pt, position: left) -) - -#grid( - columns: 3, - inset: 5pt, - gutter: 3pt, - grid.vline(stroke: green, position: left), grid.vline(stroke: red, position: right), [a], - grid.vline(stroke: blue, position: left), grid.vline(stroke: red, position: right), [b], - grid.vline(stroke: blue, position: left), grid.vline(stroke: red, position: right), [c], - grid.vline(stroke: 2pt, position: left) -) - ---- -// Test left and right for table vlines. -#table( - columns: 3, - inset: 5pt, - table.vline(stroke: green, position: left), table.vline(stroke: red, position: right), [a], - table.vline(stroke: 2pt, position: left), table.vline(stroke: red, position: right), [b], - table.vline(stroke: 2pt, position: left), table.vline(stroke: red, position: right), [c], - table.vline(stroke: 2pt, position: left) -) - -#table( - columns: 3, - inset: 5pt, - gutter: 3pt, - table.vline(stroke: green, position: left), table.vline(stroke: red, position: right), [a], - table.vline(stroke: blue, position: left), table.vline(stroke: red, position: right), [b], - table.vline(stroke: blue, position: left), table.vline(stroke: red, position: right), [c], - table.vline(stroke: 2pt, position: left) -) - ---- -// Hlines and vlines should always appear on top of cell strokes. -#table( - columns: 3, - stroke: aqua, - table.vline(stroke: red, position: end), [a], table.vline(stroke: red), [b], [c], - table.cell(stroke: blue)[d], [e], [f], - table.hline(stroke: red), - [g], table.cell(stroke: blue)[h], [i], -) - -#table( - columns: 3, - gutter: 3pt, - stroke: aqua, - table.vline(stroke: red, position: end), [a], table.vline(stroke: red), [b], [c], - table.cell(stroke: blue)[d], [e], [f], - table.hline(stroke: red), - [g], table.cell(stroke: blue)[h], [i], -) - ---- -// Ensure cell stroke overrides always appear on top. -#table( - columns: 2, - stroke: black, - table.cell(stroke: red)[a], [b], - [c], [d], -) - -#table( - columns: 2, - table.cell(stroke: red)[a], [b], - [c], [d], -) - ---- -// Error: 7:3-7:32 cannot place horizontal line at the 'bottom' position of the bottom border (y = 2) -// Hint: 7:3-7:32 set the line's position to 'top' or place it at a smaller 'y' index -#table( - columns: 2, - [a], [b], - [c], [d], - table.hline(stroke: aqua), - table.hline(position: top), - table.hline(position: bottom) -) - ---- -// Test partial border line overrides -#set page(width: auto, height: 7em, margin: (bottom: 1em)) -#table( - columns: 4, - stroke: (x, y) => if y == 0 or y == 4 { orange } else { aqua }, - table.hline(stroke: blue, start: 1, end: 2), table.cell(stroke: red, v(3em)), table.cell(stroke: blue)[b], table.cell(stroke: green)[c], [M], - [a], [b], [c], [M], - [d], [e], [f], [M], - [g], [h], [i], [M], - table.cell(stroke: red)[a], table.cell(stroke: blue)[b], table.cell(stroke: green)[c], [M], - table.hline(stroke: blue, start: 1, end: 2), -) - ---- -// - Vline should be placed after the colspan. -// - Hline should be placed under the full-width rowspan. -#table( - columns: 3, - rows: 1.25em, - inset: 1pt, - stroke: none, - table.cell(colspan: 2)[a], table.vline(stroke: red), table.hline(stroke: blue), [b], - [c], [d], [e], - table.cell(colspan: 3, rowspan: 2)[a], table.vline(stroke: blue), table.hline(stroke: red) -) - ---- -// Red line should be above [c] (hline skips the shortest rowspan). -#set text(6pt) -#table( - rows: 1em, - columns: 2, - inset: 1.5pt, - table.cell(rowspan: 3)[a], table.cell(rowspan: 2)[b], - table.hline(stroke: red), - [c] -) - ---- -// Error: 8:3-8:32 cannot place horizontal line at the 'bottom' position of the bottom border (y = 2) -// Hint: 8:3-8:32 set the line's position to 'top' or place it at a smaller 'y' index -#table( - columns: 2, - gutter: 3pt, - [a], [b], - [c], [d], table.vline(stroke: red), - table.hline(stroke: aqua), - table.hline(position: top), - table.hline(position: bottom) -) - ---- -// Error: 6:3-6:28 cannot place vertical line at the 'end' position of the end border (x = 2) -// Hint: 6:3-6:28 set the line's position to 'start' or place it at a smaller 'x' index -#grid( - columns: 2, - [a], [b], - grid.vline(stroke: aqua), - grid.vline(position: start), - grid.vline(position: end) -) - ---- -// Error: 7:3-7:28 cannot place vertical line at the 'end' position of the end border (x = 2) -// Hint: 7:3-7:28 set the line's position to 'start' or place it at a smaller 'x' index -#grid( - columns: 2, - gutter: 3pt, - [a], [b], - grid.vline(stroke: aqua), - grid.vline(position: start), - grid.vline(position: end) -) - ---- -// Error: 4:3-4:19 cannot place horizontal line at invalid row 3 -#grid( - [a], - [b], - grid.hline(y: 3) -) - ---- -// Error: 5:3-5:19 cannot place horizontal line at invalid row 3 -#grid( - gutter: 3pt, - [a], - [b], - grid.hline(y: 3) -) - ---- -// Error: 4:3-4:20 cannot place vertical line at invalid column 3 -#table( - columns: 2, - [a], [b], - table.vline(x: 3) -) - ---- -// Error: 5:3-5:20 cannot place vertical line at invalid column 3 -#table( - columns: 2, - gutter: 3pt, - [a], [b], - table.vline(x: 3) -) - ---- -// Error: 7-20 cannot use `table.hline` as a grid line; use `grid.hline` instead -#grid(table.hline()) - ---- -// Error: 7-20 cannot use `table.vline` as a grid line; use `grid.vline` instead -#grid(table.vline()) - ---- -// Error: 8-20 cannot use `grid.hline` as a table line; use `table.hline` instead -#table(grid.hline()) - ---- -// Error: 8-20 cannot use `grid.vline` as a table line; use `table.vline` instead -#table(grid.vline()) - ---- -// Error: 3:3-3:31 line cannot end before it starts -#grid( - columns: 3, - grid.hline(start: 2, end: 1), - [a], [b], [c], -) - ---- -// Error: 3:3-3:32 line cannot end before it starts -#table( - columns: 3, - table.vline(start: 2, end: 1), - [a], [b], [c], - [d], [e], [f], - [g], [h], [i], -) - ---- -// Error: 24-31 expected `top` or `bottom`, found horizon -#table.hline(position: horizon) - ---- -// Error: 24-30 expected `start`, `left`, `right`, or `end`, found center -#table.vline(position: center) - ---- -// Error: 24-29 expected `top` or `bottom`, found right -#table.hline(position: right) - ---- -// Error: 24-27 expected `start`, `left`, `right`, or `end`, found top -#table.vline(position: top) diff --git a/tests/typ/layout/grid-styling.typ b/tests/typ/layout/grid-styling.typ deleted file mode 100644 index f83c3cc4..00000000 --- a/tests/typ/layout/grid-styling.typ +++ /dev/null @@ -1,160 +0,0 @@ -// Test grid styling options. - ---- -#set page(height: 70pt) -#set grid(fill: (x, y) => if calc.even(x + y) { rgb("aaa") }) - -#grid( - columns: (1fr,) * 3, - stroke: 2pt + rgb("333"), - [A], [B], [C], [], [], [D \ E \ F \ \ \ G], [H], -) - ---- -#grid(columns: 3, stroke: none, fill: green, [A], [B], [C]) - ---- -// Test general alignment. -#grid( - columns: 3, - align: left, - [Hello], [Hello], [Hello], - [A], [B], [C], -) - -// Test alignment with a function. -#grid( - columns: 3, - align: (x, y) => (left, center, right).at(x), - [Hello], [Hello], [Hello], - [A], [B], [C], -) - -// Test alignment with array. -#grid( - columns: (1fr, 1fr, 1fr), - align: (left, center, right), - [A], [B], [C] -) - -// Test empty array. -#set align(center) -#grid( - columns: (1fr, 1fr, 1fr), - align: (), - [A], [B], [C] -) - -a - ---- -// Test inset. -#grid( - columns: (1fr,) * 3, - stroke: 2pt + rgb("333"), - inset: 5pt, - [A], [B], [C], [], [], [D \ E \ F \ \ \ G], [H], -) - -#grid( - columns: 3, - inset: 10pt, - fill: blue, - [A], [B], [C] -) - -#grid( - columns: 3, - inset: (y: 10pt), - [A], [B], [C] -) - -#grid( - columns: 3, - inset: (left: 20pt, rest: 10pt), - stroke: 3pt + red, - [A], [B], [C] -) - -#grid( - columns: 2, - inset: ( - left: 20pt, - right: 5pt, - top: 10pt, - bottom: 3pt, - ), - [A], - [B], -) - -#grid( - columns: 3, - fill: (x, y) => (if y == 0 { aqua } else { orange }).darken(x * 15%), - inset: (x, y) => (left: if x == 0 { 0pt } else { 5pt }, right: if x == 0 { 5pt } else { 0pt }, y: if y == 0 { 0pt } else { 5pt }), - [A], [B], [C], - [A], [B], [C], -) - -#grid( - columns: 3, - inset: (0pt, 5pt, 10pt), - fill: (x, _) => aqua.darken(x * 15%), - [A], [B], [C], -) - ---- -// Test inset folding -#set grid(inset: 10pt) -#set grid(inset: (left: 0pt)) - -#grid( - fill: red, - inset: (right: 0pt), - grid.cell(inset: (top: 0pt))[a] -) - ---- -// Test interaction with gutters. -#grid( - columns: (3em, 3em), - fill: (x, y) => (red, blue).at(calc.rem(x, 2)), - align: (x, y) => (left, right).at(calc.rem(y, 2)), - [A], [B], - [C], [D], - [E], [F], - [G], [H] -) - -#grid( - columns: (3em, 3em), - fill: (x, y) => (red, blue).at(calc.rem(x, 2)), - align: (x, y) => (left, right).at(calc.rem(y, 2)), - row-gutter: 5pt, - [A], [B], - [C], [D], - [E], [F], - [G], [H] -) - -#grid( - columns: (3em, 3em), - fill: (x, y) => (red, blue).at(calc.rem(x, 2)), - align: (x, y) => (left, right).at(calc.rem(y, 2)), - column-gutter: 5pt, - [A], [B], - [C], [D], - [E], [F], - [G], [H] -) - -#grid( - columns: (3em, 3em), - fill: (x, y) => (red, blue).at(calc.rem(x, 2)), - align: (x, y) => (left, right).at(calc.rem(y, 2)), - gutter: 5pt, - [A], [B], - [C], [D], - [E], [F], - [G], [H] -) diff --git a/tests/typ/layout/hide.typ b/tests/typ/layout/hide.typ deleted file mode 100644 index ede65c70..00000000 --- a/tests/typ/layout/hide.typ +++ /dev/null @@ -1,76 +0,0 @@ -// Test the `hide` function. - ---- -AB #h(1fr) CD \ -#hide[A]B #h(1fr) C#hide[D] ---- -Hidden: -#hide[#line(length: 100%)] -#line(length: 100%) ---- -Hidden: -#hide(table(rows: 2, columns: 2)[a][b][c][d]) -#table(rows: 2, columns: 2)[a][b][c][d] ---- -Hidden: -#hide[ - #polygon((20%, 0pt), - (60%, 0pt), - (80%, 2cm), - (0%, 2cm),) -] -#polygon((20%, 0pt), - (60%, 0pt), - (80%, 2cm), - (0%, 2cm),) ---- -#set rect( - inset: 8pt, - fill: rgb("e4e5ea"), - width: 100%, -) - -Hidden: -#hide[ -#grid( - columns: (1fr, 1fr, 2fr), - rows: (auto, 40pt), - gutter: 3pt, - rect[A], - rect[B], - rect[C], - rect(height: 100%)[D], -) -] -#grid( - columns: (1fr, 1fr, 2fr), - rows: (auto, 40pt), - gutter: 3pt, - rect[A], - rect[B], - rect[C], - rect(height: 100%)[D], -) ---- - -Hidden: -#hide[ -- 1 -- 2 - 1. A - 2. B -- 3 -] - - -- 1 -- 2 - 1. A - 2. B -- 3 - ---- -Hidden: -#hide(image("/assets/images/tiger.jpg", width: 5cm, height: 1cm,)) - -#image("/assets/images/tiger.jpg", width: 5cm, height: 1cm,) diff --git a/tests/typ/layout/list-attach.typ b/tests/typ/layout/list-attach.typ deleted file mode 100644 index 9d043eb0..00000000 --- a/tests/typ/layout/list-attach.typ +++ /dev/null @@ -1,54 +0,0 @@ -// Test list attaching. - ---- -// Test basic attached list. -Attached to: -- the bottom -- of the paragraph - -Next paragraph. - ---- -// Test that attached list isn't affected by block spacing. -#show list: set block(above: 100pt) -Hello -- A -World -- B - ---- -// Test non-attached list followed by attached list, -// separated by only word. -Hello - -- A - -World -- B - ---- -// Test non-attached tight list. -#set block(spacing: 15pt) -Hello -- A -World - -- B -- C - -More. - ---- -// Test that wide lists cannot be ... -#set block(spacing: 15pt) -Hello -- A - -- B -World - ---- -// ... even if forced to. -Hello -#list(tight: false)[A][B] -World diff --git a/tests/typ/layout/list-marker.typ b/tests/typ/layout/list-marker.typ deleted file mode 100644 index 9e28faad..00000000 --- a/tests/typ/layout/list-marker.typ +++ /dev/null @@ -1,34 +0,0 @@ -// Test list marker configuration. - ---- -// Test en-dash. -#set list(marker: [--]) -- A -- B - ---- -// Test that items are cycled. -#set list(marker: ([--], [•])) -- A - - B - - C - ---- -// Test function. -#set list(marker: n => if n == 1 [--] else [•]) -- A -- B - - C - - D - - E -- F - ---- -// Test that bare hyphen doesn't lead to cycles and crashes. -#set list(marker: [-]) -- Bare hyphen is -- a bad marker - ---- -// Error: 19-21 array must contain at least one marker -#set list(marker: ()) diff --git a/tests/typ/layout/list.typ b/tests/typ/layout/list.typ deleted file mode 100644 index 7b938944..00000000 --- a/tests/typ/layout/list.typ +++ /dev/null @@ -1,57 +0,0 @@ -// Test bullet lists. - ---- -_Shopping list_ -#list[Apples][Potatoes][Juice] - ---- -- 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 content block -] - ---- - - 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 - ---- -// Edge cases. -- -Not in list --Nope - ---- -// Alignment shouldn't affect marker -#set align(horizon) - -- ABCDEF\ GHIJKL\ MNOPQR diff --git a/tests/typ/layout/out-of-flow-in-block.typ b/tests/typ/layout/out-of-flow-in-block.typ deleted file mode 100644 index 2461aa5d..00000000 --- a/tests/typ/layout/out-of-flow-in-block.typ +++ /dev/null @@ -1,61 +0,0 @@ -// Test out-of-flow items (place, counter updates, etc.) at the -// beginning of a block not creating a frame just for them. - ---- -// No item in the first region. -#set page(height: 5cm, margin: 1cm) -No item in the first region. -#block(breakable: true, stroke: 1pt, inset: 0.5cm)[ - #rect(height: 2cm, fill: gray) -] - ---- -// Counter update in the first region. -#set page(height: 5cm, margin: 1cm) -Counter update. -#block(breakable: true, stroke: 1pt, inset: 0.5cm)[ - #counter("dummy").step() - #rect(height: 2cm, fill: gray) -] - ---- -// Placed item in the first region. -#set page(height: 5cm, margin: 1cm) -Placed item in the first region. -#block(breakable: true, above: 1cm, stroke: 1pt, inset: 0.5cm)[ - #place(dx: -0.5cm, dy: -0.75cm, box(width: 200%)[OOF]) - #rect(height: 2cm, fill: gray) -] - ---- -// In-flow item with size zero in the first region. -#set page(height: 5cm, margin: 1cm) -In-flow, zero-sized item. -#block(breakable: true, stroke: 1pt, inset: 0.5cm)[ - #set block(spacing: 0pt) - #line(length: 0pt) - #rect(height: 2cm, fill: gray) - #line(length: 100%) -] - ---- -// Counter update and placed item in the first region. -#set page(height: 5cm, margin: 1cm) -Counter update + place. -#block(breakable: true, above: 1cm, stroke: 1pt, inset: 0.5cm)[ - #counter("dummy").step() - #place(dx: -0.5cm, dy: -0.75cm, box([OOF])) - #rect(height: 2cm, fill: gray) -] - ---- -// Mix-and-match all the previous ones. -#set page(height: 5cm, margin: 1cm) -Mix-and-match all the previous tests. -#block(breakable: true, above: 1cm, stroke: 1pt, inset: 0.5cm)[ - #counter("dummy").step() - #place(dx: -0.5cm, dy: -0.75cm, box(width: 200%)[OOF]) - #line(length: 100%) - #place(dy: -0.8em)[OOF] - #rect(height: 2cm, fill: gray) -] diff --git a/tests/typ/layout/pad.typ b/tests/typ/layout/pad.typ deleted file mode 100644 index 0eff5876..00000000 --- a/tests/typ/layout/pad.typ +++ /dev/null @@ -1,30 +0,0 @@ -// Test the `pad` function. - ---- -// Use for indentation. -#pad(left: 10pt, [Indented!]) - -// All sides together. -#set rect(inset: 0pt) -#rect(fill: conifer, - pad(10pt, right: 20pt, - rect(width: 20pt, height: 20pt, fill: rgb("eb5278")) - ) -) - -Hi #box(pad(left: 10pt)[A]) there - ---- -// Pad can grow. -#pad(left: 10pt, right: 10pt)[PL #h(1fr) PR] - ---- -// Test that the pad element doesn't consume the whole region. -#set page(height: 6cm) -#align(left)[Before] -#pad(10pt, image("/assets/images/tiger.jpg")) -#align(right)[After] - ---- -// Test that padding adding up to 100% does not panic. -#pad(50%)[] diff --git a/tests/typ/layout/page-binding.typ b/tests/typ/layout/page-binding.typ deleted file mode 100644 index 66c8a3c6..00000000 --- a/tests/typ/layout/page-binding.typ +++ /dev/null @@ -1,46 +0,0 @@ -// Tests multi-page document with binding. - ---- -#set page(height: 100pt, margin: (inside: 30pt, outside: 20pt)) -#set par(justify: true) -#set text(size: 8pt) - -#page(margin: (x: 20pt), { - set align(center + horizon) - text(20pt, strong[Title]) - v(2em, weak: true) - text(15pt)[Author] -}) - -= Introduction -#lorem(35) - ---- -// Test setting the binding explicitly. -#set page(margin: (inside: 30pt)) -#rect(width: 100%)[Bound] -#pagebreak() -#rect(width: 100%)[Left] - ---- -// Test setting the binding explicitly. -#set page(binding: right, margin: (inside: 30pt)) -#rect(width: 100%)[Bound] -#pagebreak() -#rect(width: 100%)[Right] - ---- -// Test setting the binding implicitly. -#set page(margin: (inside: 30pt)) -#set text(lang: "he") -#rect(width: 100%)[Bound] -#pagebreak() -#rect(width: 100%)[Right] - ---- -// Error: 19-44 `inside` and `outside` are mutually exclusive with `left` and `right` -#set page(margin: (left: 1cm, outside: 2cm)) - ---- -// Error: 20-23 must be `left` or `right` -#set page(binding: top) diff --git a/tests/typ/layout/page-margin.typ b/tests/typ/layout/page-margin.typ deleted file mode 100644 index 00f2ed8a..00000000 --- a/tests/typ/layout/page-margin.typ +++ /dev/null @@ -1,20 +0,0 @@ -// Test page margins. - ---- -// Set all margins at once. -#[ - #set page(height: 20pt, margin: 5pt) - #place(top + left)[TL] - #place(bottom + right)[BR] -] - ---- -// Set individual margins. -#set page(height: 40pt) -#[#set page(margin: (left: 0pt)); #align(left)[Left]] -#[#set page(margin: (right: 0pt)); #align(right)[Right]] -#[#set page(margin: (top: 0pt)); #align(top)[Top]] -#[#set page(margin: (bottom: 0pt)); #align(bottom)[Bottom]] - -// Ensure that specific margins override general margins. -#[#set page(margin: (rest: 0pt, left: 20pt)); Overridden] diff --git a/tests/typ/layout/page-marginals.typ b/tests/typ/layout/page-marginals.typ deleted file mode 100644 index 589fb299..00000000 --- a/tests/typ/layout/page-marginals.typ +++ /dev/null @@ -1,24 +0,0 @@ -#set page( - paper: "a8", - margin: (x: 15pt, y: 30pt), - header: { - text(eastern)[*Typst*] - h(1fr) - text(0.8em)[_Chapter 1_] - }, - footer: context align(center)[\~ #counter(page).display() \~], - background: context if counter(page).get().first() <= 2 { - place(center + horizon, circle(radius: 1cm, fill: luma(90%))) - } -) - -But, soft! what light through yonder window breaks? It is the east, and Juliet -is the sun. Arise, fair sun, and kill the envious moon, Who is already sick and -pale with grief, That thou her maid art far more fair than she: Be not her maid, -since she is envious; Her vestal livery is but sick and green And none but fools -do wear it; cast it off. It is my lady, O, it is my love! O, that she knew she -were! She speaks yet she says nothing: what of that? Her eye discourses; I will -answer it. - -#set page(header: none, height: auto, margin: (top: 15pt, bottom: 25pt)) -The END. diff --git a/tests/typ/layout/page-number-align.typ b/tests/typ/layout/page-number-align.typ deleted file mode 100644 index 7559dd65..00000000 --- a/tests/typ/layout/page-number-align.typ +++ /dev/null @@ -1,25 +0,0 @@ -// Test page number alignment. - ---- -#set page( - height: 100pt, - margin: 30pt, - numbering: "(1)", - number-align: top + right, -) - -#block(width: 100%, height: 100%, fill: aqua.lighten(50%)) - ---- -#set page( - height: 100pt, - margin: 30pt, - numbering: "[1]", - number-align: bottom + left, -) - -#block(width: 100%, height: 100%, fill: aqua.lighten(50%)) - ---- -// Error: 25-39 expected `top` or `bottom`, found horizon -#set page(number-align: left + horizon) diff --git a/tests/typ/layout/page-style.typ b/tests/typ/layout/page-style.typ deleted file mode 100644 index 0d097554..00000000 --- a/tests/typ/layout/page-style.typ +++ /dev/null @@ -1,28 +0,0 @@ -// Test setting page styles. - ---- -// Empty with styles -// Should result in one conifer-colored A11 page. -#set page("a11", flipped: true, fill: conifer) - ---- -// Empty with styles and then pagebreak -// Should result in two forest-colored pages. -#set page(fill: forest) -#pagebreak() - ---- -// Empty with multiple page styles. -// Should result in a small white page. -#set page("a4") -#set page("a5") -#set page(width: 1cm, height: 1cm) - ---- -// Empty with multiple page styles. -// Should result in one eastern-colored A11 page. -#set page("a4") -#set page("a5") -#set page("a11", flipped: true, fill: eastern) -#set text(font: "Roboto", white) -#smallcaps[Typst] diff --git a/tests/typ/layout/page.typ b/tests/typ/layout/page.typ deleted file mode 100644 index f5c7822d..00000000 --- a/tests/typ/layout/page.typ +++ /dev/null @@ -1,42 +0,0 @@ -// Test the page class. - ---- -// Just empty page. -// Should result in auto-sized page, just like nothing. -#page[] - ---- -// Just empty page with styles. -// Should result in one conifer-colored A11 page. -#page("a11", flipped: true, fill: conifer)[] - ---- -// Set width and height. -// Should result in one high and one wide page. -#set page(width: 80pt, height: 80pt) -#[#set page(width: 40pt);High] -#[#set page(height: 40pt);Wide] - -// Flipped predefined paper. -#[#set page(paper: "a11", flipped: true);Flipped A11] - ---- -// Test page fill. -#set page(width: 80pt, height: 40pt, fill: eastern) -#text(15pt, font: "Roboto", fill: white, smallcaps[Typst]) -#page(width: 40pt, fill: none, margin: (top: 10pt, rest: auto))[Hi] - ---- -// Just page followed by pagebreak. -// Should result in one forest-colored A11 page and one auto-sized page. -#page("a11", flipped: true, fill: forest)[] -#pagebreak() - ---- -// Layout without any container should provide the page's dimensions, minus its margins. - -#page(width: 100pt, height: 100pt, { - layout(size => [This page has a width of #size.width and height of #size.height ]) - h(1em) - place(left, rect(width: 80pt, stroke: blue)) -}) diff --git a/tests/typ/layout/pagebreak-parity.typ b/tests/typ/layout/pagebreak-parity.typ deleted file mode 100644 index 4dbf723e..00000000 --- a/tests/typ/layout/pagebreak-parity.typ +++ /dev/null @@ -1,35 +0,0 @@ -// Test clearing to even or odd pages. - ---- -#set page(width: 80pt, height: 30pt) -First -#pagebreak(to: "odd") -Third -#pagebreak(to: "even") -Fourth -#pagebreak(to: "even") -Sixth -#pagebreak() -Seventh -#pagebreak(to: "odd") -#page[Ninth] - ---- -#set page(width: auto, height: auto) - -// Test with auto-sized page. -First -#pagebreak(to: "odd") -Third - ---- -#set page(height: 30pt, width: 80pt) - -// Test when content extends to more than one page -First - -Second - -#pagebreak(to: "odd") - -Third diff --git a/tests/typ/layout/pagebreak-weak.typ b/tests/typ/layout/pagebreak-weak.typ deleted file mode 100644 index c228959e..00000000 --- a/tests/typ/layout/pagebreak-weak.typ +++ /dev/null @@ -1,30 +0,0 @@ -// Test page breaks on basically empty pages. - ---- -// After place -// Should result in three pages. -First -#pagebreak(weak: true) -#place(right)[placed A] -#pagebreak(weak: true) -Third - ---- -// After only ignorables & invisibles -// Should result in two pages. -First -#pagebreak(weak: true) -#counter(page).update(1) -#metadata("Some") -#pagebreak(weak: true) -Second - ---- -// After only ignorables, but regular break -// Should result in three pages. -First -#pagebreak() -#counter(page).update(1) -#metadata("Some") -#pagebreak() -Third diff --git a/tests/typ/layout/pagebreak.typ b/tests/typ/layout/pagebreak.typ deleted file mode 100644 index f5921191..00000000 --- a/tests/typ/layout/pagebreak.typ +++ /dev/null @@ -1,45 +0,0 @@ -// Test forced page breaks. - ---- -// Just a pagebreak. -// Should result in two pages. -#pagebreak() - ---- -// Pagebreak, empty with styles and then pagebreak -// Should result in one auto-sized page and two conifer-colored 2cm wide pages. -#pagebreak() -#set page(width: 2cm, fill: conifer) -#pagebreak() - ---- -// Two text bodies separated with and surrounded by weak pagebreaks. -// Should result in two aqua-colored pages. -#set page(fill: aqua) -#pagebreak(weak: true) -First -#pagebreak(weak: true) -Second -#pagebreak(weak: true) - ---- -// Test a combination of pagebreaks, styled pages and pages with bodies. -// Should result in three five pages, with the fourth one being forest-colored. -#set page(width: 80pt, height: 30pt) -#[#set page(width: 60pt); First] -#pagebreak() -#pagebreak() -Third -#page(height: 20pt, fill: forest)[] -Fif#[#set page();th] - ---- -// Test hard and weak pagebreak followed by page with body. -// Should result in three navy-colored pages. -#set page(fill: navy) -#set text(fill: white) -First -#pagebreak() -#page[Second] -#pagebreak(weak: true) -#page[Third] diff --git a/tests/typ/layout/par-bidi.typ b/tests/typ/layout/par-bidi.typ deleted file mode 100644 index 4ff83802..00000000 --- a/tests/typ/layout/par-bidi.typ +++ /dev/null @@ -1,72 +0,0 @@ -// Test bidirectional text and language configuration. - ---- -// Test reordering with different top-level paragraph directions. -#let content = par[Text טֶקסט] -#text(lang: "he", content) -#text(lang: "de", content) - ---- -// Test that consecutive, embedded LTR runs stay LTR. -// Here, we have two runs: "A" and italic "B". -#let content = par[أنت A#emph[B]مطرC] -#set text(font: ("PT Sans", "Noto Sans Arabic")) -#text(lang: "ar", content) -#text(lang: "de", content) - ---- -// Test that consecutive, embedded RTL runs stay RTL. -// Here, we have three runs: "גֶ", bold "שֶׁ", and "ם". -#let content = par[Aגֶ#strong[שֶׁ]םB] -#set text(font: ("Linux Libertine", "Noto Serif Hebrew")) -#text(lang: "he", content) -#text(lang: "de", content) - ---- -// Test embedding up to level 4 with isolates. -#set text(dir: rtl) -א\u{2066}A\u{2067}Bב\u{2069}? - ---- -// Test hard line break (leads to two paragraphs in unicode-bidi). -#set text(lang: "ar", font: ("Noto Sans Arabic", "PT Sans")) -Life المطر هو الحياة \ -الحياة تمطر is rain. - ---- -// Test spacing. -L #h(1cm) ריווחR \ -Lריווח #h(1cm) R - ---- -// Test inline object. -#set text(lang: "he") -קרנפיםRh#box(image("/assets/images/rhino.png", height: 11pt))inoחיים - ---- -// Test whether L1 whitespace resetting destroys stuff. -الغالب #h(70pt) ن#" "ة - ---- -// Test explicit dir -#set text(dir: rtl) -#text("8:00 - 9:00",dir:ltr) בבוקר -#linebreak() -ב #text("12:00 - 13:00",dir:ltr) בצהריים - ---- -// Mixing raw -#set text(lang: "he") -לדוג. `if a == b:` זה תנאי -#set raw(lang:"python") -לדוג. `if a == b:` זה תנאי - -#show raw: set text(dir:rtl) -לתכנת בעברית `אם א == ב:` - ---- -// Test setting a vertical direction. -// Ref: false - -// Error: 16-19 text direction must be horizontal -#set text(dir: ttb) diff --git a/tests/typ/layout/par-indent.typ b/tests/typ/layout/par-indent.typ deleted file mode 100644 index e807d74d..00000000 --- a/tests/typ/layout/par-indent.typ +++ /dev/null @@ -1,51 +0,0 @@ -// Test paragraph indent. - ---- -#set par(first-line-indent: 12pt, leading: 5pt) -#set block(spacing: 5pt) -#show heading: set text(size: 10pt) - -The first paragraph has no indent. - -But the second one does. - -#box(image("/assets/images/tiger.jpg", height: 6pt)) -starts a paragraph, also with indent. - -#align(center, image("/assets/images/rhino.png", width: 1cm)) - -= Headings -- And lists. -- Have no indent. - - Except if you have another paragraph in them. - -#set text(8pt, lang: "ar", font: ("Noto Sans Arabic", "Linux Libertine")) -#set par(leading: 8pt) - -= Arabic -دع النص يمطر عليك - -ثم يصبح النص رطبًا وقابل للطرق ويبدو المستند رائعًا. - ---- -// This is madness. -#set par(first-line-indent: 12pt) -Why would anybody ever ... - -... want spacing and indent? - ---- -// Test hanging indent. -#set par(hanging-indent: 15pt, justify: true) -#lorem(10) - ---- -#set par(hanging-indent: 1em) -Welcome \ here. Does this work well? - ---- -#set par(hanging-indent: 2em) -#set text(dir: rtl) -لآن وقد أظلم الليل وبدأت النجوم -تنضخ وجه الطبيعة التي أعْيَتْ من طول ما انبعثت في النهار diff --git a/tests/typ/layout/par-justify-cjk.typ b/tests/typ/layout/par-justify-cjk.typ deleted file mode 100644 index d0fef644..00000000 --- a/tests/typ/layout/par-justify-cjk.typ +++ /dev/null @@ -1,64 +0,0 @@ -// Test Chinese text in narrow lines. - -// In Chinese typography, line length should be multiples of the character size -// and the line ends should be aligned with each other. -// Most Chinese publications do not use hanging punctuation at line end. -#set page(width: auto) -#set par(justify: true) -#set text(lang: "zh", font: "Noto Serif CJK SC") - -#rect(inset: 0pt, width: 80pt, fill: rgb("eee"))[ - 中文维基百科使用汉字书写,汉字是汉族或华人的共同文字,是中国大陆、新加坡、马来西亚、台湾、香港、澳门的唯一官方文字或官方文字之一。25.9%,而美国和荷兰则分別占13.7%及8.2%。近年來,中国大陆地区的维基百科编辑者正在迅速增加; -] - ---- -// Japanese typography is more complex, make sure it is at least a bit sensible. -#set page(width: auto) -#set par(justify: true) -#set text(lang: "ja", font: ("Linux Libertine", "Noto Serif CJK JP")) -#rect(inset: 0pt, width: 80pt, fill: rgb("eee"))[ - ウィキペディア(英: Wikipedia)は、世界中のボランティアの共同作業によって執筆及び作成されるフリーの多言語インターネット百科事典である。主に寄付に依って活動している非営利団体「ウィキメディア財団」が所有・運営している。 - - 専門家によるオンライン百科事典プロジェクトNupedia(ヌーペディア)を前身として、2001年1月、ラリー・サンガーとジミー・ウェールズ(英: Jimmy Donal "Jimbo" Wales)により英語でプロジェクトが開始された。 -] - ---- -// Test punctuation whitespace adjustment -#set page(width: auto) -#set text(lang: "zh", font: "Noto Serif CJK SC") -#set par(justify: true) -#rect(inset: 0pt, width: 80pt, fill: rgb("eee"))[ - “引号测试”,还, - - 《书名》《测试》下一行 - - 《书名》《测试》。 -] - -「『引号』」。“‘引号’”。 - ---- -// Test Variants of Mainland China, Hong Kong, and Japan. - -// 17 characters a line. -#set page(width: 170pt + 10pt, margin: (x: 5pt)) -#set text(lang: "zh", font: "Noto Serif CJK SC") -#set par(justify: true) - -孔雀最早见于《山海经》中的《海内经》:“有孔雀。”东汉杨孚著《异物志》记载,岭南:“孔雀,其大如大雁而足高,毛皆有斑纹彩,捕而蓄之,拍手即舞。” - -#set text(lang: "zh", region: "hk", font: "Noto Serif CJK TC") -孔雀最早见于《山海经》中的《海内经》:「有孔雀。」东汉杨孚著《异物志》记载,岭南:「孔雀,其大如大雁而足高,毛皆有斑纹彩,捕而蓄之,拍手即舞。」 - ---- -// Test punctuation marks adjustment in justified paragraph. - -// The test case includes the following scenarios: -// - Compression of punctuation marks at line start or line end -// - Adjustment of adjacent punctuation marks - -#set page(width: 110pt + 10pt, margin: (x: 5pt)) -#set text(lang: "zh", font: "Noto Serif CJK SC") -#set par(justify: true) - -标注在字间的标点符号(乙式括号省略号以外)通常占一个汉字宽度,使其易于识别、适合配置及排版,有些排版风格完全不对标点宽度进行任何调整。但是为了让文字体裁更加紧凑易读,,,以及执行3.1.4 行首行尾禁则时,就需要对标点符号的宽度进行调整。是否调整取决于…… diff --git a/tests/typ/layout/par-justify.typ b/tests/typ/layout/par-justify.typ deleted file mode 100644 index 69576c7d..00000000 --- a/tests/typ/layout/par-justify.typ +++ /dev/null @@ -1,65 +0,0 @@ - ---- -#set page(width: 180pt) -#set block(spacing: 5pt) -#set par(justify: true, first-line-indent: 14pt, leading: 5pt) - -This text is justified, meaning that spaces are stretched so that the text -forms a "block" with flush edges at both sides. - -First line indents and hyphenation play nicely with justified text. - ---- -// Test that lines with hard breaks aren't justified. -#set par(justify: true) -A B C \ -D - ---- -// Test forced justification with justified break. -A B C #linebreak(justify: true) -D E F #linebreak(justify: true) - ---- -// Test that there are no hick-ups with justification enabled and -// basically empty paragraph. -#set par(justify: true) -#"" - ---- -// Test that the last line can be shrunk -#set page(width: 155pt) -#set par(justify: true) -This text can be fitted in one line. - ---- -// Test that runts are avoided when it's not too costly to do so. -#set page(width: 124pt) -#set par(justify: true) -#for i in range(0, 20) { - "a b c " -} -#"d" - ---- -// Test that justification cannot lead to a leading space -#set par(justify: true) -#set text(size: 12pt) -#set page(width: 45mm, height: auto) - -lorem ipsum 1234, lorem ipsum dolor sit amet - -#" leading whitespace should still be displayed" - ---- -// Test that justification doesn't break code blocks - -#set par(justify: true) - -```cpp -int main() { - printf("Hello world\n"); - return 0; -} -``` - diff --git a/tests/typ/layout/par-knuth.typ b/tests/typ/layout/par-knuth.typ deleted file mode 100644 index 50f9280a..00000000 --- a/tests/typ/layout/par-knuth.typ +++ /dev/null @@ -1,30 +0,0 @@ -#set page(width: auto, height: auto) -#set par(leading: 4pt, justify: true) -#set text(font: "New Computer Modern") - -#let story = [ - In olden times when wishing still helped one, there lived a king whose - daughters were all beautiful; and the youngest was so beautiful that the sun - itself, which has seen so much, was astonished whenever it shone in her face. - Close by the king’s castle lay a great dark forest, and under an old lime-tree - in the forest was a well, and when the day was very warm, the king’s child - went out into the forest and sat down by the side of the cool fountain; and - when she was bored she took a golden ball, and threw it up on high and caught - it; and this ball was her favorite plaything. -] - -#let column(title, linebreaks, hyphenate) = { - rect(inset: 0pt, width: 132pt, fill: rgb("eee"))[ - #set par(linebreaks: linebreaks) - #set text(hyphenate: hyphenate) - #strong(title) \ #story - ] -} - -#grid( - columns: 3, - gutter: 10pt, - column([Simple without hyphens], "simple", false), - column([Simple with hyphens], "simple", true), - column([Optimized with hyphens], "optimized", true), -) diff --git a/tests/typ/layout/par-simple.typ b/tests/typ/layout/par-simple.typ deleted file mode 100644 index 34a2d626..00000000 --- a/tests/typ/layout/par-simple.typ +++ /dev/null @@ -1,20 +0,0 @@ -// Test plain text. - ---- -#set page(width: 250pt, height: 120pt) - -But, soft! what light through yonder window breaks? It is the east, and Juliet -is the sun. Arise, fair sun, and kill the envious moon, Who is already sick and -pale with grief, That thou her maid art far more fair than she: Be not her maid, -since she is envious; Her vestal livery is but sick and green And none but fools -do wear it; cast it off. It is my lady, O, it is my love! O, that she knew she -were! She speaks yet she says nothing: what of that? Her eye discourses; I will -answer it. - -I am too bold, 'tis not to me she speaks: Two of the fairest stars in all the -heaven, Having some business, do entreat her eyes To twinkle in their spheres -till they return. What if her eyes were there, they in her head? The brightness -of her cheek would shame those stars, As daylight doth a lamp; her eyes in -heaven Would through the airy region stream so bright That birds would sing and -think it were not night. See, how she leans her cheek upon her hand! O, that I -were a glove upon that hand, That I might touch that cheek! diff --git a/tests/typ/layout/par.typ b/tests/typ/layout/par.typ deleted file mode 100644 index 45b60cf5..00000000 --- a/tests/typ/layout/par.typ +++ /dev/null @@ -1,36 +0,0 @@ -// Test configuring paragraph properties. - ---- -// Test ragged-left. -#set align(right) -To the right! Where the sunlight peeks behind the mountain. - ---- -// Test changing leading and spacing. -#set block(spacing: 1em) -#set par(leading: 2pt) -But, soft! what light through yonder window breaks? - -It is the east, and Juliet is the sun. - ---- -// Test that paragraph spacing loses against block spacing. -// TODO -#set block(spacing: 100pt) -#show table: set block(above: 5pt, below: 5pt) -Hello -#table(columns: 4, fill: (x, y) => if calc.odd(x + y) { silver })[A][B][C][D] - ---- -// While we're at it, test the larger block spacing wins. -#set block(spacing: 0pt) -#show raw: set block(spacing: 15pt) -#show list: set block(spacing: 2.5pt) - -```rust -fn main() {} -``` - -- List - -Paragraph diff --git a/tests/typ/layout/place-background.typ b/tests/typ/layout/place-background.typ deleted file mode 100644 index afee0622..00000000 --- a/tests/typ/layout/place-background.typ +++ /dev/null @@ -1,18 +0,0 @@ -// Test placing a background image on a page. - ---- -#set page(paper: "a10", flipped: true) -#set text(fill: white) -#place( - dx: -10pt, - dy: -10pt, - image( - "/assets/images/tiger.jpg", - fit: "cover", - width: 100% + 20pt, - height: 100% + 20pt, - ) -) -#align(bottom + right)[ - _Welcome to_ #underline[*Tigerland*] -] diff --git a/tests/typ/layout/place-float-auto.typ b/tests/typ/layout/place-float-auto.typ deleted file mode 100644 index 2ca3dc3a..00000000 --- a/tests/typ/layout/place-float-auto.typ +++ /dev/null @@ -1,31 +0,0 @@ -// Test floating placement. - ---- -#set page(height: 140pt) -#set place(clearance: 5pt) -#lorem(6) -#place(auto, float: true, rect[A]) -#place(auto, float: true, rect[B]) -#place(auto, float: true, rect[C]) -#place(auto, float: true, rect[D]) - ---- -// Error: 2-20 automatic positioning is only available for floating placement -// Hint: 2-20 you can enable floating placement with `place(float: true, ..)` -#place(auto)[Hello] - ---- -// Error: 2-45 floating placement must be `auto`, `top`, or `bottom` -#place(center + horizon, float: true)[Hello] - ---- -// Error: 2-36 floating placement must be `auto`, `top`, or `bottom` -#place(horizon, float: true)[Hello] - ---- -// Error: 2-27 floating placement must be `auto`, `top`, or `bottom` -#place(float: true)[Hello] - ---- -// Error: 2-34 floating placement must be `auto`, `top`, or `bottom` -#place(right, float: true)[Hello] diff --git a/tests/typ/layout/place-float-columns.typ b/tests/typ/layout/place-float-columns.typ deleted file mode 100644 index e2b88d46..00000000 --- a/tests/typ/layout/place-float-columns.typ +++ /dev/null @@ -1,19 +0,0 @@ -// Test floats in columns. - ---- -#set page(height: 200pt, width: 300pt) -#show: columns.with(2) - -= Introduction -#figure( - placement: bottom, - caption: [A glacier], - image("/assets/images/glacier.jpg", width: 50%), -) -#lorem(45) -#figure( - placement: top, - caption: [A rectangle], - rect[Hello!], -) -#lorem(20) diff --git a/tests/typ/layout/place-float-figure.typ b/tests/typ/layout/place-float-figure.typ deleted file mode 100644 index 4d76fd8f..00000000 --- a/tests/typ/layout/place-float-figure.typ +++ /dev/null @@ -1,21 +0,0 @@ -// Test floating figures. - ---- -#set page(height: 250pt, width: 150pt) - -= Introduction -#lorem(10) #footnote[Lots of Latin] - -#figure( - placement: bottom, - caption: [A glacier #footnote[Lots of Ice]], - image("/assets/images/glacier.jpg", width: 80%), -) - -#lorem(40) - -#figure( - placement: top, - caption: [An important], - image("/assets/images/diagram.svg", width: 80%), -) diff --git a/tests/typ/layout/place-nested.typ b/tests/typ/layout/place-nested.typ deleted file mode 100644 index 93006ff5..00000000 --- a/tests/typ/layout/place-nested.typ +++ /dev/null @@ -1,40 +0,0 @@ -// Test vertical alignment with nested placement. - ---- -#box( - fill: aqua, - width: 30pt, - height: 30pt, - place(bottom, - place(line(start: (0pt, 0pt), end: (20pt, 0pt), stroke: red + 3pt)) - ) -) - ---- -#box( - fill: aqua, - width: 30pt, - height: 30pt, - { - box(fill: yellow, { - [Hello] - place(horizon, line(start: (0pt, 0pt), end: (20pt, 0pt), stroke: red + 2pt)) - }) - place(horizon, line(start: (0pt, 0pt), end: (20pt, 0pt), stroke: green + 3pt)) - } -) - ---- -#box(fill: aqua)[ - #place(bottom + right)[Hi] - Hello World \ - How are \ - you? -] - ---- -#box(fill: aqua)[ - #place(top + left, dx: 50%, dy: 50%)[Hi] - #v(30pt) - #line(length: 50pt) -] diff --git a/tests/typ/layout/place.typ b/tests/typ/layout/place.typ deleted file mode 100644 index d426e07f..00000000 --- a/tests/typ/layout/place.typ +++ /dev/null @@ -1,35 +0,0 @@ -// Test the `place` function. - ---- -#set page("a8") -#place(bottom + center)[© Typst] - -= Placement -#place(right, image("/assets/images/tiger.jpg", width: 1.8cm)) -Hi there. This is \ -a placed element. \ -Unfortunately, \ -the line breaks still had to be inserted manually. - -#stack( - rect(fill: eastern, height: 10pt, width: 100%), - place(right, dy: 1.5pt)[ABC], - rect(fill: conifer, height: 10pt, width: 80%), - rect(fill: forest, height: 10pt, width: 100%), - 10pt, - block[ - #place(center, dx: -7pt, dy: -5pt)[Hello] - #place(center, dx: 7pt, dy: 5pt)[Hello] - Hello #h(1fr) Hello - ] -) - ---- -// Test how the placed element interacts with paragraph spacing around it. -#set page("a8", height: 60pt) - -First - -#place(bottom + right)[Placed] - -Second diff --git a/tests/typ/layout/repeat.typ b/tests/typ/layout/repeat.typ deleted file mode 100644 index 173f9d57..00000000 --- a/tests/typ/layout/repeat.typ +++ /dev/null @@ -1,44 +0,0 @@ -// Test the `repeat` function. - ---- -// Test multiple repeats. -#let sections = ( - ("Introduction", 1), - ("Approach", 1), - ("Evaluation", 3), - ("Discussion", 15), - ("Related Work", 16), - ("Conclusion", 253), -) - -#for section in sections [ - #section.at(0) #box(width: 1fr, repeat[.]) #section.at(1) \ -] - ---- -// Test dots with RTL. -#set text(lang: "ar") -مقدمة #box(width: 1fr, repeat[.]) 15 - ---- -// Test empty repeat. -A #box(width: 1fr, repeat[]) B - ---- -// Test unboxed repeat. -#repeat(rect(width: 2em, height: 1em)) - ---- -// Test single repeat in both directions. -A#box(width: 1fr, repeat(rect(width: 6em, height: 0.7em)))B - -#set align(center) -A#box(width: 1fr, repeat(rect(width: 6em, height: 0.7em)))B - -#set text(dir: rtl) -ريجين#box(width: 1fr, repeat(rect(width: 4em, height: 0.7em)))سون - ---- -// Error: 2:2-2:13 repeat with no size restrictions -#set page(width: auto) -#repeat(".") diff --git a/tests/typ/layout/spacing.typ b/tests/typ/layout/spacing.typ deleted file mode 100644 index faba60b4..00000000 --- a/tests/typ/layout/spacing.typ +++ /dev/null @@ -1,46 +0,0 @@ -// Test the `h` and `v` functions. - ---- -// Linebreak and leading-sized weak spacing are equivalent. -#box[A \ B] #box[A #v(0.65em, weak: true) B] - -// Eating up soft spacing. -Inv#h(0pt)isible - -// Multiple spacings in a row. -Add #h(10pt) #h(10pt) up - -// Relative to area. -#let x = 25% - 4pt -|#h(x)|#h(x)|#h(x)|#h(x)| - -// Fractional. -| #h(1fr) | #h(2fr) | #h(1fr) | - ---- -// Test spacing collapsing before spacing. -#set align(right) -A #h(0pt) B #h(0pt) \ -A B \ -A #h(-1fr) B - ---- -// Test spacing collapsing with different font sizes. -#grid(columns: 2)[ - #text(size: 12pt, block(below: 1em)[A]) - #text(size: 8pt, block(above: 1em)[B]) -][ - #text(size: 12pt, block(below: 1em)[A]) - #text(size: 8pt, block(above: 1.25em)[B]) -] - ---- -// Test RTL spacing. -#set text(dir: rtl) -A #h(10pt) B \ -A #h(1fr) B - ---- -// Missing spacing. -// Error: 10-13 missing argument: amount -Totally #h() ignored diff --git a/tests/typ/layout/stack-1.typ b/tests/typ/layout/stack-1.typ deleted file mode 100644 index 8b5472e8..00000000 --- a/tests/typ/layout/stack-1.typ +++ /dev/null @@ -1,52 +0,0 @@ -// Test stack layouts. - ---- -// Test stacks with different directions. -#let widths = ( - 30pt, 20pt, 40pt, 15pt, - 30pt, 50%, 20pt, 100%, -) - -#let shaded(i, w) = { - let v = (i + 1) * 10% - rect(width: w, height: 10pt, fill: rgb(v, v, v)) -} - -#let items = for (i, w) in widths.enumerate() { - (align(right, shaded(i, w)),) -} - -#set page(width: 50pt, margin: 0pt) -#stack(dir: btt, ..items) - ---- -// Test spacing. -#set page(width: 50pt, margin: 0pt) - -#let x = square(size: 10pt, fill: eastern) -#stack( - spacing: 5pt, - stack(dir: rtl, spacing: 5pt, x, x, x), - stack(dir: ltr, x, 20%, x, 20%, x), - stack(dir: ltr, spacing: 5pt, x, x, 7pt, 3pt, x), -) - ---- -// Test overflow. -#set page(width: 50pt, height: 30pt, margin: 0pt) -#box(stack( - rect(width: 40pt, height: 20pt, fill: conifer), - rect(width: 30pt, height: 13pt, fill: forest), -)) - ---- -// Test aligning things in RTL stack with align function & fr units. -#set page(width: 50pt, margin: 5pt) -#set block(spacing: 5pt) -#set text(8pt) -#stack(dir: rtl, 1fr, [A], 1fr, [B], [C]) -#stack(dir: rtl, - align(center, [A]), - align(left, [B]), - [C], -) diff --git a/tests/typ/layout/stack-2.typ b/tests/typ/layout/stack-2.typ deleted file mode 100644 index a06950f1..00000000 --- a/tests/typ/layout/stack-2.typ +++ /dev/null @@ -1,23 +0,0 @@ -// Test fr units in stacks. - ---- -#set page(height: 3.5cm) -#stack( - dir: ltr, - spacing: 1fr, - ..for c in "ABCDEFGHI" {([#c],)} -) - -Hello -#v(2fr) -from #h(1fr) the #h(1fr) wonderful -#v(1fr) -World! 🌍 - ---- -#set page(height: 2cm) -#set text(white) -#rect(fill: forest)[ - #v(1fr) - #h(1fr) Hi you! -] diff --git a/tests/typ/layout/table-cell.typ b/tests/typ/layout/table-cell.typ deleted file mode 100644 index cbe0b9f0..00000000 --- a/tests/typ/layout/table-cell.typ +++ /dev/null @@ -1,128 +0,0 @@ -// Test basic styling using the table.cell element. - ---- -// Cell override -#table( - align: left, - fill: red, - stroke: blue, - columns: 2, - [AAAAA], [BBBBB], - [A], [B], - table.cell(align: right)[C], [D], - align(right)[E], [F], - align(horizon)[G], [A\ A\ A], - table.cell(align: horizon)[G2], [A\ A\ A], - table.cell(inset: 0pt)[I], [F], - [H], table.cell(fill: blue)[J] -) - ---- -// Cell show rule -#show table.cell: it => [Zz] - -#table( - align: left, - fill: red, - stroke: blue, - columns: 2, - [AAAAA], [BBBBB], - [A], [B], - table.cell(align: right)[C], [D], - align(right)[E], [F], - align(horizon)[G], [A\ A\ A] -) - ---- -#show table.cell: it => (it.align, it.fill) -#table( - align: left, - row-gutter: 5pt, - [A], - table.cell(align: right)[B], - table.cell(fill: aqua)[B], -) - ---- -// Cell set rules -#set table.cell(align: center) -#show table.cell: it => (it.align, it.fill, it.inset) -#set table.cell(inset: 20pt) -#table( - align: left, - row-gutter: 5pt, - [A], - table.cell(align: right)[B], - table.cell(fill: aqua)[B], -) - ---- -// Test folding per-cell properties (align and inset) -#table( - columns: (1fr, 1fr), - rows: (2.5em, auto), - align: right, - fill: (x, y) => (green, aqua).at(calc.rem(x + y, 2)), - [Top], table.cell(align: bottom)[Bot], - table.cell(inset: (bottom: 0pt))[Bot], table.cell(inset: (bottom: 0pt))[Bot] -) - ---- -// Test overriding outside alignment -#set align(bottom + right) -#table( - columns: (1fr, 1fr), - rows: 2em, - align: auto, - fill: green, - [BR], [BR], - table.cell(align: left, fill: aqua)[BL], table.cell(align: top, fill: red.lighten(50%))[TR] -) - ---- -// First doc example -#table( - columns: 2, - fill: green, - align: right, - [*Name*], [*Data*], - table.cell(fill: blue)[J.], [Organizer], - table.cell(align: center)[K.], [Leader], - [M.], table.cell(inset: 0pt)[Player] -) - ---- -#{ - show table.cell: emph - table( - columns: 2, - [Person], [Animal], - [John], [Dog] - ) -} - ---- -// Style based on position -#{ - show table.cell: it => { - if it.y == 0 { - strong(it) - } else if it.x == 1 { - emph(it) - } else { - it - } - } - table( - columns: 3, - gutter: 3pt, - [Name], [Age], [Info], - [John], [52], [Nice], - [Mary], [50], [Cool], - [Jake], [49], [Epic] - ) -} - ---- -// Error: 8-19 cannot use `grid.cell` as a table cell; use `table.cell` instead -#table(grid.cell[]) diff --git a/tests/typ/layout/table.typ b/tests/typ/layout/table.typ deleted file mode 100644 index 89a7dab5..00000000 --- a/tests/typ/layout/table.typ +++ /dev/null @@ -1,141 +0,0 @@ -// Test tables. - ---- -#set page(height: 70pt) -#set table(fill: (x, y) => if calc.even(x + y) { rgb("aaa") }) - -#table( - columns: (1fr,) * 3, - stroke: 2pt + rgb("333"), - [A], [B], [C], [], [], [D \ E \ F \ \ \ G], [H], -) - ---- -#table(columns: 3, stroke: none, fill: green, [A], [B], [C]) - ---- -// Test alignment with array. -#table( - columns: (1fr, 1fr, 1fr), - align: (left, center, right), - [A], [B], [C] -) - -// Test empty array. -#set align(center) -#table( - columns: (1fr, 1fr, 1fr), - align: (), - [A], [B], [C] -) - ---- -// Test inset. -#table( - columns: 3, - inset: 10pt, - [A], [B], [C] -) - -#table( - columns: 3, - inset: (y: 10pt), - [A], [B], [C] -) - -#table( - columns: 3, - inset: (left: 20pt, rest: 10pt), - [A], [B], [C] -) - -#table( - columns: 2, - inset: ( - left: 20pt, - right: 5pt, - top: 10pt, - bottom: 3pt, - ), - [A], - [B], -) - -#table( - columns: 3, - fill: (x, y) => (if y == 0 { aqua } else { orange }).darken(x * 15%), - inset: (x, y) => (left: if x == 0 { 0pt } else { 5pt }, right: if x == 0 { 5pt } else { 0pt }, y: if y == 0 { 0pt } else { 5pt }), - [A], [B], [C], - [A], [B], [C], -) - -#table( - columns: 3, - inset: (0pt, 5pt, 10pt), - fill: (x, _) => aqua.darken(x * 15%), - [A], [B], [C], -) - ---- -// Test inset folding -#set table(inset: 10pt) -#set table(inset: (left: 0pt)) - -#table( - fill: red, - inset: (right: 0pt), - table.cell(inset: (top: 0pt))[a] -) - ---- -// Test interaction with gutters. -#table( - columns: (3em, 3em), - fill: (x, y) => (red, blue).at(calc.rem(x, 2)), - align: (x, y) => (left, right).at(calc.rem(y, 2)), - [A], [B], - [C], [D], - [E], [F], - [G], [H] -) - -#table( - columns: (3em, 3em), - fill: (x, y) => (red, blue).at(calc.rem(x, 2)), - align: (x, y) => (left, right).at(calc.rem(y, 2)), - row-gutter: 5pt, - [A], [B], - [C], [D], - [E], [F], - [G], [H] -) - -#table( - columns: (3em, 3em), - fill: (x, y) => (red, blue).at(calc.rem(x, 2)), - align: (x, y) => (left, right).at(calc.rem(y, 2)), - column-gutter: 5pt, - [A], [B], - [C], [D], - [E], [F], - [G], [H] -) - -#table( - columns: (3em, 3em), - fill: (x, y) => (red, blue).at(calc.rem(x, 2)), - align: (x, y) => (left, right).at(calc.rem(y, 2)), - gutter: 5pt, - [A], [B], - [C], [D], - [E], [F], - [G], [H] -) - ---- -// Ref: false -#table() - ---- -// Error: 14-19 expected color, gradient, pattern, none, array, or function, found string -#table(fill: "hey") diff --git a/tests/typ/layout/terms.typ b/tests/typ/layout/terms.typ deleted file mode 100644 index 178aa98b..00000000 --- a/tests/typ/layout/terms.typ +++ /dev/null @@ -1,60 +0,0 @@ -// Test term list. - ---- -// Test with constructor. -#terms( - ([One], [First]), - ([Two], [Second]), -) - ---- -// Test joining. -#for word in lorem(4).split().map(s => s.trim(".")) [ - / #word: Latin stuff. -] - ---- -// Test multiline. -#set text(8pt) - -/ Fruit: A tasty, edible thing. -/ Veggie: - An important energy source - for vegetarians. - - And healthy! - ---- -// Test style change. -#set text(8pt) -/ First list: #lorem(6) - -#set terms(hanging-indent: 30pt) -/ Second list: #lorem(5) - ---- -// Test RTL. -#set text(8pt, dir: rtl) - -/ פרי: דבר טעים, אכיל. ומקור אנרגיה חשוב לצמחונים. - ---- -// Test grid like show rule. -#show terms: it => table( - columns: 2, - inset: 3pt, - ..it.children.map(v => (emph(v.term), v.description)).flatten(), -) - -/ A: One letter -/ BB: Two letters -/ CCC: Three letters - ---- -/ Term: -Not in list -/Nope - ---- -// Error: 8 expected colon -/ Hello diff --git a/tests/typ/layout/transform-layout.typ b/tests/typ/layout/transform-layout.typ deleted file mode 100644 index ce6dc930..00000000 --- a/tests/typ/layout/transform-layout.typ +++ /dev/null @@ -1,58 +0,0 @@ -// Test layout transformations - ---- -// Test that rotation impact layout. -#set page(width: 200pt) -#set rotate(reflow: true) - -#let one(angle) = box(fill: aqua, rotate(angle)[Test Text]) -#for angle in range(0, 360, step: 15) { - one(angle * 1deg) -} - ---- -// Test relative sizing in rotated boxes. -#set page(width: 200pt, height: 200pt) -#set text(size: 32pt) -#let rotated(body) = box(rotate( - 90deg, - box(stroke: 0.5pt, height: 20%, clip: true, body) -)) - -#set rotate(reflow: false) -Hello #rotated[World]!\ - -#set rotate(reflow: true) -Hello #rotated[World]! - ---- -// Test that scaling impact layout. -#set page(width: 200pt) -#set text(size: 32pt) -#let scaled(body) = box(scale( - x: 20%, - y: 40%, - body -)) - -#set scale(reflow: false) -Hello #scaled[World]! - -#set scale(reflow: true) -Hello #scaled[World]! - ---- -// Test relative sizing in scaled boxes. -#set page(width: 200pt, height: 200pt) -#set text(size: 32pt) -#let scaled(body) = box(scale( - x: 60%, - y: 40%, - box(stroke: 0.5pt, width: 30%, clip: true, body) -)) - -#set scale(reflow: false) -Hello #scaled[World]!\ - -#set scale(reflow: true) -Hello #scaled[World]! diff --git a/tests/typ/layout/transform.typ b/tests/typ/layout/transform.typ deleted file mode 100644 index f74ec2b0..00000000 --- a/tests/typ/layout/transform.typ +++ /dev/null @@ -1,49 +0,0 @@ -// Test transformations. - ---- -// Test creating the TeX and XeTeX logos. -#let size = 11pt -#let tex = { - [T] - h(-0.14 * size) - box(move(dy: 0.22 * size)[E]) - h(-0.12 * size) - [X] -} - -#let xetex = { - [X] - h(-0.14 * size) - box(scale(x: -100%, move(dy: 0.26 * size)[E])) - h(-0.14 * size) - [T] - h(-0.14 * size) - box(move(dy: 0.26 * size)[E]) - h(-0.12 * size) - [X] -} - -#set text(font: "New Computer Modern", size) -Neither #tex, \ -nor #xetex! - ---- -// Test combination of scaling and rotation. -#set page(height: 80pt) -#align(center + horizon, - rotate(20deg, scale(70%, image("/assets/images/tiger.jpg"))) -) - ---- -// Test setting rotation origin. -#rotate(10deg, origin: top + left, - image("/assets/images/tiger.jpg", width: 50%) -) - ---- -// Test setting scaling origin. -#let r = rect(width: 100pt, height: 10pt, fill: forest) -#set page(height: 65pt) -#box(scale(r, x: 50%, y: 200%, origin: left + top)) -#box(scale(r, x: 50%, origin: center)) -#box(scale(r, x: 50%, y: 200%, origin: right + bottom)) |
