Home > Mobile >  How can I prevent markdown styling of R output in a quarto HTML document
How can I prevent markdown styling of R output in a quarto HTML document

Time:12-21

I am printing a table that contains _ characters with kable() in a quarto file using an HTML output and it is italicizing and/or bolding the output rather than printing the _ characters. How can I print the output as is rather than converting it into italicized and/or bolded text?

I messed around with

#| output: asis

and it just further messed up the formatting.

You can see the problem if you render this:

```{r}
blah <- data.frame(word = c("abcde", "a_c_e", "_b___", "__c__"))

blah |> 
  knitr::kable()
```

CodePudding user response:

You could use the following trick: add the enter image description here

CodePudding user response:

Kable generates raw HTML, which is then spliced back into the Markdown document. We can control at read time whether the contents of HTML elements should be parsed as Markdown or handled verbatim. For that, we'll have to disable the markdown_in_html_blocks Markdown extension:

---
from: 'markdown-markdown_in_html_blocks'
---

The cells should now be passed through without being interpreted as Markdown.

  • Related