I’m encountering a formatting issue when attempting to render a quarto document from my shiny application. By employing the same example as the solution to this SO question, I can render my quarto, but it doesn’t have the correct formatting.
quarto rendered from RStudio
quarto rendered from shiny application
shiny application
# UI -----------------------------------------------------------
ui = fluidPage(
textInput("author_name", "Author Name", "John Doe"),
textInput("report_title", "Report Title", "Quarto From Shiny"),
radioButtons(
inputId = "report_file_type",
label = "Report Type",
choices = c("HTML" = "html", "PDF" = "pdf")
),
downloadButton("report", "Generate report")
)
# SERVER --------------------------------------------------------
server = function(input, output) {
output$report <- downloadHandler(
filename = function() {
paste("report", input$report_file_type, sep = ".")
},
content = function(file) {
quarto::quarto_render(
input = "report_template.qmd",
output_format = input$report_file_type,
execute_params = list(
name = input$author_name,
report_title = input$report_title
)
)
# copy the quarto generated file to `file` argument.
generated_file_name <- paste("report_template", input$report_file_type,
sep = ".")
file.copy(generated_file_name, file)
}
)
}
#
shinyApp(ui = ui, server = server)
report_template.qmd
---
title: "Untitled"
format: html
editor: visual
---
## Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
## Running Code
When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
```{r}
1 + 1
```
You can add options to executable code like this
```{r}
#| echo: false
2 * 2
```
The `echo: false` option disables the printing of code (only output is displayed).
Session info
R version 4.3.3 (2024-02-29)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux 8.9 (Ootpa)
Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblaso-r0.3.15.so; LAPACK version 3.9.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8
[6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Stockholm
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2 purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1
[9] ggplot2_3.4.3 tidyverse_2.0.0 gt_0.10.1 bslib_0.6.2 shiny_1.8.1.1
loaded via a namespace (and not attached):
[1] gtable_0.3.0 xfun_0.43 processx_3.8.0 tzdb_0.2.0 vctrs_0.6.2 tools_4.3.3 ps_1.6.0
[8] generics_0.1.3 fansi_0.5.0 pkgconfig_2.0.3 readxl_1.4.2 webshot_0.5.3 lifecycle_1.0.3 compiler_4.3.3
[15] munsell_0.5.0 fontawesome_0.5.1 janitor_2.1.0 snakecase_0.11.0 httpuv_1.6.3 htmltools_0.5.7 sass_0.4.9
[22] yaml_2.3.8 later_1.3.0 pillar_1.9.0 jquerylib_0.1.4 rsconnect_0.8.29 cachem_1.0.6 mime_0.12
[29] tidyselect_1.2.0 digest_0.6.28 stringi_1.7.12 quarto_1.4 fastmap_1.1.1 grid_4.3.3 colorspace_2.0-2
[36] cli_3.6.0 magrittr_2.0.3 utf8_1.2.2 withr_2.4.2 scales_1.2.1 promises_1.2.0.1 timechange_0.2.0
[43] rmarkdown_2.26 cellranger_1.1.0 rLFO_0.1.08 hms_1.1.3 memoise_2.0.1 evaluate_0.20 knitr_1.46
[50] rlang_1.1.0 Rcpp_1.0.10 ggVennDiagram_1.5.2 xtable_1.8-4 glue_1.6.2 xml2_1.3.3 rstudioapi_0.14
[57] jsonlite_1.8.4 R6_2.5.1