Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply lua to CSLBlock #241

Closed
sjgknight opened this issue Aug 27, 2023 · 2 comments
Closed

apply lua to CSLBlock #241

sjgknight opened this issue Aug 27, 2023 · 2 comments

Comments

@sjgknight
Copy link

I'm trying to work out how to modify the presentation of the annote/annotation content in the bibliography, which is represented as CSLBlock in the .tex output. I tried keeping the .md too but the bibliography is a temp yaml and I don't know how to retain that to try and work with it.
I've used the lua helpfully discussed to bold my name, and use multiple bibliography. Within my annotation field I have a set of key:value pairs (the 'extra' field in Zotero) for example indicating openaccess:gold status, n of citations, etc. I was hoping to display this in a more meaningful/attractive way inline with the references. I explored using another way of displaying the bibliography, but can't see how to make that work. I could edit the .bib file (manually or a script) to split those elements into elements of an entry, but then they won't display unless I define a style...I thought I might be able to use lua to effectively just replace instances of a string (e.g. openaccess:gold, with \includegraphics{gold.png}, or whatever).

Is there any easy(ish) way of doing something like this, without getting into the deep end of tex/pandoc/lua/rmd interactions?

@sjgknight
Copy link
Author

As a sort of workaround, I'm now separately knitting bibliography sections, reading in the output, processing using R, and then outputting.

So 'bib.Rmd' contains one chunk, with vitae::bibliography_entries("MyPublications.bib", "Publications")
with some text around it to extract. I get some console output and this is a very cludgy approach.

source("../R/citeAugmentR.R")
myrefs <- rmarkdown::render("bib.Rmd", output_file = "bib.tex")
myrefs_lines <- readr::read_lines(myrefs)
start <- grep(pattern = "STARTHERE", myrefs_lines) +2
end <- grep(pattern = "ENDHERE", myrefs_lines) -2

myrefs_lines <- myrefs_lines[start:end]
myrefs_lines <- process_document(mylines = myrefs_lines, outputreturn = T)

knitr::raw_latex(myrefs_lines)

@mitchelloharawild
Copy link
Owner

I suspect that this would be possible by specifying a custom CSL schema - https://citationstyles.org/
I'm glad you could find a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants