-
Notifications
You must be signed in to change notification settings - Fork 3
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
Probably a problem upstream or elsewhere: incorrect rendering of MathML in Chromium-based web browsers #3
Comments
I think chrome does not claim to support mathml? https://caniuse.com/mathml |
The equations 6, 7 and 8, do not render in any of the three browsers I tried when using Just for completeness, I redid again the tests, changing to html rendering: A bit more complex latex environment do not renderThe following html does not work in Firefox, Brave or Chromium browsers. ## A bit more complex latex environment do not render
The following **html** does not work in Firefox, Brave or Chromium browsers.
```{r}
tex6 <- "f(n) = \\begin{cases} \\frac{n}{2}, & \\text{if } n\\text{ is even} \\\\ 3n+1, & \\text{if } n\\text{ is odd} \\end{cases}"
eq6 <- katex_html(tex6, include_css = FALSE)
```
Equation 6: `r eq6`
```{r}
tex7 <- "\\begin{aligned}
\\dot{x} & = \\sigma(y-x) \\\\
\\dot{y} & = \\rho x - y - xz \\\\
\\dot{z} & = -\\beta z + xy
\\end{aligned}"
eq7 <- katex_html(tex7, include_css = FALSE)
```
Equation 7: `r eq7`
```{r}
tex8 <- "\\begin{pmatrix}
a_{11} & a_{12} & a_{13}\\\\
a_{21} & a_{22} & a_{23}\\\\
a_{31} & a_{32} & a_{33}
\\end{pmatrix}"
eq8 <- katex_html(tex8, include_css = FALSE)
```
Equation 8: `r eq8`
The HTML es generated OK (AFAICT) but for some reason it does not render, as is shown in the screenshots below (using Brave, but the same happens with RStudio viewer and Firefox): |
I think the reason that it doesn't show up is because you are using single-quote inline for printing the math, maybe the large equations just do not fit inline. You can print the math directly in displaymode by wrapping the html in ```{r}
tex6 <- "f(n) = \\begin{cases} \\frac{n}{2}, & \\text{if } n\\text{ is even} \\\\ 3n+1, & \\text{if } n\\text{ is odd} \\end{cases}"
htmltools::HTML(katex_html(tex6))
``` Your updated Rmarkdown file, which works for me: https://gist.github.com/jeroen/3209a68bc7d1b1562e8234b154d7ab6b |
I've added your these as a test vignette: https://ropensci.r-universe.dev/ui#view:katex/katex-tests.html |
Very cool, and you are correct, wrapping the output using {htmltools} does work, and also the solution of assigning explicitly the output class (what you put in the gist). Both work even with some other gnarly latex equations I had tested. |
I just reinstalled from the rOpenSci dev repo, and with your commit 44f0f45 which now does the class assignment explicitly, it all works. |
The output of the code I have in the gist: https://gist.github.com/jmcastagnetto/e1f985c210b4b0251d8665f484d751b8 renders OK in Firefox, when using MathML for complex, multiline formulas (HTML doesn't work with those, for some reason), but it doesn't work with Chromium-based browsers. At leas under Ubuntu Linux 20.04LTS.
Attached some screenshots showing the HTML output rendered Firefox, Chromium and Brave browsers.
The text was updated successfully, but these errors were encountered: