Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

downlit_md_path

Syntax highlight and link a md document


Description

downlit_md_* works by traversing the markdown AST generated by Pandoc. It applies highlight() to CodeBlocks and autolink() to inline Code.

Use downlit_md_path() to transform a file on disk; use downlit_md_string() to transform a string containing markdown as part of a larger pipeline.

Needs pandoc 1.19 or later.

Usage

downlit_md_path(in_path, out_path, format = NULL)

downlit_md_string(x, format = NULL)

Arguments

in_path, out_path

Input and output paths for markdown file.

format

Pandoc format; defaults to "gfm" if you have pandoc 2.0.0 or greater, otherwise "markdown_github".

x

A string containing markdown.

Value

downlit_md_path() invisibly returns output_path; downlit_md_string() returns a string containing markdown.

Examples

if (rmarkdown::pandoc_available("1.19")) {
downlit_md_string("`base::t()`")
downlit_md_string("`base::t`")
downlit_md_string("* `base::t`")

# But don't highlight in headings
downlit_md_string("## `base::t`")
}

downlit

Syntax Highlighting and Automatic Linking

v0.2.1
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.