typst / hayagriva

Rusty bibliography management.
Apache License 2.0
316 stars 48 forks source link

Reference top-level parents #29

Closed m-haug closed 2 years ago

m-haug commented 2 years ago

First of all, thank you for the interesting tool.

After trying it out for a bit, I've come across one issue that could help with my specific workflow: selecting parents from top-level entries. For example, my database cites a few article from a single blog. It would be nice to only write down the information once and link to it from the parent fields of the individual articles.

Apologies if this is already implemented and I missed it. I have checked the documentation for the file format and the provided example.

BibLaTeX provides similar functionality using the crossref field. You can record information about proceedings or a blog in a single entry (A) and then link to that in subentries by specifying A's citation key in the crossref field. The standard bibliography styles will then load some information from A. For example, A's title would become the booktitle on the referencing entry.

If you consider this addition worthwhile, I would also be willing to provide a PR, but may need some guidance to get familiar with the code base.

reknih commented 2 years ago

Hey, thanks for your interest! YAML provides some capabilities to that effect. Have a look at the merge operator. Does it help with your use case? It should just work™ in Hayagriva.

btw when I got the email for this issue I was confused for a bit because our names are so similar 😮

m-haug commented 2 years ago

Thanks for the quick reply!

YAML provides some capabilities to that effect. Have a look at the merge operator. Does it help with your use case? It should just work™ in Hayagriva.

Unfortunately, the merge operator does not seem to work for this. I think it is not part of the current YAML 1.2 spec. If I try to use it with this bibliography, I get the following panic.

zettelkastende: &zetde
  type: Blog
  url: https://zettelkasten.de

barbell:
  title: The Barbell Method of Reading
  parent:
    << : *zetde
> RUST_BACKTRACE=1 hayagriva bibliography.yml
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: DataTypeMismatch { key: "barbell", field: "<<", expected: "text" }', /Users/m.haug/.cargo/registry/src/github.com-1ecc6299db9ec823/hayagriva-0.1.1/src/main.rs:250:55
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: hayagriva::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

However, while reading the spec I discovered that alias nodes work:

zettelkastende: &zetde
  type: Blog
  url: https://zettelkasten.de

barbell:
  title: The Barbell Method of Reading
  parent: *zetde
> RUST_BACKTRACE=1 hayagriva bibliography.yml
---
zettelkastende:
  type: blog
  url: "https://zettelkasten.de/"
barbell:
  type: misc
  title: The Barbell Method of Reading
  parent:
    - type: blog
      url: "https://zettelkasten.de/"

One problem with this approach is, that it is not possible to override keys in the parent. However, this is not a limitation for my use case.

btw when I got the email for this issue I was confused for a bit because our names are so similar 😮

I felt the same when discovering Typist 😂