Hi,
the function markdownToHTML
in the package markdown
(current CRAN version 0.8) does not seem to correctly convert mathjax syntax on rstudio.cloud, but it works on my local windows notebook.
Here is a simple example:
library(markdown)
res = markdownToHTML(text = "MATH HERE: $x^2$", fragment.only=TRUE)
cat(res)
On my windows notebook, I get the correct mathjax compatible output:
<p>MATH HERE \(x^2\)</p>
Yet, running the same code on rstudio cloud yields the wrong HTML
<p>MATH HERE: $x<sup>2$</sup></p>
that Mathjax cannot handle. Interestingly, "mathjax" is set as default option on both my local notebook and rstudio.cloud:
# "mathjax" option is set in both environments
markdownHTMLOptions()
> markdownHTMLOptions()
[1] "skip_html" "skip_style" "skip_images" "skip_links" "safelink"
[6] "toc" "escape" "fragment_only" "hard_wrap" "use_xhtml"
[11] "smartypants" "base64_images" "mathjax" "highlight_code"
Also a possible workaround to directly write the markdown code in native mathjax format, like \(x^2\)
instead of $x^2$
does not work. While the RMarkdown package may work, it is much slower than markdown::markdownToHTML
and not well suited for my application.
To replicate the problem, you can also run the code in the file mathjax_test.R
in the following public cloud project: https://rstudio.cloud/project/46324