Skip to content
Discussion options

You must be logged in to vote

Don't use cat() .

This should work

---
format: html
---

## Test

```{r}
colorize <- function(string, color) {
  string_colorized <- paste("<span style=\"color: ", color,"\">", string,"</span>",sep = "")
  string_colorized
}
```

This text is `r colorize("red", "red")` and then black again.

Such colorize function with R is shown as example in the R Markdown Cookbook by the way
https://bookdown.org/yihui/rmarkdown-cookbook/font-color.html#using-an-r-function-to-write-raw-html-or-latex-code

It will work with Quarto too

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by setseed13
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants