From a6ab6ac99a3db30d833f60e59959785f60fdc853 Mon Sep 17 00:00:00 2001 From: Andrew Voynov <37143421+Andrew15-5@users.noreply.github.com> Date: Tue, 10 Jun 2025 20:59:06 +0300 Subject: [PATCH] Specify which CSL style is not suitable for bibliographies (#6306) Co-authored-by: Laurenz --- crates/typst-library/src/model/bibliography.rs | 10 +++++++++- tests/suite/model/bibliography.typ | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/typst-library/src/model/bibliography.rs b/crates/typst-library/src/model/bibliography.rs index 114356575..2a80f67d9 100644 --- a/crates/typst-library/src/model/bibliography.rs +++ b/crates/typst-library/src/model/bibliography.rs @@ -227,7 +227,15 @@ impl Show for Packed { let references = works .references .as_ref() - .ok_or("CSL style is not suitable for bibliographies") + .ok_or_else(|| match self.style(styles).source { + CslSource::Named(style) => eco_format!( + "CSL style \"{}\" is not suitable for bibliographies", + style.display_name() + ), + CslSource::Normal(..) => { + "CSL style is not suitable for bibliographies".into() + } + }) .at(span)?; if references.iter().any(|(prefix, _)| prefix.is_some()) { diff --git a/tests/suite/model/bibliography.typ b/tests/suite/model/bibliography.typ index 6de44e240..23576c156 100644 --- a/tests/suite/model/bibliography.typ +++ b/tests/suite/model/bibliography.typ @@ -71,6 +71,10 @@ Now we have multiple bibliographies containing @glacier-melt @keshav2007read #bibliography("/assets/bib/works_too.bib", style: "mla") +--- bibliography-style-not-suitable --- +// Error: 2-62 CSL style "Alphanumeric" is not suitable for bibliographies +#bibliography("/assets/bib/works.bib", style: "alphanumeric") + --- 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