-
Hi all! I wanted to make my life easier by wrapping
The above works fine via:
However, this creates a new paragraph for a single, mid-sentence word, which lead me to throwing the entire paragraph into a slightly more complicated function. Since this doesn't feel right, I wanted to ask whether there is any way to generate raw HTML via inline code? I also tried generating R inline code via sprintf, but, unsurprisingly, this also didn't work:
I'm thankful for any assistance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Don't use 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 It will work with Quarto too |
Beta Was this translation helpful? Give feedback.
-
I thought I lost my sanity, because I was pretty sure I saw a working example somewhere in the documentation...I was scouring the one for Quarto quite extensively... And since the same holds for the LUA filters, you not only made my day, but my entire month! |
Beta Was this translation helpful? Give feedback.
Don't use
cat()
.This should work
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