diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-03-21 17:46:09 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-03-21 17:50:56 +0100 |
| commit | 5e08028fb36aa766957cba64c5c665edf9b96fb7 (patch) | |
| tree | 912799dad3c1e25b7032f3e3bee009537c6f555b /tests | |
| parent | 898728f260923a91444eb23b522d0abf01a4299b (diff) | |
Syntax functions 🚀
This adds overridable functions that markup desugars into. Specifically:
- \ desugars into linebreak
- Two newlines desugar into parbreak
- * desugars into strong
- _ desugars into emph
- = .. desugars into heading
- `..` desugars into raw
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/markup/emph.png | bin | 3053 -> 3387 bytes | |||
| -rw-r--r-- | tests/ref/markup/heading.png | bin | 4540 -> 5288 bytes | |||
| -rw-r--r-- | tests/ref/markup/linebreak.png | bin | 3770 -> 4307 bytes | |||
| -rw-r--r-- | tests/ref/markup/parbreak.png | bin | 0 -> 1654 bytes | |||
| -rw-r--r-- | tests/ref/markup/raw.png | bin | 7291 -> 8299 bytes | |||
| -rw-r--r-- | tests/ref/markup/strong.png | bin | 2824 -> 3374 bytes | |||
| -rw-r--r-- | tests/typ/expr/ops.typ | 3 | ||||
| -rw-r--r-- | tests/typ/library/paragraph.typ | 4 | ||||
| -rw-r--r-- | tests/typ/markup/emph.typ | 13 | ||||
| -rw-r--r-- | tests/typ/markup/heading.typ | 8 | ||||
| -rw-r--r-- | tests/typ/markup/linebreak.typ | 8 | ||||
| -rw-r--r-- | tests/typ/markup/parbreak.typ | 11 | ||||
| -rw-r--r-- | tests/typ/markup/raw.typ | 8 | ||||
| -rw-r--r-- | tests/typ/markup/strong.typ | 12 | ||||
| -rw-r--r-- | tests/typeset.rs | 2 |
15 files changed, 59 insertions, 10 deletions
diff --git a/tests/ref/markup/emph.png b/tests/ref/markup/emph.png Binary files differindex 75231a62..f43eeecb 100644 --- a/tests/ref/markup/emph.png +++ b/tests/ref/markup/emph.png diff --git a/tests/ref/markup/heading.png b/tests/ref/markup/heading.png Binary files differindex 3473f798..515788f3 100644 --- a/tests/ref/markup/heading.png +++ b/tests/ref/markup/heading.png diff --git a/tests/ref/markup/linebreak.png b/tests/ref/markup/linebreak.png Binary files differindex 4e4702f9..aa01c99a 100644 --- a/tests/ref/markup/linebreak.png +++ b/tests/ref/markup/linebreak.png diff --git a/tests/ref/markup/parbreak.png b/tests/ref/markup/parbreak.png Binary files differnew file mode 100644 index 00000000..008afca2 --- /dev/null +++ b/tests/ref/markup/parbreak.png diff --git a/tests/ref/markup/raw.png b/tests/ref/markup/raw.png Binary files differindex 59a4e3dd..1aebc02d 100644 --- a/tests/ref/markup/raw.png +++ b/tests/ref/markup/raw.png diff --git a/tests/ref/markup/strong.png b/tests/ref/markup/strong.png Binary files differindex 7e62f0f3..20e29b1f 100644 --- a/tests/ref/markup/strong.png +++ b/tests/ref/markup/strong.png diff --git a/tests/typ/expr/ops.typ b/tests/typ/expr/ops.typ index 2390b7b4..ef249c43 100644 --- a/tests/typ/expr/ops.typ +++ b/tests/typ/expr/ops.typ @@ -122,10 +122,7 @@ #test((1, 2, 3) == (1, 2.0) + (3,), true) #test((:) == (a: 1), false) #test((a: 2 - 1.0, b: 2) == (b: 2, a: 1), true) -#test([*Hi*] == [*Hi*], true) - #test("a" != "a", false) -#test([*] != [_], true) --- // Test comparison operators. diff --git a/tests/typ/library/paragraph.typ b/tests/typ/library/paragraph.typ index 3ce946bd..74fb8189 100644 --- a/tests/typ/library/paragraph.typ +++ b/tests/typ/library/paragraph.typ @@ -3,11 +3,11 @@ --- // Test configuring paragraph properties. -#paragraph(spacing: 10pt, leading: 25%, word-spacing: 1pt) +#par(spacing: 10pt, leading: 25%, word-spacing: 1pt) But, soft! what light through yonder window breaks? It is the east, and Juliet is the sun. --- // Test that it finishes an existing paragraph. -Hello #paragraph(word-spacing: 0pt) t h e r e ! +Hello #par(word-spacing: 0pt) t h e r e ! diff --git a/tests/typ/markup/emph.typ b/tests/typ/markup/emph.typ index 500381c1..8e25e7d3 100644 --- a/tests/typ/markup/emph.typ +++ b/tests/typ/markup/emph.typ @@ -10,5 +10,14 @@ Partly em_phas_ized. // Scoped to body. #rect[_Scoped] to body. -// Unterminated is fine. -_The End +--- +#let emph = strong +_Strong_ + +#let emph() = "Hi" +_, _! + +#let emph = "hi" + +// Error: 1-2 expected function, found string +_ diff --git a/tests/typ/markup/heading.typ b/tests/typ/markup/heading.typ index 15c391d1..9bbe3415 100644 --- a/tests/typ/markup/heading.typ +++ b/tests/typ/markup/heading.typ @@ -42,3 +42,11 @@ No = heading // Escaped. \= No heading + +--- +// Make small, but double heading. +#let heading(contents) = heading(contents + contents, level: 6) + +// The new heading's argument list doesn't contain `level`. +// Error: 1-11 unexpected argument +=== Twice. diff --git a/tests/typ/markup/linebreak.typ b/tests/typ/markup/linebreak.typ index e6392992..a0a501b6 100644 --- a/tests/typ/markup/linebreak.typ +++ b/tests/typ/markup/linebreak.typ @@ -21,3 +21,11 @@ Trailing 2 // Trailing before end of document. Trailing 3 \ + +--- +#let linebreak() = [ + // Inside the old line break definition is still active. + #circle(radius: 2pt, fill: #000) \ +] + +A \ B \ C \ diff --git a/tests/typ/markup/parbreak.typ b/tests/typ/markup/parbreak.typ new file mode 100644 index 00000000..b9b8a222 --- /dev/null +++ b/tests/typ/markup/parbreak.typ @@ -0,0 +1,11 @@ +// Test paragraph breaks. + +--- +// Paragraph breaks don't exist! +#let parbreak() = [ ] + +No more + +paragraph breaks + +for you! diff --git a/tests/typ/markup/raw.typ b/tests/typ/markup/raw.typ index 005d413e..cae3d261 100644 --- a/tests/typ/markup/raw.typ +++ b/tests/typ/markup/raw.typ @@ -46,6 +46,14 @@ def hi(): ``` --- +// Make everything block-level. +#let raw(text) = raw(text, block: true) + +// The new raw's argument list doesn't contain `block`. +// Error: 6-10 unexpected argument +This `is` block-level. + +--- // Unterminated. // Error: 2:1 expected backtick(s) `endless diff --git a/tests/typ/markup/strong.typ b/tests/typ/markup/strong.typ index a56e0e1c..6a6fc04a 100644 --- a/tests/typ/markup/strong.typ +++ b/tests/typ/markup/strong.typ @@ -10,5 +10,13 @@ Partly str*ength*ened. // Scoped to body. #rect[*Scoped] to body. -// Unterminated is fine. -*The End +--- +#let strong = emph +*Emph* + +#let strong() = "Bye" +*, *! + +#let strong = 123 +// Error: 1-2 expected function, found integer +* diff --git a/tests/typeset.rs b/tests/typeset.rs index 2cf6bfb6..0a22c96b 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -209,7 +209,7 @@ fn test_part( let (local_compare_ref, ref_diags) = parse_metadata(src, &map); let compare_ref = local_compare_ref.unwrap_or(compare_ref); - let mut scope = library::new(); + let mut scope = library::_new(); let panics = Rc::new(RefCell::new(vec![])); register_helpers(&mut scope, Rc::clone(&panics)); |
