diff options
Diffstat (limited to 'tests/typ/meta')
34 files changed, 0 insertions, 1515 deletions
diff --git a/tests/typ/meta/bibliography-full.typ b/tests/typ/meta/bibliography-full.typ deleted file mode 100644 index 9b652cd2..00000000 --- a/tests/typ/meta/bibliography-full.typ +++ /dev/null @@ -1,5 +0,0 @@ -// Test the full bibliography. - ---- -#set page(paper: "a6", height: 170mm) -#bibliography("/assets/bib/works.bib", full: true) diff --git a/tests/typ/meta/bibliography-ordering.typ b/tests/typ/meta/bibliography-ordering.typ deleted file mode 100644 index 4732ad68..00000000 --- a/tests/typ/meta/bibliography-ordering.typ +++ /dev/null @@ -1,16 +0,0 @@ -#set page(width: 300pt) - -@mcintosh_anxiety -@psychology25 -@netwok -@issue201 -@arrgh -@quark -@distress, -@glacier-melt -@issue201 -@tolkien54 -@sharing -@restful - -#bibliography("/assets/bib/works.bib") diff --git a/tests/typ/meta/bibliography.typ b/tests/typ/meta/bibliography.typ deleted file mode 100644 index 107f790e..00000000 --- a/tests/typ/meta/bibliography.typ +++ /dev/null @@ -1,44 +0,0 @@ -// Test citations and bibliographies. - ---- -#set page(width: 200pt) - -= Details -See also @arrgh #cite(<distress>, supplement: [p.~22]), @arrgh[p.~4], and @distress[p.~5]. -#bibliography("/assets/bib/works.bib") - ---- -// Test unconventional order. -#set page(width: 200pt) -#bibliography( - "/assets/bib/works.bib", - title: [Works to be cited], - style: "chicago-author-date", -) -#line(length: 100%) - -As described by #cite(<netwok>, form: "prose"), -the net-work is a creature of its own. -This is close to piratery! @arrgh -And quark! @quark - ---- -#set page(width: 200pt) -#set heading(numbering: "1.") -#show bibliography: set heading(numbering: "1.") - -= Multiple Bibs -Now we have multiple bibliographies containing @glacier-melt @keshav2007read -#bibliography(("/assets/bib/works.bib", "/assets/bib/works_too.bib")) - ---- -// Test ambiguous reference. -= Introduction <arrgh> - -// Error: 1-7 label occurs in the document and its bibliography -@arrgh -#bibliography("/assets/bib/works.bib") - ---- -// Error: 15-65 duplicate bibliography keys: netwok, issue201, arrgh, quark, distress, glacier-melt, tolkien54, DBLP:books/lib/Knuth86a, sharing, restful, mcintosh_anxiety, psychology25 -#bibliography(("/assets/bib/works.bib", "/assets/bib/works.bib")) diff --git a/tests/typ/meta/cite-footnote.typ b/tests/typ/meta/cite-footnote.typ deleted file mode 100644 index c6eff59d..00000000 --- a/tests/typ/meta/cite-footnote.typ +++ /dev/null @@ -1,5 +0,0 @@ -Hello @netwok -And again: @netwok - -#pagebreak() -#bibliography("/assets/bib/works.bib", style: "chicago-notes") diff --git a/tests/typ/meta/cite-form.typ b/tests/typ/meta/cite-form.typ deleted file mode 100644 index 343981d7..00000000 --- a/tests/typ/meta/cite-form.typ +++ /dev/null @@ -1,10 +0,0 @@ -// Test citation forms. - ---- -#set page(width: 200pt) - -Nothing: #cite(<arrgh>, form: none) - -#cite(<netwok>, form: "prose") say stuff. - -#bibliography("/assets/bib/works.bib", style: "apa") diff --git a/tests/typ/meta/cite-group.typ b/tests/typ/meta/cite-group.typ deleted file mode 100644 index 331c87ca..00000000 --- a/tests/typ/meta/cite-group.typ +++ /dev/null @@ -1,19 +0,0 @@ -// Test citation grouping. - ---- -A#[@netwok@arrgh]B \ -A@netwok@arrgh B \ -A@netwok @arrgh B \ -A@netwok @arrgh. B \ - -A @netwok#[@arrgh]B \ -A @netwok@arrgh, B \ -A @netwok @arrgh, B \ -A @netwok @arrgh. B \ - -A#[@netwok @arrgh @quark]B. \ -A @netwok @arrgh @quark B. \ -A @netwok @arrgh @quark, B. - -#set text(0pt) -#bibliography("/assets/bib/works.bib") diff --git a/tests/typ/meta/context-compatibility.typ b/tests/typ/meta/context-compatibility.typ deleted file mode 100644 index 60124255..00000000 --- a/tests/typ/meta/context-compatibility.typ +++ /dev/null @@ -1,29 +0,0 @@ -// Test compatibility with the pre-context way of things. -// Ref: false - ---- -#let s = state("x", 0) -#let compute(expr) = [ - #s.update(x => - eval(expr.replace("x", str(x))) - ) - New value is #s.display(). -] - -#locate(loc => { - let elem = query(<here>, loc).first() - test(s.at(elem.location()), 13) -}) - -#compute("10") \ -#compute("x + 3") \ -*Here.* <here> \ -#compute("x * 2") \ -#compute("x - 5") - ---- -#style(styles => measure([it], styles).width < 20pt) - ---- -#counter(heading).update(10) -#counter(heading).display(n => test(n, 10)) diff --git a/tests/typ/meta/context.typ b/tests/typ/meta/context.typ deleted file mode 100644 index 729d9fa2..00000000 --- a/tests/typ/meta/context.typ +++ /dev/null @@ -1,181 +0,0 @@ -// Test context expressions. -// Ref: false - ---- -// Test that context body is parsed as atomic expression. -#let c = [#context "hello".] -#test(c.children.first().func(), (context none).func()) -#test(c.children.last(), [.]) - ---- -// Test that manual construction is forbidden. -// Error: 2-25 cannot be constructed manually -#(context none).func()() - ---- -// Test that `here()` yields the context element's location. -#context test(query(here()).first().func(), (context none).func()) - ---- -// Test whether context is retained in nested function. -#let translate(..args) = args.named().at(text.lang) -#set text(lang: "de") -#context test(translate(de: "Inhalt", en: "Contents"), "Inhalt") - ---- -// Test whether context is retained in built-in callback. -#set text(lang: "de") -#context test( - ("en", "de", "fr").sorted(key: v => v != text.lang), - ("de", "en", "fr"), -) - ---- -// Test `locate` + `here`. -#context test(here().position().y, 10pt) - ---- -// Test `locate`. -#v(10pt) -= Introduction <intro> -#context test(locate(<intro>).position().y, 20pt) - ---- -// Error: 10-25 label `<intro>` does not exist in the document -#context locate(<intro>) - ---- -= Introduction <intro> -= Introduction <intro> - -// Error: 10-25 label `<intro>` occurs multiple times in the document -#context locate(<intro>) - ---- -#v(10pt) -= Introduction <intro> -#context test(locate(heading).position().y, 20pt) - ---- -// Error: 10-25 selector does not match any element -#context locate(heading) - ---- -= Introduction <intro> -= Introduction <intro> - -// Error: 10-25 selector matches multiple elements -#context locate(heading) - ---- -// Test `counter`. -#let c = counter("heading") -#c.update(2) -#c.update(n => n + 2) -#context test(c.get(), (4,)) -#c.update(n => n - 3) -#context test(c.at(here()), (1,)) - ---- -// Test `state.at` outside of context. -// Error: 2-26 can only be used when context is known -// Hint: 2-26 try wrapping this in a `context` expression -// Hint: 2-26 the `context` expression should wrap everything that depends on this function -#state("key").at(<label>) - ---- -// Test `counter.at` outside of context. -// Error: 2-28 can only be used when context is known -// Hint: 2-28 try wrapping this in a `context` expression -// Hint: 2-28 the `context` expression should wrap everything that depends on this function -#counter("key").at(<label>) - ---- -// Test `measure`. -#let f(lo, hi) = context { - let h = measure[Hello].height - assert(h > lo) - assert(h < hi) -} -#text(10pt, f(6pt, 8pt)) -#text(20pt, f(13pt, 14pt)) - ---- -// Test basic get rule. -#context test(text.lang, "en") -#set text(lang: "de") -#context test(text.lang, "de") -#text(lang: "es", context test(text.lang, "es")) - ---- -// Test folding. -#set rect(stroke: red) -#context { - test(type(rect.stroke), stroke) - test(rect.stroke.paint, red) -} -#[ - #set rect(stroke: 4pt) - #context test(rect.stroke, 4pt + red) -] -#context test(rect.stroke, stroke(red)) - ---- -// We have one collision: `figure.caption` could be both the element and a get -// rule for the `caption` field, which is settable. We always prefer the -// element. It's unfortunate, but probably nobody writes -// `set figure(caption: ..)` anyway. -#test(type(figure.caption), function) -#context test(type(figure.caption), function) - ---- -// Error: 10-31 Assertion failed: "en" != "de" -#context test(text.lang, "de") - ---- -// Error: 15-20 function `text` does not contain field `langs` -#context text.langs - ---- -// Error: 18-22 function `heading` does not contain field `body` -#context heading.body - ---- -// Error: 7-11 can only be used when context is known -// Hint: 7-11 try wrapping this in a `context` expression -// Hint: 7-11 the `context` expression should wrap everything that depends on this function -#text.lang - ---- -// Error: 7-12 function `text` does not contain field `langs` -#text.langs - ---- -// Error: 10-14 function `heading` does not contain field `body` -#heading.body - ---- -// Test that show rule establishes context. -#set heading(numbering: "1.") -#show heading: it => test( - counter(heading).get(), - (intro: (1,), back: (2,)).at(str(it.label)), -) - -= Introduction <intro> -= Background <back> - ---- -// Test that show rule on non-locatable element allows `query`. -// Error: 18-47 Assertion failed: 2 != 3 -#show emph: _ => test(query(heading).len(), 3) -#show strong: _ => test(query(heading).len(), 2) -= Introduction -= Background -*Hi* _there_ - ---- -// Test error when captured variable is assigned to. -#let i = 0 -// Error: 11-12 variables from outside the context expression are read-only and cannot be modified -#context (i = 1) diff --git a/tests/typ/meta/counter-page.typ b/tests/typ/meta/counter-page.typ deleted file mode 100644 index 54134b6e..00000000 --- a/tests/typ/meta/counter-page.typ +++ /dev/null @@ -1,10 +0,0 @@ -// Test the page counter. - -#set page(height: 50pt, margin: (bottom: 20pt, rest: 10pt)) -#lorem(12) -#set page(numbering: "(i)") -#lorem(6) -#pagebreak() -#set page(numbering: "1 / 1") -#counter(page).update(1) -#lorem(20) diff --git a/tests/typ/meta/counter.typ b/tests/typ/meta/counter.typ deleted file mode 100644 index 6d72f246..00000000 --- a/tests/typ/meta/counter.typ +++ /dev/null @@ -1,52 +0,0 @@ -// Test counters. - ---- -// Count with string key. -#let mine = counter("mine!") - -Final: #context mine.final().at(0) \ -#mine.step() -First: #context mine.display() \ -#mine.update(7) -#context mine.display("1 of 1", both: true) \ -#mine.step() -#mine.step() -Second: #context mine.display("I") -#mine.update(n => n * 2) -#mine.step() - ---- -// Count labels. -#let label = <heya> -#let count = context counter(label).display() -#let elem(it) = [#box(it) #label] - -#elem[hey, there!] #count \ -#elem[more here!] #count - ---- -// Count headings. -#set heading(numbering: "1.a.") -#show heading: set text(10pt) -#counter(heading).step() - -= Alpha -In #context counter(heading).display() -== Beta - -#set heading(numbering: none) -= Gamma -#heading(numbering: "I.")[Delta] - -At Beta, it was #context { - let it = query(heading).find(it => it.body == [Beta]) - numbering(it.numbering, ..counter(heading).at(it.location())) -} - ---- -// Count figures. -#figure(numbering: "A", caption: [Four 'A's], kind: image, supplement: "Figure")[_AAAA!_] -#figure(numbering: none, caption: [Four 'B's], kind: image, supplement: "Figure")[_BBBB!_] -#figure(caption: [Four 'C's], kind: image, supplement: "Figure")[_CCCC!_] -#counter(figure.where(kind: image)).update(n => n + 3) -#figure(caption: [Four 'D's], kind: image, supplement: "Figure")[_DDDD!_] diff --git a/tests/typ/meta/document.typ b/tests/typ/meta/document.typ deleted file mode 100644 index b058bd96..00000000 --- a/tests/typ/meta/document.typ +++ /dev/null @@ -1,49 +0,0 @@ -// Test document and page-level styles. - ---- -// This is okay. -#set document(title: [Hello]) -What's up? - ---- -// This, too. -// Ref: false -#set document(author: ("A", "B"), date: datetime.today()) - ---- -// Error: 21-28 expected datetime, none, or auto, found string -#set document(date: "today") - ---- -// This, too. -// Error: 23-29 expected string, found integer -#set document(author: (123,)) -What's up? - ---- -Hello - -// Error: 2-30 document set rules must appear before any content -#set document(title: [Hello]) - ---- -// Error: 2-12 can only be used in set rules -#document() - ---- -#box[ - // Error: 4-32 document set rules are not allowed inside of containers - #set document(title: [Hello]) -] - ---- -#box[ - // Error: 4-18 page configuration is not allowed inside of containers - #set page("a4") -] - ---- -#box[ - // Error: 4-15 pagebreaks are not allowed inside of containers - #pagebreak() -] diff --git a/tests/typ/meta/figure-caption.typ b/tests/typ/meta/figure-caption.typ deleted file mode 100644 index 0cdc2bbb..00000000 --- a/tests/typ/meta/figure-caption.typ +++ /dev/null @@ -1,64 +0,0 @@ -// Test figure captions. - ---- -// Test figure.caption element -#show figure.caption: emph - -#figure( - [Not italicized], - caption: [Italicized], -) - ---- -// Test figure.caption element for specific figure kinds -#show figure.caption.where(kind: table): underline - -#figure( - [Not a table], - caption: [Not underlined], -) - -#figure( - table[A table], - caption: [Underlined], -) - ---- -// Test creating custom figure and custom caption - -#let gap = 0.7em -#show figure.where(kind: "custom"): it => rect(inset: gap, { - align(center, it.body) - v(gap, weak: true) - line(length: 100%) - v(gap, weak: true) - align(center, it.caption) -}) - -#figure( - [A figure], - kind: "custom", - caption: [Hi], - supplement: [A], -) - -#show figure.caption: it => emph[ - #it.body - (#it.supplement - #context it.counter.display(it.numbering)) -] - -#figure( - [Another figure], - kind: "custom", - caption: [Hi], - supplement: [B], -) - ---- -// Ref: false -#set figure.caption(position: top) - ---- -// Error: 31-38 expected `top` or `bottom`, found horizon -#set figure.caption(position: horizon) diff --git a/tests/typ/meta/figure-localization.typ b/tests/typ/meta/figure-localization.typ deleted file mode 100644 index 144d9d67..00000000 --- a/tests/typ/meta/figure-localization.typ +++ /dev/null @@ -1,34 +0,0 @@ -// Test localization-related figure features. - ---- -// Test French -#set text(lang: "fr") -#figure( - circle(), - caption: [Un cercle.], -) - ---- -// Test Chinese -#set text(lang: "zh") -#figure( - rect(), - caption: [一个矩形], -) - ---- -// Test Russian -#set text(lang: "ru") - -#figure( - polygon.regular(size: 1cm, vertices: 8), - caption: [Пятиугольник], -) - ---- -// Test Greek -#set text(lang: "gr") -#figure( - circle(), - caption: [Ένας κύκλος.], -) diff --git a/tests/typ/meta/figure.typ b/tests/typ/meta/figure.typ deleted file mode 100644 index b6c1bfd6..00000000 --- a/tests/typ/meta/figure.typ +++ /dev/null @@ -1,111 +0,0 @@ -// Test figures. - ---- -#set page(width: 150pt) -#set figure(numbering: "I") - -We can clearly see that @fig-cylinder and -@tab-complex are relevant in this context. - -#figure( - table(columns: 2)[a][b], - caption: [The basic table.], -) <tab-basic> - -#figure( - pad(y: -6pt, image("/assets/images/cylinder.svg", height: 2cm)), - caption: [The basic shapes.], - numbering: "I", -) <fig-cylinder> - -#figure( - table(columns: 3)[a][b][c][d][e][f], - caption: [The complex table.], -) <tab-complex> - ---- - -// Testing figures with tables. -#figure( - table( - columns: 2, - [Second cylinder], - image("/assets/images/cylinder.svg"), - ), - caption: "A table containing images." -) <fig-image-in-table> - ---- - -// Testing show rules with figures with a simple theorem display -#show figure.where(kind: "theorem"): it => { - let name = none - if not it.caption == none { - name = [ #emph(it.caption.body)] - } else { - name = [] - } - - let title = none - if not it.numbering == none { - title = it.supplement - if not it.numbering == none { - title += " " + it.counter.display(it.numbering) - } - } - title = strong(title) - pad( - top: 0em, bottom: 0em, - block( - fill: green.lighten(90%), - stroke: 1pt + green, - inset: 10pt, - width: 100%, - radius: 5pt, - breakable: false, - [#title#name#h(0.1em):#h(0.2em)#it.body#v(0.5em)] - ) - ) -} - -#set page(width: 150pt) -#figure( - $a^2 + b^2 = c^2$, - supplement: "Theorem", - kind: "theorem", - caption: "Pythagoras' theorem.", - numbering: "1", -) <fig-formula> - -#figure( - $a^2 + b^2 = c^2$, - supplement: "Theorem", - kind: "theorem", - caption: "Another Pythagoras' theorem.", - numbering: none, -) <fig-formula> - -#figure( - ```rust - fn main() { - println!("Hello!"); - } - ```, - caption: [Hello world in _rust_], -) - ---- -// Test breakable figures -#set page(height: 6em) -#show figure: set block(breakable: true) - -#figure(table[a][b][c][d][e], caption: [A table]) - ---- -// Test custom separator for figure caption -#set figure.caption(separator: [ --- ]) - -#figure( - table(columns: 2)[a][b], - caption: [The table with custom separator.], -) diff --git a/tests/typ/meta/footnote-break.typ b/tests/typ/meta/footnote-break.typ deleted file mode 100644 index 9e213aeb..00000000 --- a/tests/typ/meta/footnote-break.typ +++ /dev/null @@ -1,16 +0,0 @@ -// Test footnotes that break across pages. - ---- -#set page(height: 200pt) - -#lorem(5) -#footnote[ // 1 - A simple footnote. - #footnote[Well, not that simple ...] // 2 -] -#lorem(15) -#footnote[Another footnote: #lorem(30)] // 3 -#lorem(15) -#footnote[My fourth footnote: #lorem(50)] // 4 -#lorem(15) -#footnote[And a final footnote.] // 5 diff --git a/tests/typ/meta/footnote-columns.typ b/tests/typ/meta/footnote-columns.typ deleted file mode 100644 index 0dc88930..00000000 --- a/tests/typ/meta/footnote-columns.typ +++ /dev/null @@ -1,9 +0,0 @@ -// Test footnotes in columns, even those -// that are not enabled via `set page`. - ---- -#set page(height: 120pt) -#align(center, strong[Title]) -#show: columns.with(2) -#lorem(3) #footnote(lorem(6)) -Hello there #footnote(lorem(2)) diff --git a/tests/typ/meta/footnote-container.typ b/tests/typ/meta/footnote-container.typ deleted file mode 100644 index 2fa14fac..00000000 --- a/tests/typ/meta/footnote-container.typ +++ /dev/null @@ -1,32 +0,0 @@ -// Test footnotes in containers. - ---- -// Test footnote in caption. -Read the docs #footnote[https://typst.app/docs]! -#figure( - image("/assets/images/graph.png", width: 70%), - caption: [ - A graph #footnote[A _graph_ is a structure with nodes and edges.] - ] -) -More #footnote[just for ...] footnotes #footnote[... testing. :)] - ---- -// Test duplicate footnotes. -#let lang = footnote[Languages.] -#let nums = footnote[Numbers.] - -/ "Hello": A word #lang -/ "123": A number #nums - -- "Hello" #lang -- "123" #nums - -+ "Hello" #lang -+ "123" #nums - -#table( - columns: 2, - [Hello], [A word #lang], - [123], [A number #nums], -) diff --git a/tests/typ/meta/footnote-invariant.typ b/tests/typ/meta/footnote-invariant.typ deleted file mode 100644 index e4d6ded1..00000000 --- a/tests/typ/meta/footnote-invariant.typ +++ /dev/null @@ -1,9 +0,0 @@ -// Ensure that a footnote and the first line of its entry -// always end up on the same page. - ---- -#set page(height: 120pt) - -#lorem(13) - -There #footnote(lorem(20)) diff --git a/tests/typ/meta/footnote-refs.typ b/tests/typ/meta/footnote-refs.typ deleted file mode 100644 index 0caee7bc..00000000 --- a/tests/typ/meta/footnote-refs.typ +++ /dev/null @@ -1,40 +0,0 @@ -// Test references to footnotes. - ---- -A footnote #footnote[Hi]<fn> \ -A reference to it @fn - ---- -// Multiple footnotes are refs -First #footnote[A]<fn1> \ -Second #footnote[B]<fn2> \ -First ref @fn1 \ -Third #footnote[C] \ -Fourth #footnote[D]<fn4> \ -Fourth ref @fn4 \ -Second ref @fn2 \ -Second ref again @fn2 - ---- -// Forward reference -Usage @fn \ -Definition #footnote[Hi]<fn> - ---- -// Footnote ref in footnote -#footnote[Reference to next @fn] -#footnote[Reference to myself @fn]<fn> -#footnote[Reference to previous @fn] - ---- -// Styling -#show footnote: text.with(fill: red) -Real #footnote[...]<fn> \ -Ref @fn - ---- -// Footnote call with label -#footnote(<fn>) -#footnote[Hi]<fn> -#ref(<fn>) -#footnote(<fn>) diff --git a/tests/typ/meta/footnote-table.typ b/tests/typ/meta/footnote-table.typ deleted file mode 100644 index a52d28ba..00000000 --- a/tests/typ/meta/footnote-table.typ +++ /dev/null @@ -1,23 +0,0 @@ -// Test footnotes in tables. When the table spans multiple pages, the footnotes -// will all be after the table, but it shouldn't create any empty pages. ---- - -#set page(height: 100pt) - -= Tables -#table( - columns: 2, - [Hello footnote #footnote[This is a footnote.]], - [This is more text], - [This cell - #footnote[This footnote is not on the same page] - breaks over multiple pages.], - image("/assets/images/tiger.jpg"), -) - -#table( - columns: 3, - ..range(1, 10) - .map(numbering.with("a")) - .map(v => upper(v) + footnote(v)) -) diff --git a/tests/typ/meta/footnote.typ b/tests/typ/meta/footnote.typ deleted file mode 100644 index 8f56fea2..00000000 --- a/tests/typ/meta/footnote.typ +++ /dev/null @@ -1,34 +0,0 @@ -// Test footnotes. - ---- -#footnote[Hi] - ---- -// Test space collapsing before footnote. -A#footnote[A] \ -A #footnote[A] - ---- -// Test nested footnotes. -First \ -Second #footnote[A, #footnote[B, #footnote[C]]] \ -Third #footnote[D, #footnote[E]] \ -Fourth - ---- -// Currently, numbers a bit out of order if a nested footnote ends up in the -// same frame as another one. :( -#footnote[A, #footnote[B]], #footnote[C] - ---- -// Test customization. -#show footnote: set text(red) -#show footnote.entry: set text(8pt, style: "italic") -#set footnote.entry( - indent: 0pt, - gap: 0.6em, - clearance: 0.3em, - separator: repeat[.], -) - -Beautiful footnotes. #footnote[Wonderful, aren't they?] diff --git a/tests/typ/meta/heading.typ b/tests/typ/meta/heading.typ deleted file mode 100644 index a253913e..00000000 --- a/tests/typ/meta/heading.typ +++ /dev/null @@ -1,73 +0,0 @@ -// Test headings. - ---- -// Different number of equals signs. - -= Level 1 -== Level 2 -=== Level 3 - -// After three, it stops shrinking. -=========== Level 11 - ---- -// Heading vs. no heading. - -// Parsed as headings if at start of the context. -/**/ = Level 1 -#[== Level 2] -#box[=== Level 3] - -// Not at the start of the context. -No = heading - -// Escaped. -\= No heading - ---- -// Blocks can continue the heading. - -= #[This -is -multiline. -] - -= This - is not. - ---- -// Test styling. -#show heading.where(level: 5): it => block( - text(font: "Roboto", fill: eastern, it.body + [!]) -) - -= Heading -===== Heading 🌍 -#heading(level: 5)[Heading] - ---- -// Test setting the starting offset. -#set heading(numbering: "1.1") -#show heading.where(level: 2): set text(blue) -= Level 1 - -#heading(depth: 1)[We're twins] -#heading(level: 1)[We're twins] - -== Real level 2 - -#set heading(offset: 1) -= Fake level 2 -== Fake level 3 - ---- -// Passing level directly still overrides all other set values -#set heading(numbering: "1.1", offset: 1) -#heading(level: 1)[Still level 1] - ---- -// Edge cases. -#set heading(numbering: "1.") -= -Not in heading -=Nope diff --git a/tests/typ/meta/link.typ b/tests/typ/meta/link.typ deleted file mode 100644 index dd5bffa8..00000000 --- a/tests/typ/meta/link.typ +++ /dev/null @@ -1,77 +0,0 @@ -// Test hyperlinking. - ---- -// Link syntax. -https://example.com/ - -// Link with body. -#link("https://typst.org/")[Some text text text] - -// With line break. -This link appears #link("https://google.com/")[in the middle of] a paragraph. - -// Certain prefixes are trimmed when using the `link` function. -Contact #link("mailto:hi@typst.app") or -call #link("tel:123") for more information. - ---- -// Test that the period is trimmed. -#show link: underline -https://a.b.?q=%10#. \ -Wahttp://link \ -Nohttps:\//link \ -Nohttp\://comment - ---- -// Verify that brackets are included in links. -https://[::1]:8080/ \ -https://example.com/(paren) \ -https://example.com/#(((nested))) \ - ---- -// Check that unbalanced brackets are not included in links. -#[https://example.com/] \ -https://example.com/) - ---- -// Verify that opening brackets without closing brackets throw an error. -// Error: 1-22 automatic links cannot contain unbalanced brackets, use the `link` function instead -https://exam(ple.com/ - ---- -// Styled with underline and color. -#show link: it => underline(text(fill: rgb("283663"), it)) -You could also make the -#link("https://html5zombo.com/")[link look way more typical.] - ---- -// Transformed link. -#set page(height: 60pt) -#let mylink = link("https://typst.org/")[LINK] -My cool #box(move(dx: 0.7cm, dy: 0.7cm, rotate(10deg, scale(200%, mylink)))) - ---- -// Link containing a block. -#link("https://example.com/", block[ - My cool rhino - #box(move(dx: 10pt, image("/assets/images/rhino.png", width: 1cm))) -]) - ---- -// Link to page one. -#link((page: 1, x: 10pt, y: 20pt))[Back to the start] - ---- -// Test link to label. -Text <hey> -#link(<hey>)[Go to text.] - ---- -// Error: 2-20 label `<hey>` does not exist in the document -#link(<hey>)[Nope.] - ---- -Text <hey> -Text <hey> -// Error: 2-20 label `<hey>` occurs multiple times in the document -#link(<hey>)[Nope.] diff --git a/tests/typ/meta/numbering.typ b/tests/typ/meta/numbering.typ deleted file mode 100644 index 9c0c9b66..00000000 --- a/tests/typ/meta/numbering.typ +++ /dev/null @@ -1,103 +0,0 @@ -// Test integrated numbering patterns. - ---- -#for i in range(0, 9) { - numbering("*", i) - [ and ] - numbering("I.a", i, i) - [ for #i \ ] -} - ---- -#for i in range(0, 4) { - numbering("A", i) - [ for #i \ ] -} -... \ -#for i in range(26, 30) { - numbering("A", i) - [ for #i \ ] -} -... \ -#for i in range(702, 706) { - numbering("A", i) - [ for #i \ ] -} - ---- -#set text(lang: "he") -#for i in range(9, 21, step: 2) { - numbering("א.", i) - [ עבור #i \ ] -} - ---- -#set text(lang: "zh", font: ("Linux Libertine", "Noto Serif CJK SC")) -#for i in range(9, 21, step: 2){ - numbering("一", i) - [ and ] - numbering("壹", i) - [ for #i \ ] -} - ---- -#set text(lang: "ja", font: ("Linux Libertine", "Noto Serif CJK JP")) -#for i in range(0, 4) { - numbering("イ", i) - [ (or ] - numbering("い", i) - [) for #i \ ] -} -... \ -#for i in range(47, 51) { - numbering("イ", i) - [ (or ] - numbering("い", i) - [) for #i \ ] -} -... \ -#for i in range(2256, 2260) { - numbering("イ", i) - [ for #i \ ] -} - ---- -#set text(lang: "ko", font: ("Linux Libertine", "Noto Serif CJK KR")) -#for i in range(0, 4) { - numbering("가", i) - [ (or ] - numbering("ㄱ", i) - [) for #i \ ] -} -... \ -#for i in range(47, 51) { - numbering("가", i) - [ (or ] - numbering("ㄱ", i) - [) for #i \ ] -} -... \ -#for i in range(2256, 2260) { - numbering("ㄱ", i) - [ for #i \ ] -} - ---- -#set text(lang: "jp", font: ("Linux Libertine", "Noto Serif CJK JP")) -#for i in range(0, 9) { - numbering("あ", i) - [ and ] - numbering("I.あ", i, i) - [ for #i \ ] -} - -#for i in range(0, 9) { - numbering("ア", i) - [ and ] - numbering("I.ア", i, i) - [ for #i \ ] -} - ---- -// Error: 17-19 number must be at least zero -#numbering("1", -1) diff --git a/tests/typ/meta/outline-entry.typ b/tests/typ/meta/outline-entry.typ deleted file mode 100644 index 74a785a9..00000000 --- a/tests/typ/meta/outline-entry.typ +++ /dev/null @@ -1,59 +0,0 @@ -// Tests outline entry. - ---- -#set page(width: 150pt) -#set heading(numbering: "1.") - -#show outline.entry.where( - level: 1 -): it => { - v(12pt, weak: true) - strong(it) -} - -#outline(indent: auto) - -#set text(8pt) -#show heading: set block(spacing: 0.65em) - -= Introduction -= Background -== History -== State of the Art -= Analysis -== Setup - ---- -#set page(width: 150pt, numbering: "I", margin: (bottom: 20pt)) -#set heading(numbering: "1.") -#show outline.entry.where(level: 1): it => [ - #let loc = it.element.location() - #let num = numbering(loc.page-numbering(), ..counter(page).at(loc)) - #emph(link(loc, it.body)) - #text(luma(100), box(width: 1fr, repeat[#it.fill.body;·])) - #link(loc, num) -] - -#counter(page).update(3) -#outline(indent: auto, fill: repeat[--]) - -#set text(8pt) -#show heading: set block(spacing: 0.65em) - -= Top heading -== Not top heading -=== Lower heading -=== Lower too -== Also not top - -#pagebreak() -#set page(numbering: "1") - -= Another top heading -== Middle heading -=== Lower heading - ---- -// Error: 2-27 cannot outline metadata -#outline(target: metadata) -#metadata("hello") diff --git a/tests/typ/meta/outline-first-par-indent.typ b/tests/typ/meta/outline-first-par-indent.typ deleted file mode 100644 index 77396634..00000000 --- a/tests/typ/meta/outline-first-par-indent.typ +++ /dev/null @@ -1,15 +0,0 @@ -#set par(first-line-indent: 1.5em) -#set heading(numbering: "1.1.a.") -#show outline.entry.where(level: 1): it => { - v(0.5em, weak: true) - strong(it) -} - -#outline() - -= Introduction -= Background -== History -== State of the Art -= Analysis -== Setup diff --git a/tests/typ/meta/outline-indent.typ b/tests/typ/meta/outline-indent.typ deleted file mode 100644 index b0132d43..00000000 --- a/tests/typ/meta/outline-indent.typ +++ /dev/null @@ -1,60 +0,0 @@ -// Tests outline 'indent' option. - ---- -// With heading numbering -#set page(width: 200pt) -#set heading(numbering: "1.a.") -#outline() -#outline(indent: false) -#outline(indent: true) -#outline(indent: none) -#outline(indent: auto) -#outline(indent: 2em) -#outline(indent: n => ([-], [], [==], [====]).at(n)) -#outline(indent: n => "!" * calc.pow(2, n)) - -= About ACME Corp. - -== History -#lorem(10) - -== Products -#lorem(10) - -=== Categories -#lorem(10) - -==== General -#lorem(10) - ---- -// Without heading numbering -#set page(width: 200pt) -#outline() -#outline(indent: false) -#outline(indent: true) -#outline(indent: none) -#outline(indent: auto) -#outline(indent: n => 2em * n) -#outline(indent: n => ([-], [], [==], [====]).at(n)) -#outline(indent: n => "!" * calc.pow(2, n)) - -= About ACME Corp. - -== History -#lorem(10) - -== Products -#lorem(10) - -=== Categories -#lorem(10) - -==== General -#lorem(10) - ---- -// Error: 2-35 expected relative length or content, found dictionary -#outline(indent: n => (a: "dict")) - -= Heading diff --git a/tests/typ/meta/outline.typ b/tests/typ/meta/outline.typ deleted file mode 100644 index 1d0bcf75..00000000 --- a/tests/typ/meta/outline.typ +++ /dev/null @@ -1,45 +0,0 @@ -#set page("a7", margin: 20pt, numbering: "1") -#set heading(numbering: "(1/a)") -#show heading.where(level: 1): set text(12pt) -#show heading.where(level: 2): set text(10pt) -#set math.equation(numbering: "1") - -#outline() -#outline(title: [Figures], target: figure) -#outline(title: [Equations], target: math.equation) - -= Introduction -#lorem(12) - -= Analysis -#lorem(10) - -#[ - #set heading(outlined: false) - == Methodology - #lorem(6) -] - -== Math -$x$ is a very useful constant. See it in action: -$ x = x $ - -== Interesting figures -#figure(rect[CENSORED], kind: image, caption: [A picture showing a programmer at work.]) -#figure(table[1x1], caption: [A very small table.]) - -== Programming -```rust -fn main() { - panic!("in the disco"); -} -``` - -==== Deep Stuff -Ok ... - -// Ensure 'bookmarked' option doesn't affect the outline -#set heading(numbering: "(I)", bookmarked: false) - -= #text(blue)[Sum]mary -#lorem(10) diff --git a/tests/typ/meta/page-label.typ b/tests/typ/meta/page-label.typ deleted file mode 100644 index 8d12fb13..00000000 --- a/tests/typ/meta/page-label.typ +++ /dev/null @@ -1,47 +0,0 @@ -#set page(margin: (bottom: 20pt, rest: 10pt)) -#let filler = lorem(20) - -// (i) - (ii). No style opt. because of suffix. -#set page(numbering: "(i)") -#filler -#pagebreak() -#filler - -// 3 - 4. Style opt. Page Label should use /D style. -#set page(numbering: "1") -#filler -#pagebreak() -#filler - -// I - IV. Style opt. Page Label should use /R style and start at 1 again. -#set page(numbering: "I / I") -#counter(page).update(1) -#filler -#pagebreak() -#filler -#pagebreak() -#filler -#pagebreak() -#filler - -// Pre: ほ, Pre: ろ, Pre: は, Pre: に. No style opt. Uses prefix field entirely. -// Counter update without numbering change. -#set page(numbering: "Pre: い") -#filler -#pagebreak() -#filler -#counter(page).update(2) -#filler -#pagebreak() -#filler -#pagebreak() -#filler - -// aa & ba. Style opt only for values <= 26. Page Label uses lower alphabet style. -// Repeats letter each 26 pages or uses numbering directly as prefix. -#set page(numbering: "a") -#counter(page).update(27) -#filler -#pagebreak() -#counter(page).update(53) -#filler diff --git a/tests/typ/meta/query-before-after.typ b/tests/typ/meta/query-before-after.typ deleted file mode 100644 index 5f134093..00000000 --- a/tests/typ/meta/query-before-after.typ +++ /dev/null @@ -1,69 +0,0 @@ - ---- -#set page( - paper: "a7", - numbering: "1 / 1", - margin: (bottom: 1cm, rest: 0.5cm), -) - -#show heading.where(level: 1, outlined: true): it => [ - #it - - #set text(size: 12pt, weight: "regular") - #outline( - title: "Chapter outline", - indent: true, - target: heading - .where(level: 1) - .or(heading.where(level: 2)) - .after(it.location(), inclusive: true) - .before( - heading - .where(level: 1, outlined: true) - .after(it.location(), inclusive: false), - inclusive: false, - ) - ) -] - -#set heading(outlined: true, numbering: "1.") - -= Section 1 -== Subsection 1 -== Subsection 2 -=== Subsubsection 1 -=== Subsubsection 2 -== Subsection 3 - -= Section 2 -== Subsection 1 -== Subsection 2 - -= Section 3 -== Subsection 1 -== Subsection 2 -=== Subsubsection 1 -=== Subsubsection 2 -=== Subsubsection 3 -== Subsection 3 - ---- - -#set page( - paper: "a7", - numbering: "1 / 1", - margin: (bottom: 1cm, rest: 0.5cm), -) - -#set heading(outlined: true, numbering: "1.") - -#context [ - Non-outlined elements: - #(query(selector(heading).and(heading.where(outlined: false))) - .map(it => it.body).join(", ")) -] - -#heading("A", outlined: false) -#heading("B", outlined: true) -#heading("C", outlined: true) -#heading("D", outlined: false) diff --git a/tests/typ/meta/query-figure.typ b/tests/typ/meta/query-figure.typ deleted file mode 100644 index 1fe82372..00000000 --- a/tests/typ/meta/query-figure.typ +++ /dev/null @@ -1,41 +0,0 @@ -// Test a list of figures. - ---- -#set page( - paper: "a7", - numbering: "1 / 1", - margin: (bottom: 1cm, rest: 0.5cm), -) - -#set figure(numbering: "I") -#show figure: set image(width: 80%) - -= List of Figures -#context { - let elements = query(selector(figure).after(here())) - for it in elements [ - Figure - #numbering(it.numbering, - ..counter(figure).at(it.location())): - #it.caption.body - #box(width: 1fr, repeat[.]) - #counter(page).at(it.location()).first() \ - ] -} - -#figure( - image("/assets/images/glacier.jpg"), - caption: [Glacier melting], -) - -#figure( - rect[Just some stand-in text], - kind: image, - supplement: "Figure", - caption: [Stand-in text], -) - -#figure( - image("/assets/images/tiger.jpg"), - caption: [Tiger world], -) diff --git a/tests/typ/meta/query-header.typ b/tests/typ/meta/query-header.typ deleted file mode 100644 index 5cbaa995..00000000 --- a/tests/typ/meta/query-header.typ +++ /dev/null @@ -1,30 +0,0 @@ -// Test creating a header with the query function. - ---- -#set page( - paper: "a7", - margin: (y: 1cm, x: 0.5cm), - header: context { - smallcaps[Typst Academy] - h(1fr) - let after = query(selector(heading).after(here())) - let before = query(selector(heading).before(here())) - let elem = if before.len() != 0 { - before.last() - } else if after.len() != 0 { - after.first() - } - emph(elem.body) - } -) - -#outline() - -= Introduction -#lorem(35) - -= Background -#lorem(35) - -= Approach -#lorem(60) diff --git a/tests/typ/meta/ref.typ b/tests/typ/meta/ref.typ deleted file mode 100644 index 4cc824d7..00000000 --- a/tests/typ/meta/ref.typ +++ /dev/null @@ -1,48 +0,0 @@ -// Test references. - ---- -#set heading(numbering: "1.") - -= Introduction <intro> -See @setup. - -== Setup <setup> -As seen in @intro, we proceed. - ---- -// Error: 1-5 label `<foo>` does not exist in the document -@foo - ---- -= First <foo> -= Second <foo> - -// Error: 1-5 label `<foo>` occurs multiple times in the document -@foo - ---- -#set heading(numbering: "1.", supplement: [Chapter]) -#set math.equation(numbering: "(1)", supplement: [Eq.]) - -= Intro -#figure( - image("/assets/images/cylinder.svg", height: 1cm), - caption: [A cylinder.], - supplement: "Fig", -) <fig1> - -#figure( - image("/assets/images/tiger.jpg", height: 1cm), - caption: [A tiger.], - supplement: "Tig", -) <fig2> - -$ A = 1 $ <eq1> - -#set math.equation(supplement: none) -$ A = 1 $ <eq2> - -@fig1, @fig2, @eq1, (@eq2) - -#set ref(supplement: none) -@fig1, @fig2, @eq1, @eq2 diff --git a/tests/typ/meta/state.typ b/tests/typ/meta/state.typ deleted file mode 100644 index 3fa8ece7..00000000 --- a/tests/typ/meta/state.typ +++ /dev/null @@ -1,56 +0,0 @@ -// Test state. - ---- -#let s = state("hey", "a") -#let double(it) = 2 * it - -#s.update(double) -#s.update(double) -$ 2 + 3 $ -#s.update(double) - -Is: #context s.get(), -Was: #context { - let it = query(math.equation).first() - s.at(it.location()) -}. - ---- -// Try same key with different initial value. -#context state("key", 2).get() -#state("key").update(x => x + 1) -#context state("key", 2).get() -#context state("key", 3).get() -#state("key").update(x => x + 1) -#context state("key", 2).get() - ---- -#set page(width: 200pt) -#set text(8pt) - -#let ls = state("lorem", lorem(1000).split(".")) -#let loremum(count) = { - context ls.get().slice(0, count).join(".").trim() + "." - ls.update(list => list.slice(count)) -} - -#let fs = state("fader", red) -#let trait(title) = block[ - #context text(fill: fs.get())[ - *#title:* #loremum(1) - ] - #fs.update(color => color.lighten(30%)) -] - -#trait[Boldness] -#trait[Adventure] -#trait[Fear] -#trait[Anger] - ---- -// Make sure that a warning is produced if the layout fails to converge. -// Warning: layout did not converge within 5 attempts -// Hint: check if any states or queries are updating themselves -#let s = state("s", 1) -#context s.update(s.final() + 1) -#context s.get() |
