How do I use a Hayagriva .yaml bibliography file with a Typst .typ document?

CSShistory:
  type: video,
  title: "Peachpuffs and Lemonchiffons [CSSConfUS2014]"
  url:
    value: https://www.youtube.com/watch?v=HmStJQzclHc
    date: 2014-07-17
 author:
    - Alex Sexton

This is my Hayagriva file called mybib.yml in the same directory as the main Typst file, mydoc.typ.

In mydoc.typ, I have a section called == References in which I want to include this single reference. It has also been cited as #cite(CSShistory) in the text.
How do I link the mybib.yml file to the mydoc.typ file?

I tried #bibliography("mybib.yml") but I get errors on compiling.

Can someone pease help me.

How exactly are you citing? It is either #cite(<CSShistory>) or @CSShistory, the path to the YML file should work as-is.

1 Like

@xkevio: Thank you for so emphatically saying that it should work.

I now realize that the cause of the error was the terminal comma after video in the second line of the mybib.yml file as listed above. Removing the comma solved the problem. Cheers!

From https://typst.app/docs/reference/model/cite/#example:

This was already noted by
pirates long ago. @arrgh

Multiple sources say ...
@arrgh @netwok.

You can also call `cite`
explicitly. #cite(<arrgh>)

#bibliography("works.bib")

@Andrew: I am a BibTeX user trying out Hayagrva.

I looked at the link you have shown before posting, but did not see a Hayagriva file in the docs for arrgh or netwok.

The error I made was also because of my BibTeX habit of separating key values from the next key by commas.

Hmm. The Bibliography Function – Typst Documentation page does mention both, but I guess it won’t hurt explicitly mentioning it in Cite Function – Typst Documentation. See Mention types of supported bibliography formats for citing by Andrew15-5 · Pull Request #6354 · typst/typst · GitHub.

@chyavana, do you think an explicit mention of supported Hayagriva format on the page for cite would’ve solved your problem, or would you still have asked how to use it because of the comma and the change to the docs is not worth it?

@Andrew: A cautionary note to those coming in from BibTeX—where a precautionary terminal comma is prescribed—to avoid that very comma in Hayagriva would be helpful.

Also, a link to the Hayagriva examples page would be helpful.

What I was looking for was the Hayagriva source file: "works.yml" file.

After looking at some errors, I see that Typst actually tells you about it:

error: failed to parse YAML (CSShistory.type: unknown variant video,, expected one of Article, article, Chapter, chapter, Entry, entry, Anthos, anthos, Report, report, Thesis, thesis, Web, web, Scene, scene, Artwork, artwork, Patent, patent, Case, case, Newspaper, newspaper, Legislation, legislation, Manuscript, manuscript, Post, post, Misc, misc, Performance, performance, Periodical, periodical, Proceedings, proceedings, Book, book, Blog, blog, Reference, reference, Conference, conference, Anthology, anthology, Repository, repository, Thread, thread, Video, video, Audio, audio, Exhibition, exhibition, Original, original at line 2 column 9)

From it, it’s clear that video, is not video nor Video, therefore the comma is causing the error.

Did you see this error?

Now (soon™) it will also show the point at which the error occurred in the YAML file.

error: failed to parse YAML (CSShistory.type: unknown variant `video,`, expected one of `Article`, `article`, `Chapter`, `chapter`, `Entry`, `entry`, `Anthos`, `anthos`, `Report`, `report`, `Thesis`, `thesis`, `Web`, `web`, `Scene`, `scene`, `Artwork`, `artwork`, `Patent`, `patent`, `Case`, `case`, `Newspaper`, `newspaper`, `Legislation`, `legislation`, `Manuscript`, `manuscript`, `Post`, `post`, `Misc`, `misc`, `Performance`, `performance`, `Periodical`, `periodical`, `Proceedings`, `proceedings`, `Book`, `book`, `Blog`, `blog`, `Reference`, `reference`, `Conference`, `conference`, `Anthology`, `anthology`, `Repository`, `repository`, `Thread`, `thread`, `Video`, `video`, `Audio`, `audio`, `Exhibition`, `exhibition`, `Original`, `original` at line 2 column 9)
  ┌─ a.yaml:2:8
  │
2 │   type: video,
  │         ^

help: error occurred in this call of function `bibliography`
  ┌─ a.typ:1:1
  │
1 │ #bibliography("a.yaml")
  │  ^^^^^^^^^^^^^^^^^^^^^^

Your file is actually not a valid YAML, as a tool like yq says

Error: bad file '-': yaml: line 6: did not find expected key

And GitHub - redhat-developer/yaml-language-server: Language Server for YAML Files also shows the error:

Not sure if it’s a not-so-hard error or if Typst softens the validation.

No, I did not see that error. There is a superfluity of commas in the error message, but with a space before each. Frankly the error message did not serve to identify or clarify the cause, at least for me.