markdownHTMLOptions {markdown}R Documentation

Markdown HTML rendering options

Description

markdownHTMLOptions returns a character vector listing all the options that are available for the HTML renderer in the markdown package. As a convenience, the package default options were chosen to render well-formed stand-alone HTML pages when using markdownToHTML(). The default options are 'use_xhtml', 'smartypants', 'base64_images', 'mathjax', and 'highlight_code'.

Usage

markdownHTMLOptions(defaults = FALSE)

Arguments

defaults

If TRUE, then only the default options are returned. Otherwise all options are returned.

Details

The HTML renderer provides several options described below. To turn these on globally in the markdown package, simply place some or all of them in a character vector and assign to the global option markdown.HTML.options like so:

options(markdown.HTML.options = markdownHTMLOptions())

To reset the options to package default, use:

options(markdown.HTML.options = markdownHTMLOptions(default = TRUE))

To override the global option, pass the options as an argument:

markdownToHTML(..., options = c('skip_images'))

Description of all options:

'skip_html'

suppress output of all HTML tags in the document.

'skip_style'

suppress output of HTML style tags.

'skip_images'

suppress output of HTML image tags.

'skip_links'

suppress output of HTML anchor tags.

'safelink'

only create links for known url types, e.g. http, ftp, http, etc.

'toc'

assigns an HTML id to each header of the form 'toc_ where ' (starting at 0), and creates the table of contents.

'hard_wrap'

adds an HTML br tag for every newline (excluding trailing) found within a paragraph.

'use_xhtml'

create XHMTL 1.0 compliant HTML tags.

'escape'

escape all HTML found within the markdown. Overrides all of the 'skip_*' options mentioned above.

'smartypants'

translates plain ASCII punctuation characters into smart typographic punctuation HTML entities.

'fragment_only'

eliminates the inclusion of any HTML header or body tags, CSS, or Javascript components.

'base64_images'

Any local images linked with the '<img>' tag to the output HTML will automatically be converted to base64 and included along with output.

'mathjax'

includes appropriate Javascript libraries to render math markup.

'highlight_code'

includes appropriate Javascript libraries to highlight code chunks.

See the EXAMPLES section to see the output of each option turned on or off.

Value

A character vector listing either all available options or just the default options.

See Also

markdownToHTML

Examples

# List all available extensions:
markdownHTMLOptions()

# To turn on all HTML options globally:
options(markdown.HTML.options = markdownHTMLOptions())

# To turn off all HTML options globally:
options(markdown.HTML.options = NULL)

# To turn on package default HTML options globally:
options(markdown.HTML.options = markdownHTMLOptions(default = TRUE))

# HTML OPTIONS

# The following examples are short, so we allways add the HTML option 'fragment_only'
tOpt <- "fragment_only"

# skip_html example
mkd = '<style></style><img src="http://cran.rstudio.com/Rlogo.jpg"><a href="#">Hello</a>'
cat(markdownToHTML(text = mkd, options = c(tOpt)))
cat(markdownToHTML(text = mkd, options = c(tOpt, "skip_html")))

# skip_style example
cat(markdownToHTML(text = mkd, options = c(tOpt)))
cat(markdownToHTML(text = mkd, options = c(tOpt, "skip_style")))

# skip_images example
cat(markdownToHTML(text = mkd, options = c(tOpt)))
cat(markdownToHTML(text = mkd, options = c(tOpt, "skip_images")))

# skip_links example
cat(markdownToHTML(text = mkd, options = c(tOpt)))
cat(markdownToHTML(text = mkd, options = c(tOpt, "skip_links")))

# safelink example
cat(markdownToHTML(text = '[foo](http://google.com "baz")', options = c(tOpt)))
cat(markdownToHTML(text = '[foo](http://google.com "baz")', options = c(tOpt, "safelink")))

# toc example
mkd <- paste(c("# Header 1", "p1", "## Header 2", "p2"), collapse = "\n")

cat(markdownToHTML(text = mkd, options = c(tOpt)))
cat(markdownToHTML(text = mkd, options = c(tOpt, "toc")))

# hard_wrap example
cat(markdownToHTML(text = "foo\nbar\n", options = c(tOpt)))
cat(markdownToHTML(text = "foo\nbar\n", options = c(tOpt, "hard_wrap")))

# use_xhtml example
cat(markdownToHTML(text = "foo\nbar\n", options = c(tOpt, "hard_wrap")))
cat(markdownToHTML(text = "foo\nbar\n", options = c(tOpt, "hard_wrap", "use_xhtml")))

# escape example
mkd = '<style></style><img src="http://cran.rstudio.com/Rlogo.jpg"><a href="#">Hello</a>'
cat(markdownToHTML(text = mkd, options = c(tOpt, "skip_html")))
# overrides all 'skip_*' options
cat(markdownToHTML(text = mkd, options = c(tOpt, "skip_html", "escape")))

# smartypants example
cat(markdownToHTML(text = "1/2 (c)", options = c(tOpt)))
cat(markdownToHTML(text = "1/2 (c)", options = c(tOpt, "smartypants")))

cat(smartypants(text = "1/2 (c)\n"))

[Package markdown version 0.8.1 Index]