Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Markdown preview via shiny, pandoc and rmarkdown
library(shiny)
library(rmarkdown)
shinyServer(function(input, output) {
output$html = reactive({
t <- tempfile()
cat(input$markdown, file = t)
## convert input to html
t <- render(
input = t,
output_format = 'html_document')
## read results
res <- readLines(t)
## cleanup
unlink(sub('.html$', '*', t))
## return
paste(res, collapse = '\n')
})
})
library(shiny)
shinyUI(fluidPage(
titlePanel('Try markdown'),
fluidRow(
column(6,
tags$textarea(
'Hello markdown!',
id = 'markdown',
rows = 25,
style = 'width:100%;')),
column(6,
htmlOutput('html')))
))
@daroczig

This comment has been minimized.

Copy link
Owner Author

@daroczig daroczig commented Jun 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment