show_markdown: Show markdown

View source: R/utils2.R

show_markdownR Documentation

Show markdown

Description

Render markdown to html in rstudio viewer or default browser.

Usage

show_markdown(
  ...,
  use_viewer = !is.null(getOption("viewer")),
  markArgs = list()
)

Arguments

...

one or more character strings

use_viewer

logical; if TRUE, attempts to use rstudioapi::viewer or opens in default browser on error

markArgs

a list of addition arguments passed to markdownToHTML

Value

The html code (invisibly) as a character string.

See Also

show_html, show_math

Examples

## Not run: 
library('markdown')

## separate strings of markdown
show_markdown('## this is a header','here is some *plain* text  ',
              '<font color=red>ahhh</font>')


## or as a single character string
mkd <- "
1. Here is some markdown I want to test
2. This is a list
  + a sub-point
  + another sub-point

```
This text is displayed verbatim / preformatted
```

and this text will be formatted using r syntax

```r
mean(1:5)
```

And now I will make a table:

First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell
Content Cell  | Content Cell

## ta-daaa!

> here's a picture with a [hyperlink](www.google.com):

<div align=center>
    <a href='http://xkcd.com/710/'>
        <img src='http://imgs.xkcd.com/comics/collatz_conjecture.png'
             style='display: block; margin: auto;' />
    </a>
</div>
"

show_markdown(mkd)


## the default stylesheet is
getOption('markdown.HTML.stylesheet')

## apply another style sheet by setting the option or passing
## arguments directly to markdown::markdownToHTML

## here are four css files in this package
list.files(system.file(package = 'rawr', 'styles'))
kcss <- system.file(package = 'rawr', 'styles', 'knitr.css')
gcss <- system.file(package = 'rawr', 'styles', 'github.css')
## file.show(gcss)


show_markdown(mkd, markArgs = list(stylesheet = gcss))
show_markdown(mkd, markArgs = list(stylesheet = kcss),
              use_viewer = FALSE)

## End(Not run)


raredd/rawr documentation built on April 29, 2024, 10:29 a.m.