Created
June 29, 2015 11:32
-
-
Save daroczig/2812971d0c2613ceb669 to your computer and use it in GitHub Desktop.
Markdown preview via shiny, pandoc and rmarkdown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'))) | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pander
version: https://gist.github.com/daroczig/e56e0e8ad3e8a3eed31e