Skip to content

Commit

Permalink
Support syntax highlighting for subset/assignment methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebKrantz committed Jun 1, 2024
1 parent 77ed3e1 commit 5325213
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/highlight.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# highligh_text() and highlight_examples() are only used for usage
# and examples, and are specifically excluded in tweak_reference_highlighting()
highlight_text <- function(text) {
text <- gsub("[[(", "`[[`(", text, fixed = TRUE)
text <- gsub("[(", "`[`(", text, fixed = TRUE)
text <- gsub("$(", "`$`(", text, fixed = TRUE)
out <- downlit::highlight(text, classes = downlit::classes_pandoc())
out <- gsub("`[[`(", "[[(", out, fixed = TRUE)
out <- gsub("`[`(", "[(", out, fixed = TRUE)
out <- gsub("`$`(", "$(", out, fixed = TRUE)
if (!is.na(out)) {
sourceCode(pre(out, r_code = TRUE))
} else {
Expand Down

0 comments on commit 5325213

Please sign in to comment.