keaven / gsDesign

Group sequential design for clinical trials
https://keaven.github.io/gsDesign/
GNU General Public License v3.0
51 stars 14 forks source link

Use KaTeX for pkgdown math rendering #161

Closed nanxstats closed 4 months ago

nanxstats commented 4 months ago

What's in this PR

This PR brings back glorious math rendering to the pkgdown vignettes by switching the math rendering engine to KaTeX supported in pkgdown 2.1.0.

Before and after

This is what an example vignette section looks like before, current, and after this patch.

pkgdown 2.0.9 (old default, MathJax)

Click to expand screenshot old-mathjax

pkgdown 2.1.0 (new default, MathML)

Click to expand screenshot new-mathml

pkgdown 2.1.0 + KaTeX

Click to expand screenshot katex

Method

To make this work, I did two things:

Alternative paths

Apparently, MathML doesn't render very well for our formulas. Although we can choose the old default MathJaX, the font bundling situation is a bit more challenging to fix using the same customization approach as the fonts were defining in JS (I successfully converted them to CSS). Considering that KaTeX is faster and simpler, I think it's the optimal choice.