Skip to content

Commit 611acf5

Browse files
[skip style] [skip vbump] Restyle files
1 parent a279ec0 commit 611acf5

File tree

2 files changed

+34
-28
lines changed

2 files changed

+34
-28
lines changed

R/tm_rmarkdown.R

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@
7676
#' moduleServer(id, function(input, output, session) {
7777
#' reactive({
7878
#' req(data())
79-
#' within(data(), {
80-
#' rmd_data$n_rows <- n_rows_value
81-
#' }, n_rows_value = input$n_rows)
79+
#' within(data(),
80+
#' {
81+
#' rmd_data$n_rows <- n_rows_value
82+
#' },
83+
#' n_rows_value = input$n_rows
84+
#' )
8285
#' })
8386
#' })
8487
#' }
@@ -153,7 +156,7 @@ ui_rmarkdown <- function(id, rmd_file, allow_download, extra_transform, ...) {
153156
class = "btn-primary btn-sm"
154157
)
155158
},
156-
ui_transform_teal_data(ns("extra_transform"), transformators = extra_transform)
159+
ui_transform_teal_data(ns("extra_transform"), transformators = extra_transform)
157160
),
158161
tags$hr(),
159162
uiOutput(ns("rmd_output"))
@@ -199,31 +202,34 @@ srv_rmarkdown <- function(id, data, rmd_file, allow_download, extra_transform) {
199202
)
200203

201204
rendered_path_r <- reactive({
202-
datasets <- req(q_r()) # Ensure data is available
205+
datasets <- req(q_r()) # Ensure data is available
203206
temp_dir <- tempdir()
204207
temp_rmd <- tempfile(tmpdir = temp_dir, fileext = ".Rmd")
205208
temp_html <- tempfile(tmpdir = temp_dir, fileext = ".md")
206209
file.copy(rmd_file, temp_rmd) # Use a copy of the Rmd file to avoid modifying the original
207210

208-
tryCatch({
209-
rmarkdown::render(
210-
temp_rmd,
211-
output_format = rmarkdown::md_document(
212-
variant = "gfm",
213-
toc = TRUE,
214-
preserve_yaml = TRUE
215-
),
216-
output_file = temp_html,
217-
params = datasets[["rmd_data"]],
218-
envir = new.env(parent = globalenv()),
219-
quiet = TRUE,
220-
runtime = "static"
221-
)
222-
temp_html
223-
}, error = function(e) {
224-
warning("Error rendering RMD file: ", e$message) # verbose error in logs
225-
e
226-
})
211+
tryCatch(
212+
{
213+
rmarkdown::render(
214+
temp_rmd,
215+
output_format = rmarkdown::md_document(
216+
variant = "gfm",
217+
toc = TRUE,
218+
preserve_yaml = TRUE
219+
),
220+
output_file = temp_html,
221+
params = datasets[["rmd_data"]],
222+
envir = new.env(parent = globalenv()),
223+
quiet = TRUE,
224+
runtime = "static"
225+
)
226+
temp_html
227+
},
228+
error = function(e) {
229+
warning("Error rendering RMD file: ", e$message) # verbose error in logs
230+
e
231+
}
232+
)
227233
})
228234

229235
rendered_html_r <- reactive({
@@ -256,6 +262,6 @@ srv_rmarkdown <- function(id, data, rmd_file, allow_download, extra_transform) {
256262
rendered_html_r()
257263
)
258264
out_data
259-
})
260-
})
265+
})
266+
})
261267
}

inst/sample_files/test.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This is an example of an R markdown file with an inline r execution that gives t
1212
Code chunk that performs a simple calculation (`1+1`)
1313

1414
```{r}
15-
1+1
15+
1 + 1
1616
```
1717

1818
Code chunk that shows the structure of the params object
@@ -31,4 +31,4 @@ Code chunk that plots the first `n_rows` of the `CO2` dataset if it is provided
3131

3232
```{r, eval = !is.null(params$CO2)}
3333
plot(head(params$CO2, n = params$n_rows))
34-
```
34+
```

0 commit comments

Comments
 (0)