mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
use skipStartupTypeset: true for MathJax config, and call MathJax.Hub.Typeset() later
setTimeout() is necessary for uiOutput(); we need to wait for a short while before typesetting math, otherwise two bad things can happen: 1. a math expression may be rendered twice (static output) 2. it is not rendered at all (dynamic ui output) so the compromise is to typeset math after a short while when the document is ready; 200 ms is an arbitrary choice here
This commit is contained in:
@@ -153,9 +153,14 @@ includeScript <- function(path, ...) {
|
||||
withMathJax <- function(...) {
|
||||
path <- 'https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
|
||||
tagList(
|
||||
tags$head(singleton(tags$script(src = path, type = 'text/javascript'))),
|
||||
tags$head(
|
||||
singleton(tags$script(HTML('window.MathJax = {skipStartupTypeset: true};'))),
|
||||
singleton(tags$script(src = path, type = 'text/javascript'))
|
||||
),
|
||||
...,
|
||||
tags$script(HTML('MathJax.Hub.Typeset();'))
|
||||
tags$script(HTML('$(function() {
|
||||
setTimeout(function() {MathJax.Hub.Typeset();}, 200);
|
||||
});'))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user