daattali / shinyalert

🗯️ Easily create pretty popup messages (modals) in Shiny
https://daattali.com/shiny/shinyalert-demo/
Other
241 stars 26 forks source link

MathJax support #54

Closed daattali closed 3 years ago

daattali commented 3 years ago

Extracted from #51

Thanks for the report by @gueyenono :

I am rendering an Rmarkdown (actually bookdown) HTML document inside shinyalert. Although the document is displayed properly inside the modal, the MathJax equations are not rendered despite the use of shiny::withMathJax().

daattali commented 3 years ago

You're right that MathJax doesn't seem to work. I don't know enough about how mathjax works and it's unlikely I'll fix it, unless someone else knows how to fix it. The reason I say it's unlikely I'll fix it is because I know that many other packages also struggle with mathjax, and even shiny::insertUI() doesn't seem to work with it:

library(shiny)

ui <- fluidPage(
  withMathJax(div("$$\\sqrt{1}$$")),
  actionButton("btn", "btn")
)

server <- function(input, output, session) {
  observeEvent(input$btn, {
    insertUI("body", "beforeEnd", withMathJax("$$\\sqrt{2}$$"))
  })
}

shinyApp(ui, server)

When I tried googling for "mathjax sweetalert" I did notice that @timelyportfolio 's sweetalertR has a line that mentions mathjax so perhaps he has some information that can be helpful, but I wouldn't count on it

daattali commented 3 years ago

This is now supported

gueyenono commented 3 years ago

@daattali Is it possible to get a minimal example?

daattali commented 3 years ago

You can see the example used in the PR https://github.com/daattali/shinyalert/pull/57