Skip to content

Commit

Permalink
Take github css from here, in reprex; stop using a template
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Sep 9, 2024
1 parent 11eca0d commit cbea199
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions R/reprex_render.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,25 +182,19 @@ reprex_render_impl <- function(input,
invisible(reprex_file)
}

# heavily influenced by the post_processor() function of github_document()
# influenced by the post_processor() function of github_document()
# but with substantial reprex-specific updates in 2024-09
preview <- function(input) {
css <- rmarkdown::pandoc_path_arg(
mode <- if (is_dark_mode()) "dark" else "light"
res_dir <- rmarkdown::pandoc_path_arg(
path_package(
"rmarkdown",
"rmarkdown/templates/github_document/resources/github.css"
)
)
css <- glue("github-markdown-css:{css}")
template <- rmarkdown::pandoc_path_arg(
path_package(
"rmarkdown",
"rmarkdown/templates/github_document/resources/preview.html"
"reprex",
glue("rmarkdown/templates/reprex_document/resources")
)
)
args <- c(
"--standalone", "--self-contained",
"--template", template,
"--variable", css,
"--standalone", "--embed-resources",
"--css", path(res_dir, glue("github-{mode}.css")),
"--metadata", "pagetitle=PREVIEW",
"--quiet"
)
Expand All @@ -216,7 +210,7 @@ preview <- function(input) {
preview_file <- preview_file(input)
rmarkdown::pandoc_convert(
input = input, to = "html", from = "gfm", output = preview_file,
options = args, verbose = FALSE
options = args, verbose = TRUE
)

# can be interesting re: detecting how we were called and what we should
Expand Down

0 comments on commit cbea199

Please sign in to comment.