You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
R code using the cli package produces unstyled, plain text output in Quarto HTML documents. The ANSI escape sequences are stripped, losing all formatting (colors, bold, emphasis). While Quarto 1.7+ added ANSI support for Jupyter/Julia, R/knitr documents still lack native handling.
Background
The cli package is widely used in the R ecosystem (tidyverse, devtools, usethis, etc.). Many custom print methods leverage cli for informative output. Without native support, Quarto users see degraded output quality compared to RStudio console or terminal rendering.
Minimal Reproducible Example
Save as cli-demo.qmd and render with quarto render cli-demo.qmd:
This is non-obvious, requires additional dependencies (fansi, htmltools), and must be repeated in every document.
Note
The workaround produces separate <pre> blocks for each cli statement, which may result in extra vertical spacing. This is normal knitr behavior (one output block per cat()/message() call). If desired, CSS can be used to collapse consecutive output blocks:
Summary
R code using the
clipackage produces unstyled, plain text output in Quarto HTML documents. The ANSI escape sequences are stripped, losing all formatting (colors, bold, emphasis). While Quarto 1.7+ added ANSI support for Jupyter/Julia, R/knitr documents still lack native handling.Background
The
clipackage is widely used in the R ecosystem (tidyverse, devtools, usethis, etc.). Many custom print methods leverageclifor informative output. Without native support, Quarto users see degraded output quality compared to RStudio console or terminal rendering.Minimal Reproducible Example
Save as
cli-demo.qmdand render withquarto render cli-demo.qmd:Output Comparison
Desired Output
Mirror RStudio with a light grey background for CLI output:
Or, just the regular CLI output:
Expected vs Actual Behavior
Current Workaround
Users must manually configure custom knitr hooks using
fansiin every document:This is non-obvious, requires additional dependencies (
fansi,htmltools), and must be repeated in every document.Note
The workaround produces separate
<pre>blocks for eachclistatement, which may result in extra vertical spacing. This is normal knitr behavior (one output block percat()/message()call). If desired, CSS can be used to collapse consecutive output blocks:Proposed Solution
Add native ANSI processing for R/knitr output, similar to the fix in PR #7813. Also consider adding a feature flag or three for the new behavior:
ansi: trueto enable ANSI-to-HTML conversionexecute: ansi-colors: trueRelated Issues
downlitEnvironment