1

I am trying to load and render in a Shiny app a series of math exercices written in markdown. Let's take 2 exercices for the sake of example. ex1.Rmd looks like this:

A formula: $x^2=x\times{}x$.

... and ex2.Rmd like this:

A different formula: $x^3=x^2\times{}x$.

When I run the following app:

exercices  <- c('ex1', 'ex2')
for(e in exercices) render(
  input         = paste0(e, '.Rmd'),
  output_format = html_document()
)

shinyApp(
  ui     = shinyUI(htmlOutput('exercices')),
  server = shinyServer(function(input, output) {

    output$exercices <- renderUI({
      lapply(exercices, htmlOutput, class='exercice')
    })

    for(e in exercices) local({
      output[[e]] <- renderUI(
        withMathJax(includeHTML(paste0(e, '.html')))
      )
    })

  })

)

... I only get the first formula. However, in the HTML structure, the two dynamic UI elements have correctly been created. But only the first one has a content.

enter image description here

Are you all getting the same result? If yes, what am I doing wrong?

juvchan
  • 6,113
  • 2
  • 22
  • 35
Arthur
  • 1,208
  • 13
  • 25
  • It seems that the HTML code generated by `render` and `withMathJax` is messing things up. If you use `includeMarkdown` with the `rmd` files both get displayed. I don't have a solution to the HTML problem though. – Xiongbing Jin Mar 07 '16 at 04:04
  • With `includeHTML` alone, I have the same problem. With `includeMarkdown` I correctly get all the exercices, but no math rendering. – Arthur Mar 07 '16 at 08:14

0 Answers0