I create a R Markdown file in RStudio , then I click on the Knit HTML
button on the top of the screen to create and save an HTML page which I want to use elsewhere, say store it on my server.
The problem with the HTML file, is that it contains
<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/2.0-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
which is not valid anymore, and when I edit the HTML and change the source to the following it works.
https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
Any way I don't have to edit every time the HTML, but have the correct source from RStudio?
This was changed in the rmarkdown
package just about a month ago (see this commit). You just need to install the latest version of the rmarkdown package:
> devtools::install_github("rstudio/rmarkdown")
(of course, you'll also need to install.packages("devtools")
if you don't have devtools.)
Incidentally, even without this step, you can tell rmarkdown where you want to get MathJax from. This is useful if you want to point to a different CDN.
output:
html_document:
mathjax: https://d3eoax9i5htok0.cloudfront.net/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
Finally, you can eliminate your MathJax CDN dependency entirely by using mathjax: local
to use a built-in copy of MathJax in rmarkdown (note that you'll also need to set self_contained: no
to do this).