-
-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mathjax is not working properly with kableExtra html format in Quarto #746
Comments
Hi 👋 , Quarto developer here. We have some explanation about this in this thread opened in Quarto Let me give summary of the context here:
This way of working for Quarto is explaining what is seen here:
In this case, they are not parsed because they are included in a HTML table inside raw block, and so nor Quarto nor Pandoc will see this as regulat content, and not parse it a Math elements to be rendered as markdown. To be clear, this first example would not work in R Markdown either for a HTML table inside a raw block which would contain math as markdown.
When doing this, the content generating as results of the knitr cell won't be inside a HTML raw block. So Quarto won't parse it, and only Pandoc Markdown parsing is done. Pandoc can parse Markdown in HTML when some extensions of Pandoc are activated. It won't see the whole table as HTML but somes pieces as Raw HTML inlines, and other Markdown content. Anyhow, you can set
I really hope this helps understand the behavior. Let's discuss possible solution now. The best way would be for kableExtra to have a mechanism to allow to format some content in cell as Markdown to be processed by Quarto. This means passing the content in the mentioned attributes. gt does through it Here is an example to make the initial one shared above works ---
title: "kableExtra"
format: html
execute:
echo: false
---
## Quarto
```{r}
library(kableExtra)
tbl1 <- data.frame(
var = c("$a$", "$b$", "$c$"),
val = c(1, 2, 3)
)
make_data_qmd <- function(content) {
sprintf('<span data-qmd="%s">%s</span>', content, content)
}
tbl1$var <- make_data_qmd(tbl1$var)
```
```{r}
kbl(tbl1, format="html", escape = FALSE) %>%
kable_classic(full_width = F) %>%
kable_styling(font_size = 24) %>%
row_spec(2, color = "lightgray", background = "darkred")
``` it requires I hope it clarifies what can be done to bring support to this in kableExtra inside Quarto context. I believe what I explained above will apply to other issues too (like fontawesome icons in kableExtra #766). I am available for further explanation and discussion to help make everything work smoothly! |
I'm not a Quarto user, so I'm probably doing something very naive, but when I run your final document through "render" in RStudio, I don't get final output, I just see something that looks like intermediate output:
... and so on. Did something get messed up in what you posted? More to the point: would an option to |
Found the naive problem: somehow I kept the 4 backtick fences around the code. But now that I've removed those, I'm seeing the |
My example should work with latest Quarto. I am running it with 1.4.554
I don't know enough about I am thinking of adding some helpers for this anyway in quarto R package to help creating string with this feature. Could be wrapper as Or now that I am challenged on the idea (thanks !) maybe there could be some generic way to mark some string in R to be transformed to this attributes syntax by knitr itself. 🤔 Really I am opened to any suggestion to make the R user experience better regarding this feature from Quarto. |
Okay, I had an old Quarto on my path, and RStudio was using it. It's gone now and things are working. I think the ideal user experience would be to have this happen automatically in |
Consider the following reprex to understand the issue,
which generates the following table,
As you can see, the
a
,b
,c
wrapped within$...$
is not rendered correctly by mathjax.But strange enough, If I save the
kbl
object in a variable and thencat
it, everything works as intended.Would you kindly help me to understand what is going on here 😅🙏?
The text was updated successfully, but these errors were encountered: