Skip to content

Instantly share code, notes, and snippets.

@nutterb
Created April 8, 2016 00:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nutterb/7d723f64201c9afa8bb57774b47bfd7c to your computer and use it in GitHub Desktop.
Save nutterb/7d723f64201c9afa8bb57774b47bfd7c to your computer and use it in GitHub Desktop.
Shiny Real-time markdown rendering
library(shiny)
library(knitr)
library(markdown)
ui <- shinyUI(
fluidPage(
fluidRow(
column(
width = 6,
tags$textarea(
id = "text",
cols = 50,
rows = 30
)
),
column(
width = 6,
uiOutput('markdown')
)
)
)
)
server <- function(input, output) {
output$markdown <- renderUI({
HTML(markdown::markdownToHTML(text = input$text))
})
}
shinyApp(ui, server)
# Copy and paste the code below into the textArea input when the application is running.
# Header 1
## Header 2
### Header 3
#### Header 4
##### Header 5
It would be really helpful to include a link to a markdown cheat sheet. [This is a good example](http://support.mashery.com/docs/read/customizing_your_portal/Markdown_Cheat_Sheet) of where to get a good rundown of basic markdown.
> We can place block quotes this way
> It's quite lovely
```
We can also block out code segments.
x <- rnorm(100)
hist(x)
```
If we want to make a table
| Column 1 | Column 2 |
|----------------|---------------:|
| r1, c1 | r1, c2 |
| r2, c1 | r2, c2 |
&nbsp;
The &nbsp; makes a non breaking space that is useful for putting in white space.
We write _italic_ text this way.
And we can make **bold** text this way
Lists are simple
* Item
* Item
* Item
Ordered lists are easy too
1. Item 1
2. Item 2
3. Item 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment