Skip to content

Commit

Permalink
fix the syntax highlighting of |> in LaTeX/PDF output: rstudio/bookdo…
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui authored Oct 4, 2021
1 parent 0ed2349 commit 5a3e941
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rmarkdown
Type: Package
Title: Dynamic Documents for R
Version: 2.11.2
Version: 2.11.3
Authors@R: c(
person("JJ", "Allaire", role = "aut", email = "[email protected]"),
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
Expand Down
12 changes: 12 additions & 0 deletions R/pdf_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@ pdf_document <- function(toc = FALSE,
output_dir)
}

post_processor <- function(metadata, input_file, output_file, clean, verbose) {
# TODO: remove this temporary fix after the syntax highlighting problem is
# fixed in Pandoc https://github.com/rstudio/bookdown/issues/1157
x <- read_utf8(output_file)
s <- '\\SpecialCharTok{|}\\ErrorTok{\\textgreater{}}'
if (length(grep(s, x, fixed = TRUE)) == 0) return(output_file)
x <- gsub(s, '\\SpecialCharTok{|\\textgreater{}}', x, fixed = TRUE)
write_utf8(x, output_file)
output_file
}

intermediates_generator <- function(...) {
general_intermediates_generator(saved_files_dir, ...)
}
Expand All @@ -207,6 +218,7 @@ pdf_document <- function(toc = FALSE,
keep_md = keep_md,
df_print = df_print,
pre_processor = pre_processor,
post_processor = post_processor,
intermediates_generator = intermediates_generator
)
}
Expand Down

0 comments on commit 5a3e941

Please sign in to comment.