Skip to content

Commit

Permalink
Adds on.exit-call to restore RefManageR-options to tidy_bib_file().
Browse files Browse the repository at this point in the history
  • Loading branch information
crsh committed Jan 5, 2021
1 parent 3d5b19b commit 1c5c4c7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions R/tidy_bib_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ tidy_bib_file <- function(
for(i in seq_along(messy_bibliography)) {
complete_bibliography <- append(complete_bibliography, RefManageR::ReadBib(messy_bibliography[i], check = FALSE, .Encoding = encoding))
}

necessary_bibliography <- complete_bibliography[names(complete_bibliography) %in% reference_handles]

if(length(necessary_bibliography) == 0) stop("Found none of the ", length(reference_handles), " necessary references in the look-up bibliography.")
Expand All @@ -66,10 +66,9 @@ tidy_bib_file <- function(

bib_options <- RefManageR::BibOptions()
RefManageR::BibOptions(check.entries = FALSE)
on.exit(RefManageR::BibOptions(bib_options))

RefManageR::WriteBib(unique(necessary_bibliography), file = file, useBytes = TRUE, biblatex = betterbiblatex_format == "biblatex")

RefManageR::BibOptions(bib_options)
}


Expand Down

0 comments on commit 1c5c4c7

Please sign in to comment.