Skip to content

Fix range parsing#86

Merged
PgBiel merged 4 commits intotypst:mainfrom
DerDrodt:fix-range-parsing
Sep 21, 2025
Merged

Fix range parsing#86
PgBiel merged 4 commits intotypst:mainfrom
DerDrodt:fix-range-parsing

Conversation

@Drodt
Copy link
Copy Markdown
Contributor

@Drodt Drodt commented Jul 2, 2025

Fixes typst/hayagriva#340.

One test fails. Someone needs to explain to me why 21:4-21:6 should be parsed as the range 4..6. That loses information and makes no sense to me.

@PgBiel
Copy link
Copy Markdown
Contributor

PgBiel commented Jul 4, 2025

One test fails. Someone needs to explain to me why 21:4-21:6 should be parsed as the range 4..6. That loses information and makes no sense to me.

I think it's treated as just a prefix. What is the usual meaning of this syntax?
In principle, page ranges that aren't parsed need to be handled by Hayagriva, but we need to make sure they can be used meaningfully. However, of course, one could also argue that they should be displayed verbatim.

@Drodt
Copy link
Copy Markdown
Contributor Author

Drodt commented Jul 4, 2025

I think it's treated as just a prefix. What is the usual meaning of this syntax? In principle, page ranges that aren't parsed need to be handled by Hayagriva, but we need to make sure they can be used meaningfully. However, of course, one could also argue that they should be displayed verbatim.

It is for journal articles where the first number stands for the article number, the second for the page number; each article starts with its own page 1. However, this was not properly handled. There was no check that the prefix remains the same and the article number was removed.

Then I think, this PR handles this correctly now. More complex parsing should be left up to users.

Comment thread src/types/mod.rs
Comment on lines +237 to +239
if !s.done() {
return Err(TypeError::new(span, TypeErrorKind::InvalidNumber));
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder when these types of failures can happen 🤔

@PgBiel PgBiel merged commit abb77bd into typst:main Sep 21, 2025
2 checks passed
@PgBiel
Copy link
Copy Markdown
Contributor

PgBiel commented Sep 21, 2025

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pages field with alphanumeric values like "1A1" is truncated in bibliography output

2 participants