typst / hayagriva

Rusty bibliography management.
Apache License 2.0
289 stars 44 forks source link

Fix citation suppresses title when no author provided #144

Closed AstrickHarren closed 3 months ago

AstrickHarren commented 3 months ago

From https://github.com/typst/citationberg/issues/4#issuecomment-2009709750

I found the problem is due to substitute and choose working together. (Its actually a problem of typst/hayagriva)

  1. substitute will cause any subsequent query to variables, in this case, the title, suppressed if that variable is queried once before.

  2. choose actually calls query to title two times, the first time to find out which branch makes sense and the second to render.

  3. therefore the second time is suppressed and resulting in no title.

A simple fix can be to do a silent lookup on the first query of choose, much like what is done in Test::will_have_info(..).

This is the output from OP's bib after applying the fix:

Definition and objectives of systems development. (2016, January 19). https://www.opentextbooks.org.hk/ditatopic/25323

However, the journal part does not seem to be there, which I think is not there even with author specified.

Fixes typst/citationberg#4 Fixes #139

AstrickHarren commented 3 months ago

As tests seems to build up, I think I can help with reorganizing them into functions/macros as well :)

reknih commented 3 months ago

Thank you!

As tests seems to build up, I think I can help with reorganizing them into functions/macros as well :)

That would be fantastic! I also aim to increase compliance with the citeproc test suite.