-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
server.R
32 lines (26 loc) · 976 Bytes
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Workaround for https://github.com/yihui/knitr/issues/1538
evaluate2 <- function(...) evaluate::evaluate(...)
environment(evaluate2) <- asNamespace("knitr")
knitr::knit_hooks$set(evaluate = evaluate2)
function(input, output) {
regFormula <- reactive({
as.formula(paste('mpg ~', input$x))
})
output$report <- renderUI({
src <- normalizePath('report.Rmd')
# temporarily switch to the temp dir, in case you do not have write
# permission to the current working directory
owd <- setwd(tempdir())
on.exit(setwd(owd))
knitr::opts_knit$set(root.dir = owd)
tagList(
HTML(knitr::knit2html(text = readLines(src), fragment.only = TRUE)),
# typeset LaTeX math
tags$script(HTML('MathJax.Hub.Queue(["Typeset", MathJax.Hub]);')),
# syntax highlighting
tags$script(HTML("if (hljs) $('#report pre code').each(function(i, e) {
hljs.highlightBlock(e)
});"))
)
})
}