Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Specify which CSL style is not suitable for bibliographies #6306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from

Conversation

Andrew15-5
Copy link
Contributor

@Andrew15-5 Andrew15-5 commented May 20, 2025

While stumbling into "alphanumeric" style for the nth time, I found that now apparently it errors that you can't use it for bibliography (it appears that I need to exclusively use it with cite()). But the error is vague, IMO.

CSL style is not suitable for bibliographies

Which style? It would be helpful to see more info. Initially I thought that this is better:

The CSL style is not suitable for bibliographies
Current CSL style is not suitable for bibliographies

But then I switched to

Current CSL style is not suitable for bibliographies: "name"

And finally ended up with

"name" CSL style is not suitable for bibliographies

This works for named styles and file paths. Though as always, I don't know what is the most efficient way to get X (string name) from Y (style field type), but it looks short enough.

#bibliography(bytes(""), style: "alphanumeric")
// #bibliography(bytes(""), style: "agora.csl")

Perhaps a hint can be added to point out other built-in styles that will work.

P.S. I in fact still haven't read the latest changelog...

@laurmaedje laurmaedje added the diagnostics Improvements to compiler errors label Jun 4, 2025
.ok_or("CSL style is not suitable for bibliographies")
.ok_or_else(|| {
eco_format!(
"{:?} CSL style is not suitable for bibliographies",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using {:?} debug formatting here is problematic as it fill use Rust-style formatting (e.g. Bytes(10)). I think we should instead only print a name if we know it (i.e. for named styles via style.names()). I would also reorder this, so that the final message is

eco_format!("CSL style `{}` is not suitable for bibliographies", name.repr())

If there is no name, we can keep the old message.

Could you also add tests for both cases?

Copy link
Contributor Author

@Andrew15-5 Andrew15-5 Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does .repr() come from?

no method named `repr` found for enum `hayagriva::archive::ArchivedStyle` in the current scope items from traits can only be used if the trait is implemented and in scope [E0599]

I don't know where does .names() gets multiple names if we can only specify one. There is also .display_name(). Why not use it?

I also don't know how to add test for this because of unnamed variant and because of plurality. Is it a pure Typst or Rust test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostics Improvements to compiler errors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.