paleolimbot / rbbt

R Interface to the Better BiBTex Zotero Connector
142 stars 25 forks source link

The example YAML key for R markdown in bbt_write_bib() doesn't work #12

Closed florisvdh closed 3 years ago

florisvdh commented 3 years ago

The documentation of bbt_write_bib() suggested:

bibliography: "`r rbbt::bbt_write_bib("bibliography.json", overwrite = TRUE)`"

However copying this into a Rmd file does not work because double quotes are used inside double quotes. Will fix this.

dmi3kno commented 1 year ago

This remains my main method of using rbbt @cderv. I love it to pieces!

Basically, as long as Zotero is running in the background, I don't need to worry about updating my .bib file ever! I just insert the keys as I write the document and the .bib file is updated just before it is rendered by knitr.

I am aware of the visual mode, and I don't like it, because

In contrast, rbbt interface is much lighter and does not load the whole collection on insert.

cderv commented 1 year ago

Ok I see. But the path is fixed right ? bibliography.json ?

So if you were to run this at the last chunk of you document (or maybe even in a setup chunk) this would have the same effect, wouldn't it ?

bibliography: bibliography.json

and then somewhere in the doc

```{r}
#| include: false
rbbt::bbt_write_bib("bibliography.json", overwrite = TRUE)


This is how we would do it usually with `knitr::write_bib()`  which write by default to a bib file any citation of packages loaded 

https://bookdown.org/yihui/rmarkdown-cookbook/write-bib.html

Why couldn't this be used the same way ? it would work in Quarto 
dmi3kno commented 1 year ago

I don't know why I never did it! I guess I assumed that YAML is evaluated before the body of the document. I honestly don't know. So stupid. Of course, @cderv it works as it should! Loving it. Thank you!

cderv commented 1 year ago

I think that should be the new documented way for rbbt it will work no matter Rmd or .qmd and it is to my opinion more in line with the workflow.

Glad I could help ! Thanks for asking the question and making me discover this package.

dmi3kno commented 1 year ago

@bwiernik we should put this example into the documentation, preferably in README as one of the recommended ways of using rbbt.