diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-01-30 12:50:58 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-01-30 22:46:59 +0100 |
| commit | 8d1ce390e21ce0a5812a4211c893ec359906d6f1 (patch) | |
| tree | 5dbe1ad96af8ce8f9f01887340fe06025462e959 /tests | |
| parent | d7072f378fef733ae994fd9a1e767df4e4dd878e (diff) | |
Rework strong and emph
- Star and underscore not parsed as strong/emph inside of words
- Stars/underscores must be balanced and they cannot go over paragraph break
- New `strong` and `emph` classes
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ref/markup/emph-strong.png | bin | 0 -> 6988 bytes | |||
| -rw-r--r-- | tests/ref/markup/emph.png | bin | 3772 -> 0 bytes | |||
| -rw-r--r-- | tests/ref/markup/strong.png | bin | 3481 -> 0 bytes | |||
| -rw-r--r-- | tests/ref/style/set-toggle.png | bin | 1188 -> 0 bytes | |||
| -rw-r--r-- | tests/typ/code/ops.typ | 2 | ||||
| -rw-r--r-- | tests/typ/markup/emph-strong.typ | 33 | ||||
| -rw-r--r-- | tests/typ/markup/emph.typ | 11 | ||||
| -rw-r--r-- | tests/typ/markup/escape.typ | 2 | ||||
| -rw-r--r-- | tests/typ/markup/strong.typ | 11 | ||||
| -rw-r--r-- | tests/typ/style/set-toggle.typ | 10 | ||||
| -rw-r--r-- | tests/typ/style/wrap.typ | 2 | ||||
| -rw-r--r-- | tests/typ/text/bidi.typ | 4 | ||||
| -rw-r--r-- | tests/typ/text/linebreaks.typ | 2 | ||||
| -rw-r--r-- | tests/typeset.rs | 5 |
14 files changed, 43 insertions, 39 deletions
diff --git a/tests/ref/markup/emph-strong.png b/tests/ref/markup/emph-strong.png Binary files differnew file mode 100644 index 00000000..cce98812 --- /dev/null +++ b/tests/ref/markup/emph-strong.png diff --git a/tests/ref/markup/emph.png b/tests/ref/markup/emph.png Binary files differdeleted file mode 100644 index 6b3bfb2d..00000000 --- a/tests/ref/markup/emph.png +++ /dev/null diff --git a/tests/ref/markup/strong.png b/tests/ref/markup/strong.png Binary files differdeleted file mode 100644 index 53062e9a..00000000 --- a/tests/ref/markup/strong.png +++ /dev/null diff --git a/tests/ref/style/set-toggle.png b/tests/ref/style/set-toggle.png Binary files differdeleted file mode 100644 index daaa3d6c..00000000 --- a/tests/ref/style/set-toggle.png +++ /dev/null diff --git a/tests/typ/code/ops.typ b/tests/typ/code/ops.typ index be2cdb48..e3e2e855 100644 --- a/tests/typ/code/ops.typ +++ b/tests/typ/code/ops.typ @@ -4,7 +4,7 @@ --- // Test template addition. // Ref: true -{[*Hello ] + [world!]} +{[*Hello* ] + [world!]} --- // Test math operators. diff --git a/tests/typ/markup/emph-strong.typ b/tests/typ/markup/emph-strong.typ new file mode 100644 index 00000000..9bdb5059 --- /dev/null +++ b/tests/typ/markup/emph-strong.typ @@ -0,0 +1,33 @@ +// Test emph and strong. + +--- +// Basic. +_Emphasized and *strong* words!_ + +// Inside of a word it's a normal underscore or star. +hello_world Nutzer*innen + +// Can contain paragraph in child template. +_Still [ + +] emphasized._ + +--- +// Inside of words can still use the functions. +P#strong[art]ly em#emph[phas]ized. + +--- +// Error: 13 expected underscore +#box[_Scoped] to body. + +--- +// Ends at paragraph break. +// Error: 7 expected underscore +_Hello + +World + +--- +// Error: 1:12 expected star +// Error: 2:1 expected star +_Cannot *be_ interleaved* diff --git a/tests/typ/markup/emph.typ b/tests/typ/markup/emph.typ deleted file mode 100644 index 77ac2c72..00000000 --- a/tests/typ/markup/emph.typ +++ /dev/null @@ -1,11 +0,0 @@ -// Test emphasis toggle. - ---- -// Basic. -_Emphasized!_ - -// Inside of words. -Partly em_phas_ized. - -// Scoped to body. -#box[_Scoped] to body. diff --git a/tests/typ/markup/escape.typ b/tests/typ/markup/escape.typ index c039e0b7..87d2b83a 100644 --- a/tests/typ/markup/escape.typ +++ b/tests/typ/markup/escape.typ @@ -32,4 +32,4 @@ let f() , ; : | + - /= == 12 "string" --- // Unterminated. // Error: 6 expected closing brace -\u{41*Bold* +\u{41[*Bold*] diff --git a/tests/typ/markup/strong.typ b/tests/typ/markup/strong.typ deleted file mode 100644 index d396cc2d..00000000 --- a/tests/typ/markup/strong.typ +++ /dev/null @@ -1,11 +0,0 @@ -// Test strong toggle. - ---- -// Basic. -*Strong!* - -// Inside of words. -Partly str*ength*ened. - -// Scoped to body. -#box[*Scoped] to body. diff --git a/tests/typ/style/set-toggle.typ b/tests/typ/style/set-toggle.typ deleted file mode 100644 index 9f26bdf7..00000000 --- a/tests/typ/style/set-toggle.typ +++ /dev/null @@ -1,10 +0,0 @@ -// Test set rules for toggleable booleans. - ---- -// Test toggling and untoggling. -*AB_C*DE -*_* - ---- -// Test toggling and nested templates. -*A[B*[_C]]D*E diff --git a/tests/typ/style/wrap.typ b/tests/typ/style/wrap.typ index 1ff3cc95..2fa7716e 100644 --- a/tests/typ/style/wrap.typ +++ b/tests/typ/style/wrap.typ @@ -16,7 +16,7 @@ in booklovers and the great fulfiller of human need. --- // Test wrap in template. -A [_B #wrap c in [*#c*]; C] D +A [_B #wrap c in [*#c*]; C_] D --- // Test wrap style precedence. diff --git a/tests/typ/text/bidi.typ b/tests/typ/text/bidi.typ index 658c7fa6..09e23558 100644 --- a/tests/typ/text/bidi.typ +++ b/tests/typ/text/bidi.typ @@ -10,7 +10,7 @@ --- // Test that consecutive, embedded LTR runs stay LTR. // Here, we have two runs: "A" and italic "B". -#let content = [أنت A_B_مطرC] +#let content = [أنت A#emph[B]مطرC] #set text(serif, "Noto Sans Arabic") #par(lang: "ar", content) #par(lang: "de", content) @@ -18,7 +18,7 @@ --- // Test that consecutive, embedded RTL runs stay RTL. // Here, we have three runs: "גֶ", bold "שֶׁ", and "ם". -#let content = [Aגֶ*שֶׁ*םB] +#let content = [Aגֶ#strong[שֶׁ]םB] #set text(serif, "Noto Serif Hebrew") #par(lang: "he", content) #par(lang: "de", content) diff --git a/tests/typ/text/linebreaks.typ b/tests/typ/text/linebreaks.typ index 5f886381..de99f5ed 100644 --- a/tests/typ/text/linebreaks.typ +++ b/tests/typ/text/linebreaks.typ @@ -10,7 +10,7 @@ Supercalifragilisticexpialidocious Expialigoricmetrioxidation. --- // Test that there are no unwanted line break opportunities on run change. -This is partly emp_has_ized. +This is partly emp#emph[has]ized. --- Hard \ break. diff --git a/tests/typeset.rs b/tests/typeset.rs index 5437860b..64749975 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -259,6 +259,8 @@ fn test_part( debug: bool, rng: &mut LinearShift, ) -> (bool, bool, Vec<Rc<Frame>>) { + let mut ok = true; + let id = ctx.sources.provide(src_path, src); let source = ctx.sources.get(id); if debug { @@ -267,7 +269,8 @@ fn test_part( let (local_compare_ref, mut ref_errors) = parse_metadata(&source); let compare_ref = local_compare_ref.unwrap_or(compare_ref); - let mut ok = test_reparse(ctx.sources.get(id).src(), i, rng); + + ok &= test_reparse(ctx.sources.get(id).src(), i, rng); let (frames, mut errors) = match ctx.evaluate(id) { Ok(module) => { |
