Skip to content

Bump hayagriva to 0.9.1 and fix citation supplement comparison#6171

Merged
laurmaedje merged 27 commits intotypst:mainfrom
wkordalski:citation-supplement-equality
Oct 1, 2025
Merged

Bump hayagriva to 0.9.1 and fix citation supplement comparison#6171
laurmaedje merged 27 commits intotypst:mainfrom
wkordalski:citation-supplement-equality

Conversation

@wkordalski
Copy link
Contributor

@wkordalski wkordalski commented Apr 12, 2025

Fixes typst/hayagriva#280

See typst/hayagriva#299 (comment) for more context.

Current status

This PR is ready to review. It only waits (therefore draft status of PR) for merging Hayagriva PR — and then — for next release of Hayagriva, so that we can remove [patch.crates-io] section that overrides Hayagriva version.

We can discuss whether using plain_text() for supplement discrimination is the right choice. I think it is much better than current version and the one that introduces the least complexity.

@wkordalski wkordalski force-pushed the citation-supplement-equality branch 2 times, most recently from c5153d1 to a56c22e Compare May 15, 2025 14:27
@laurmaedje laurmaedje added bibliography Anything about citations and bibliographies. fix A bug fix. labels Jun 4, 2025
@wkordalski wkordalski force-pushed the citation-supplement-equality branch from 0f001df to 758168f Compare August 31, 2025 17:48
@PgBiel PgBiel mentioned this pull request Sep 13, 2025
1 task
@wkordalski wkordalski force-pushed the citation-supplement-equality branch from 3744ecc to d7b420c Compare September 15, 2025 09:02
@wkordalski wkordalski force-pushed the citation-supplement-equality branch from eba872c to 06de54c Compare September 19, 2025 11:21
@wkordalski wkordalski marked this pull request as ready for review September 19, 2025 11:45
@PgBiel
Copy link
Contributor

PgBiel commented Sep 19, 2025

Thanks! In order to merge this, we'll need some unit tests. Do you have some sample styles we can use to test? You can make a test and paste a simple style inline (with bibliography(bytes(style))), or send it here and I'll do it for you. Thanks!

@wkordalski
Copy link
Contributor Author

I've added a test for supplement equality (where supplement is text-only). Do we need more?

We could also add tests with more complex supplements, but I suppose that content equality is not specified by the language and we should not assume anything about it. Maybe we should even compare plain_text() of Content instead of whole Content?

I've started with https://github.com/citation-style-language/styles/blob/master/polish-legal.csl
and removed as much as possible.

<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" class="note" default-locale="pl-PL">
  <info>
    <title>Example citation style</title>
    <id>http://www.example.com/</id>
  </info>
  <macro name="locator">
    <group delimiter=" ">
      <label variable="locator" form="short"/>
      <text variable="locator"/>
    </group>
  </macro>
  
  <citation>
    <sort>
      <key variable="title"/>
      <key variable="issued"/>
    </sort>
    <layout>
      <choose>
        <if position="first">
          <group delimiter=", ">
            <text variable="title"/>
            <text macro="locator"/>
          </group>
        </if>
        <else-if position="ibid-with-locator">
          <group delimiter=", ">
            <text term="ibid"/>
            <text macro="locator"/>
          </group>
        </else-if>
        <else-if position="ibid">
          <text term="ibid"/>
        </else-if>
        <else-if position="subsequent">
          <group delimiter=", ">
            <text variable="title"/>
            <text macro="locator"/>
          </group>
        </else-if>
      </choose>
    </layout>
  </citation>

  <bibliography>
    <sort>
      <key variable="title"/>
    </sort>
    <layout>
      <text variable="title"/>
    </layout>
  </bibliography>
</style>

Any style that handles ibid and ibid-with-locator separately would work.

Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Copy link
Contributor

@PgBiel PgBiel left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

wkordalski and others added 2 commits September 27, 2025 08:51
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
@wkordalski
Copy link
Contributor Author

wkordalski commented Sep 27, 2025

After updating to Hayagriva 0.9.1 one test fails.
@PgBiel, could you verify whether we should update ref image for that test or some bug was introduced?

Ref:
image

Live:
image

(n.d.) was added in the last line.

@PgBiel
Copy link
Contributor

PgBiel commented Sep 27, 2025

Probably a consequence of typst/hayagriva#400, seems expected in principle. I'd update the test.

@laurmaedje laurmaedje changed the title Typst treats each citation supplement as equal — fix it Bump hayagriva to 0.9.1 and fix citation supplement comparison Oct 1, 2025
@laurmaedje
Copy link
Member

Thanks!

Tip: Instead of copying reference images from the output directory manually, you can use cargo testit --update and then it will automatically optimize the images for smaller sizes. This also made the large annotation unnecessary.

@laurmaedje laurmaedje enabled auto-merge October 1, 2025 10:18
@laurmaedje laurmaedje added the dependencies Pull requests that update a dependency file label Oct 1, 2025
@laurmaedje laurmaedje added this pull request to the merge queue Oct 1, 2025
Merged via the queue into typst:main with commit aafa274 Oct 1, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bibliography Anything about citations and bibliographies. dependencies Pull requests that update a dependency file fix A bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ibid-with-locator becomes ibid although the supplement differs

3 participants