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

Accommodate multiple css #115

Merged
merged 2 commits into from
Mar 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions R/coursera.R
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,30 @@ render_without_toc <- function(output_dir = file.path("docs", "no_toc"),
# Retrieve yaml file specs
output_yaml_lines <- yaml::yaml.load_file(output_yaml_file)

# Copy over css file that's specified
# Copy over css file(s) that's specified
org_css_file <- output_yaml_lines$`bookdown::gitbook`$css
css_file <- file.path(output_dir, org_css_file)

# Write it as "style.css"
fs::file_copy(org_css_file,
css_file,
overwrite = TRUE
)

# Check if there are multiple .css
if(length(org_css_file) > 1){
# Read all .css
css_files_read <- sapply(org_css_file, readLines)

# Make a "mega .css" and write
if (verbose) {
message("Combining .css files")
}
css_lines_cat <- rbind(unlist(css_files_read))
css_file <- file.path(output_dir, org_css_file[1])
writeLines(css_lines_cat, css_file)
} else {
css_file <- file.path(output_dir, org_css_file)

# Write it as "style.css"
fs::file_copy(org_css_file,
css_file,
overwrite = TRUE
)
}

###### Now do the rendering! ######
message("Render bookdown without TOC")
Expand All @@ -312,8 +327,7 @@ render_without_toc <- function(output_dir = file.path("docs", "no_toc"),
bookdown::render_book(
input = "index.Rmd",
output_yaml = output_yaml_file,
output_dir = output_dir,
clean_envir = FALSE
output_dir = output_dir
)

# Read in TOC closing CSS lines
Expand Down