Last active
August 29, 2015 14:23
-
-
Save daroczig/e56e0e8ad3e8a3eed31e to your computer and use it in GitHub Desktop.
Markdown preview via shiny, pandoc and pander
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(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') | |
}) | |
}) |
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
rmarkdown
version: https://gist.github.com/daroczig/2812971d0c2613ceb669