From 01d859163906230ff265d7974bf0182b09420e88 Mon Sep 17 00:00:00 2001 From: mitchelloharawild Date: Wed, 28 Jul 2021 21:35:19 +1000 Subject: [PATCH] Fix bibliography_entries() encoding issue on Windows Resolves #158, #167 --- DESCRIPTION | 3 ++- R/bibliography.R | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 36333b40..ec7588e2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,7 +20,8 @@ Imports: yaml, tibble, vctrs (>= 0.3.3), - pillar + pillar, + jsonlite Suggests: covr, rorcid, diff --git a/R/bibliography.R b/R/bibliography.R index b19f7448..44891a5f 100644 --- a/R/bibliography.R +++ b/R/bibliography.R @@ -42,8 +42,10 @@ bibliography_entries <- function(file, startlabel = NULL, endlabel = NULL) { } # Parse bib file - bib <- rmarkdown::pandoc_citeproc_convert(file) - + # Set system() output encoding as UTF-8 to fix Windows issue (rmarkdown#2195) + bib <- rmarkdown::pandoc_citeproc_convert(file, type = "json") + Encoding(bib) <- "UTF-8" + bib <- jsonlite::fromJSON(bib, simplifyVector = FALSE) # Produce prototype bib_schema <- unique(vec_c(!!!lapply(bib, names)))