Skip to content
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

Parse page ranges following citeproc #155

Merged
merged 30 commits into from
Oct 1, 2024
Merged

Conversation

DerDrodt
Copy link
Contributor

This PR depends on typst/citationberg#7.

Allows for page-range field to have multiple ranges, as in 1-4 & 7-12, 13, 14\-19.

Each of these is split into parts:

  • Commas as ,
  • Ampersands like &
  • Single pages like 13
  • Escaped ranges like 14\-19, where the hyphen will not be replaced by the given separator
  • Ranges like 1-4

Ranges are given to citationberg to format depending on the format rule per the CSL spec.

@reknih
Copy link
Member

reknih commented Aug 5, 2024

I have fixed the compile error and removed the provisional error message. I noticed that there were a few test regressions:

❌ Test label_EmptyLabelVanish should pass but failed
❌ Test locale_PageRangeDelimiterTermDefined should pass but failed
❌ Test locale_PageRangeDelimiterTermFrenchUndef should pass but failed
❌ Test number_PageFirst should pass but failed
❌ Test number_StrangeError should pass but failed
❌ Test page_Chicago should pass but failed
❌ Test page_Chicago16 should pass but failed
❌ Test page_NumberPageFirst should pass but failed
❌ Test page_PluralDetectWithEndash should pass but failed
❌ Test page_WithLocaleAndWeirdDelimiter should pass but failed
❌ Test virtual_PageFirst should pass but failed citeproc regressions

Chicago, for example, seems to be reversed in terms of what numbers it omits. It would be great if you could check what's going wrong here and if there's a common cause!

@PgBiel PgBiel mentioned this pull request Aug 6, 2024
@Drodt
Copy link
Contributor

Drodt commented Aug 20, 2024

There was a minor bug in the page range formats for citationberg that I fixed.

Besides that I put page into its own variable kind, as it behaves quite different from other variables. With these changes, all tests pass and I even managed to get one more to pass.

Look into the design changes, especially for citationberg, and let me know if you want something changed.

typst/citationberg#14

@reknih
Copy link
Member

reknih commented Sep 2, 2024

I merged typst/citationberg#14 with two comments added, thank you!

The rev for citationberg in this PR should now be updated. Did that.

@Drodt
Copy link
Contributor

Drodt commented Sep 8, 2024

From my POV this is good to merge. There might be further work down the line but this is worth an update imo

Copy link
Member

@reknih reknih left a comment

Choose a reason for hiding this comment

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

I have made a few changes to the comparison functions and the resolve_page_variable function. Thank you for your work!

Comment on lines +395 to +399
if let NumberOrPageVariable::Number(v) = label.variable {
n.is_plural(v.is_number_of_variable())
} else {
panic!("Incompatiable variable types")
}
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to enforce this on a type system level but it's okay for now

@reknih reknih merged commit 8f3e183 into typst:main Oct 1, 2024
2 checks passed
reknih added a commit that referenced this pull request Oct 1, 2024
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.

3 participants