Since I updated my pkgdown to 1.4.0, I have been having issues with how math equations and symbols from README.Rmd are getting rendered on Home page of pkgdown website for my package.
REAMDE: https://github.com/IndrajeetPatil/ggstatsplot/blob/master/README.md
Website: https://indrajeetpatil.github.io/ggstatsplot/
Here are a few examples of what the README output looks like and how it is rendered by pkgdown:
README output

pkgdown output

README output

pkgdown output

Etc.
I can reproduce on Chromium but it looks fine on Firefox. Maybe this can help pinpoint the source of this issue.
@jayhesselberth Any possibility of working on fixing this issue any time soon?
I have had an ugly homepage for my pkgdown website for a few months now. I'd really appreciate any help in fixing this issue. Thanks.
I also just checked and can confirm the page is malformed on chrome but looks fine on firefox.
I wonder if it's an issue with Mathjax. The most recent commit that modifies the Mathjax library brings in an extra JS library. I don't know enough about how Mathjax works to make a prediction about whether this is the issue, but could you delete each one of those from your site locally and confirm whether it fixes the issue? Or revert to the older Mathjax library code?
@IndrajeetPatil if you want help, you should start by creating a minimal reprex package that illustrates the problem. But this issue appears to only affect you, so I think is low priority.
@jayhesselberth Thanks for the suggestion. Will try to do that.
While exploring some documentation on mathjax in pkgdown website, I found that the source of this document is 404: https://github.com/r-lib/pkgdown/blob/master/vignettes/test/mathjax.Rmd

Hmm that's a link to old content (wrong version is in the badge). We may need to run clear out old content with clean_site() on travis before building new content.
Here's the correct mathjax code:
@hadley Here is a minimal reprex package that demonstrates this issue:
https://github.com/IndrajeetPatil/minimalReprex
GitHub README looks fine:
https://github.com/IndrajeetPatil/minimalReprex/blob/master/README.md

But pkgdown output is malformed:

I see two different issues here:
Regarding the issue you reported in your first comment, it seems to be stemming from a difference in how Firefox and Chromium are handling embed src. Firefox treats it as img src while Chromium actually embeds the document. I'm not entirely sure why embed src is needed over img src here anyways. This is probably due to pandoc itself and they might have a good reason to do so.
Regarding your comment https://github.com/r-lib/pkgdown/issues/1150#issuecomment-559804461. It's not a browser display issue but a parsing issue. The source code itself is wrong and this issue is reproducible in both Firefox and Chromium. Weirdly here, img src is used instead of embed src. Did you use the same pandoc version as your initial comment?
I'm trying to get rid of MathJax as well for another package of mine and it looks like rmarkdown doesn't properly support --webtex or --mathml options for some outputs. It seems to work fine with for github_document but not for html_document for example.
@Bisaloo Thanks for trying to get to the bottom of this issue! I am not an expert in HTML/JS, so I am a bit out of my depth here, unfortunately.
I _can_ confirm though that I am using the same version of pandoc (2.7.2) in both my original comment and minimal reprex comment.
I have used rmarkdown support for --webtex only in github_document and can confirm that it works fine but haven't tried --mathml.
I just updated to pandoc 2.8.0.1 and can confirm that the same issue still holds.
I'm also having problems with mathjax rendering for README.md, but the issue seems slightly different. For me, pkgdown renders inline math in my articles (vignettes) just fine, but it doesn't render the same inline math in the README.md file. In an article, the text "$p$-value" gets rendered in html as
<span class="math inline">\(p\)</span>-value
but the same thing from the README.md file gets rendered in index.html as
$p$-value
Is there a way to have the README.md rendered the same way as the articles?
An example is at
https://pdhoff.github.io/FABInference/index.html
Thanks for any help or suggestions.
@pdhoff, it's because pandoc needs the tex_math_dollars and tex_math_single_backslash extensions. I just verified it by adding them in my pkgdown fork, and by compiling your page.
@jayhesselberth, @hadley, do you think these extensions should be added? I'm asking because I'm not familiar enough with the codebase to know if it could have unforeseen consequences in other places.
Oh and btw, @IndrajeetPatil, is that the reason you are using --webtex? Because this would also solve your issue then (even though the issue with --webtex remains a partial mystery to me)
@Bisaloo can you submit a PR with the suggested changes? Then others can confirm whether it works for them, and we can determine whether the changes would have unintended consequences.
I don't know enough about pandoc / mathjax to make a prediction about the effect.
@Bisaloo Thanks, I understand that inlineMath: [ ['$','$'] needs to be specified, but I don't know where to put it. How have you done it? Ideally it could be specified in the override option in the build_home function but maybe it is more complicated than that.
@jayhesselberth These extensions are apparently already being used when rendering .Rmd files for articles, but for some reason not for README.md's or README.Rmd's. I'm not sure if the different behavior is a feature or a bug, but I'm pretty sure (I could check) that this difference in rendering was not present in previous pkgdown versions.
Thanks for your help and comments.
Closing following https://github.com/r-lib/pkgdown/issues/1207#issuecomment-575899270