From 1f8128111825410fdfcea056448fb37fe92a589e Mon Sep 17 00:00:00 2001 From: Leedehai <18319900+Leedehai@users.noreply.github.com> Date: Mon, 5 Aug 2024 06:04:35 -0400 Subject: Fix the show rule effect for bibliography heading level (#4622) --- crates/typst/src/model/bibliography.rs | 2 +- tests/ref/issue-4618-bibliography-set-heading-level.png | Bin 0 -> 5227 bytes tests/suite/model/bibliography.typ | 13 +++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/ref/issue-4618-bibliography-set-heading-level.png diff --git a/crates/typst/src/model/bibliography.rs b/crates/typst/src/model/bibliography.rs index ed593d45..71616616 100644 --- a/crates/typst/src/model/bibliography.rs +++ b/crates/typst/src/model/bibliography.rs @@ -217,7 +217,7 @@ impl Show for Packed { }) { seq.push( HeadingElem::new(title) - .with_level(Smart::Custom(NonZeroUsize::ONE)) + .with_depth(NonZeroUsize::ONE) .pack() .spanned(self.span()), ); diff --git a/tests/ref/issue-4618-bibliography-set-heading-level.png b/tests/ref/issue-4618-bibliography-set-heading-level.png new file mode 100644 index 00000000..29a4e517 Binary files /dev/null and b/tests/ref/issue-4618-bibliography-set-heading-level.png differ diff --git a/tests/suite/model/bibliography.typ b/tests/suite/model/bibliography.typ index 7197082f..18c62620 100644 --- a/tests/suite/model/bibliography.typ +++ b/tests/suite/model/bibliography.typ @@ -53,3 +53,16 @@ Now we have multiple bibliographies containing @glacier-melt @keshav2007read @Zee04 #bibliography("/assets/bib/works_too.bib", style: "mla") + +--- issue-4618-bibliography-set-heading-level --- +// Test that the bibliography block's heading is set to 2 by the show rule, +// and therefore should be rendered like a level-2 heading. Notably, this +// bibliography heading should not be underlined. +#show heading.where(level: 1): it => [ #underline(it.body) ] +#show bibliography: set heading(level: 2) + += Level 1 +== Level 2 +@Zee04 + +#bibliography("/assets/bib/works_too.bib") -- cgit v1.2.3