From 8ed1eff7b5b76b72eef8e67ee9120e5d24925aa7 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 14 Feb 2024 09:45:25 +0100 Subject: Fix text show-set regression (#3410) --- crates/typst/src/realize/process.rs | 6 ++++- tests/ref/compiler/show-set-text.png | Bin 0 -> 8734 bytes tests/typ/compiler/show-set-text.typ | 41 +++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/ref/compiler/show-set-text.png create mode 100644 tests/typ/compiler/show-set-text.typ diff --git a/crates/typst/src/realize/process.rs b/crates/typst/src/realize/process.rs index 73d5cc4f..a5acd8fc 100644 --- a/crates/typst/src/realize/process.rs +++ b/crates/typst/src/realize/process.rs @@ -129,7 +129,11 @@ fn verdict<'a>( continue; } - if let Transformation::Style(transform) = &recipe.transform { + // Special handling for show-set rules. Exception: Regex show rules, + // those need to be handled like normal transformations. + if let (Transformation::Style(transform), false) = + (&recipe.transform, matches!(&recipe.selector, Some(Selector::Regex(_)))) + { // If this is a show-set for an unprepared element, we need to apply // it. if !prepared { diff --git a/tests/ref/compiler/show-set-text.png b/tests/ref/compiler/show-set-text.png new file mode 100644 index 00000000..27803e8a Binary files /dev/null and b/tests/ref/compiler/show-set-text.png differ diff --git a/tests/typ/compiler/show-set-text.typ b/tests/typ/compiler/show-set-text.typ new file mode 100644 index 00000000..464cad90 --- /dev/null +++ b/tests/typ/compiler/show-set-text.typ @@ -0,0 +1,41 @@ +// Text show-set rules are weird. + +--- +#show "He": set text(red) +#show "ya": set text(blue) +Heya + +--- +#show "Heya": set text(red) +#show "ya": set text(blue) +Heya + +--- +#show "He": set text(red) +#show "Heya": set text(blue) +Heya + +--- +#show "Heya": set text(red) +#show "yaho": set text(blue) +Heyaho + +--- +#show "He": set text(red) +#show "ya": set text(weight: "bold") +Heya + +--- +#show "Heya": set text(red) +#show "ya": set text(weight: "bold") +Heya + +--- +#show "He": set text(red) +#show "Heya": set text(weight: "bold") +Heya + +--- +#show "Heya": set text(red) +#show "yaho": set text(weight: "bold") +Heyaho -- cgit v1.2.3