From 698a5b8856e97f6c01cfc1265253f16dd281ebb0 Mon Sep 17 00:00:00 2001 From: Sebastian Krantz Date: Sun, 2 Jun 2024 01:56:29 +0200 Subject: [PATCH] Highlight template code for optional arguments. --- R/highlight.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/highlight.R b/R/highlight.R index bcb528c27..07f9dbd7c 100644 --- a/R/highlight.R +++ b/R/highlight.R @@ -4,6 +4,11 @@ highlight_text <- function(text) { text <- gsub("[[(", "`[[`(", text, fixed = TRUE) text <- gsub("[(", "`[`(", text, fixed = TRUE) text <- gsub("$(", "`$`(", text, fixed = TRUE) + # For fast-statistical-functions.Rd + text <- gsub(", [w = NULL,]", ", w = NULL,", text, fixed = TRUE) + text <- gsub(", [na.rm = TRUE,]", ", na.rm = TRUE,", text, fixed = TRUE) + text <- gsub(", [nthreads = 1L,]", ", nthreads = 1L,", text, fixed = TRUE) + text <- gsub("[keep.w = TRUE,] [stub = TRUE,] [nthreads = 1L,]", "keep.w = TRUE, stub = TRUE, nthreads = 1L,", text, fixed = TRUE) out <- downlit::highlight(text, classes = downlit::classes_pandoc()) # out <- gsub("`[[`", "[[", out, fixed = TRUE) # out <- gsub("`[`", "[", out, fixed = TRUE)