Skip to content

Instantly share code, notes, and snippets.

@daroczig
Last active August 29, 2015 14:23
Show Gist options
  • Save daroczig/e56e0e8ad3e8a3eed31e to your computer and use it in GitHub Desktop.
Save daroczig/e56e0e8ad3e8a3eed31e to your computer and use it in GitHub Desktop.
Markdown preview via shiny, pandoc and pander
library(shiny)
library(pander)
shinyServer(function(input, output) {
output$html = reactive({
## convert input to html
t <- Pandoc.convert(
text = input$markdown,
format = 'html',
open = FALSE,
options = '-s')
## 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
Copy link
Author

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