typst / hayagriva

Rusty bibliography management.
Apache License 2.0
314 stars 47 forks source link

ArXiv Preprint in APA not correct #92

Closed yochem closed 9 months ago

yochem commented 9 months ago

The following example reference: https://github.com/typst/hayagriva/blob/main/tests/data/basic.yml#L252-L261

$ hayagriva --version
Hayagriva CLI 0.4.0
$ hayagriva refs.yml reference --style apa --key really-habitable
Pedbost, M. F., Pomalgu, T., Lintott, C., Eisner, N., & Nicholson, B. (2020). Defining the Really Habitable Zone (2003.13722). https://arxiv.org/abs/2003.13722

Thus gives as result: Pedbost, M. F., Pomalgu, T., Lintott, C., Eisner, N., & Nicholson, B. (2020). Defining the Really Habitable Zone (2003.13722). https://arxiv.org/abs/2003.13722

But according to the APA style guide, it should be:

Pedbost, M. F., Pomalgu, T., Lintott, C., Eisner, N., & Nicholson, B. (2020). Defining the Really Habitable Zone. ArXiv. https://arxiv.org/abs/2003.13722

yochem commented 9 months ago

It would also be nice if the DOI can be generated from the serial-number.arxiv field, since its format is just https://doi.org/10.48550/arXiv.<serial-number.arxiv>.

zepinglee commented 9 months ago

CSL/Zotero assumes the name of archive is stored in the publisher field (see https://aurimasv.github.io/z2csl/typeMap.xml#map-preprint). The current version of hayagriva doesn't look into the parent for the publisher field. I've made a try to fix in cb09ac4.

yochem commented 9 months ago

Would it be possible to automatically set that when the entry contains serial-number.arxiv? Just like the DOI?

zepinglee commented 9 months ago

Would it be possible to automatically set that when the entry contains serial-number.arxiv? Just like the DOI?

I'm afraid it's not possible for CSL. The archive name and ID are plain fields in CSL's data model and CSL cannot make special processing for arXiv articles.

yochem commented 9 months ago

And if we would change the function https://github.com/typst/hayagriva/blob/3e92ac83837914a0f1feeff63e50ed2faa1577a6/src/lib.rs#L717-L719

to be

 pub fn set_arxiv(&mut self, arxiv: String) { 
     self.set_keyed_serial_number("arxiv", arxiv); 
     self.set_keyed_serial_number("doi", "10.48550/arXiv.{arxiv}"); // I don't know how to write this in rust
 } 

It seems to me that in that case, the doi key would also be set, resulting in the DOI being included in the reference. Or is that not how the code works?

Edit: doesn't seem to work