Mathjax在一个有光泽的BS警报中

时间:2017-05-05 17:18:20

标签: r shiny shinybs

有没有办法在shinyBS创建的提醒中使用MathJax?下面的尝试不能按预期工作。

library(shiny)
library(shinyBS)
shinyApp(
  ui =
    fluidPage(
      sidebarLayout(
        sidebarPanel(textInput("num1", NULL, value = 100),
                     "divided by", textInput("num2", NULL, value = 20),
                     "equals", textOutput("exampleOutput")),
        mainPanel(
          withMathJax(bsAlert("alert"))
        )
      )
    ),
  server =
    function(input, output, session) {
      output$exampleOutput <- renderText({
        num1 <- as.numeric(input$num1)
        num2 <- as.numeric(input$num2)

        if(num2 == 0) {
          createAlert(session, "alert", "exampleAlert", title = "Oops",
                      content = HTML("You cannot divide by <span class='math inline'>\\(0\\)</span>."))
        } else {
          closeAlert(session, "exampleAlert")
          return(num1/num2)
        }

      })
    }
)

1 个答案:

答案 0 :(得分:0)

这适用于{<1}},如OP

withMathJax(bsAlert("alert"))

奇怪,因为脚本包含两次。