Skip to content

Commit 40ae02c

Browse files
committed
assign .QuartoInlineRender into new tools env
1 parent 864dbd7 commit 40ae02c

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/resources/rmd/execute.R

+16-14
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,24 @@ execute <- function(input, format, tempDir, libDir, dependencies, cwd, params, r
157157
}
158158
}
159159

160+
# special internal function for rendering inline code using Quarto syntax
161+
.assignToQuartoToolsEnv(".QuartoInlineRender", function(v) { # nolint: object_usage_linter, line_length_linter.
162+
if (is.null(v)) {
163+
"NULL"
164+
} else if (inherits(v, "AsIs")) {
165+
v
166+
} else if (is.character(v)) {
167+
gsub(
168+
pattern = "(\\[|\\]|[`*_{}()>#+-.!])",
169+
x = v, replacement = "\\\\\\1"
170+
)
171+
} else {
172+
v
173+
}
174+
})
175+
160176
# we need ojs only if markdown has ojs code cells
161177
# inspect code cells for spaces after line breaks
162-
163178
needs_ojs <- grepl("(\n|^)[[:space:]]*```+\\{ojs[^}]*\\}", markdown)
164179
# FIXME this test isn't failing in shiny mode, but it doesn't look to be
165180
# breaking quarto-shiny-ojs. We should make sure this is right.
@@ -173,19 +188,6 @@ execute <- function(input, format, tempDir, libDir, dependencies, cwd, params, r
173188
local = .quarto_tools_env
174189
)
175190
}
176-
177-
# special internal function for rendering inline code using Quarto syntax
178-
.quarto_tools_env$.QuartoInlineRender <- function(v) {
179-
if (is.null(v)) {
180-
"NULL"
181-
} else if (inherits(v, "AsIs")) {
182-
v
183-
} else if (is.character(v)) {
184-
gsub(pattern="(\\[|\\]|[`*_{}()>#+-.!])", x=v, replacement="\\\\\\1")
185-
} else {
186-
v
187-
}
188-
}
189191

190192
render_output <- rmarkdown::render(
191193
input = input,

0 commit comments

Comments
 (0)