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