mitchelloharawild / vitae

R Markdown Résumés and CVs

Home Page:https://pkg.mitchelloharawild.com/vitae/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

apply lua to CSLBlock

sjgknight opened this issue · comments

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?

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)

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