Skip to content
Snippets Groups Projects
Commit bba7992e authored by David Dorchies's avatar David Dorchies
Browse files

fix: missing babel language support dependency

Fix #21
parent 6a77d227
No related branches found
No related tags found
No related merge requests found
......@@ -40,12 +40,14 @@ add_report <- function(name,
destpath
)
bookdown_config <- list(
language = list(ui = list(
chapter_name = paste0(stringr::str_to_title(i18n("chapter", lang)), " ")
)),
babel_lang = lang
)
cat(
yaml::as.yaml(list(language = list(
ui = list(chapter_name = paste0(stringr::str_to_title(
i18n("chapter", lang)
), " "))
))),
yaml::as.yaml(bookdown_config),
file = file.path(destpath, "_bookdown.yml"),
append = TRUE
)
......@@ -68,13 +70,8 @@ add_report <- function(name,
"% Add your own settings below to append or overwrite template settings")
writeLines(tex_content, file.path(destpath, sprintf("%s.tex", x)))
})
if ("tinytex" %in% rownames(installed.packages())) {
# Install babel LaTeX package for the specified language
babel_pkg <- paste0("babel-", lang)
if (! babel_pkg %in% tinytex::tl_pkgs(only_installed = TRUE)) {
tinytex::tlmgr_install(babel_pkg)
}
}
tinytex_install_babel_language_support(lang)
return(destpath)
}
......@@ -10,7 +10,13 @@ render_report <- function(input,
stopifnot(output_format %in% c("bookdown::gitbook", "bookdown::pdf_book"))
if (output_format == "bookdown::pdf_book") {
if (!requireNamespace("tinytex", quietly=TRUE)) install.packages("tinytex")
if (!requireNamespace("tinytex", quietly = TRUE)) install.packages("tinytex")
if (dir.exists(input)) {
babel_lang <- yaml::read_yaml(file.path(input, "_bookdown.yml"))$babel_lang
if (!is.null(babel_lang)) {
tinytex_install_babel_language_support(babel_lang)
}
}
}
message("output_format=", output_format)
......
......@@ -53,3 +53,13 @@ purge_string <- function(x, replacement = " ") {
from = "UTF-8",
to = "ASCII//TRANSLIT")
}
tinytex_install_babel_language_support <- function(lang) {
if ("tinytex" %in% rownames(installed.packages())) {
# Install babel LaTeX package for the specified language
babel_pkg <- paste0("babel-", lang)
if (! babel_pkg %in% tinytex::tl_pkgs(only_installed = TRUE)) {
tinytex::tlmgr_install(babel_pkg)
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment