-
Notifications
You must be signed in to change notification settings - Fork 409
Description
This issue is based on the discussion in #3717. Just reporting here so it's easier to follow.
It would be nice if Quarto supported ANSI colour output with downlit. Currently Quarto uses downlit for code linking when code-link: true, but this doesn't make colours work.
I thought it would work based on my experiences with pkgdown, but after some discussion it sounds like pkgdown does some additional processing with fansi to support colour output (See #3717 (comment)). At this time, if you do need colour output in Quarto, you can get it use the fansi knitr hooks for converting ANSI highlighting to HTML highlighting. See #3717 (comment).
One thing that is nice about this approach with fansi is that you can turn the hook on and off throughout a document, in case you only want colour output for certain parts. For example, in this blog post I have fansi hooks on in the body of the post, but turned them off for the appendix so the output from sessioninfo::session_info() wouldn't be coloured.
If Quarto does support colour output in the future, it would be nice to make it a chunk option (e.g., colour-output: true/false) rather than a document-wide option like code-link so it can be used selectively when needed.
Here's a reprex copied from the discussion that can be used for testing.
---
title: "Reprex"
format:
html:
code-link: true
---
```{r}
#| collapse = TRUE
cat(cli::col_red("This is red"), "\n")
cat(cli::col_blue("This is blue"), "\n")
message(cli::col_green("This is green"))
warning(cli::style_bold("This is bold"))
```