md_chunk: Markdown code block

View source: R/md-chunk.R

md_chunkR Documentation

Markdown code block

Description

Take a character vector of lines and return a glue vector

Usage

md_chunk(x, type = c("tick", "tilde", "indent"), ...)

Arguments

x

A character vector of lines to be wrapped concatenated into a single block, possibly created by readLines() or deparse().

type

The type of code block to be created. Either "tick", "tilde" (which call md_fence()) or "indent" (which calls md_indent()).

...

Arguments to be passed to md_fence() or md_indent().

Details

Turn a character vector of lines into a single code block either indented or fenced in tildes or backticks. This markdown leaf block can be rendered as nested HTML ⁠<code>⁠ and ⁠<pre>⁠ tags. This function either calls md_fence() or md_indent() based on the type argument.

Value

A glue object of length 1, with elements of x formatted via md_fence() or md_indent().

See Also

Other leaf block functions: md_blank(), md_fence(), md_heading(), md_indent(), md_label(), md_paragraph(), md_reference(), md_rule(), md_setext(), md_table()

Examples

md_chunk("$ sudo apt install r-base-dev", info = "bash")
md_indent(
  n = c(4, 4, 6),
  x = c(
    "library(dplyr)",
    "starwars %>%",
    "filter(species == 'Droid')"
  )
)

gluedown documentation built on Nov. 2, 2023, 5:48 p.m.