md_indent: Markdown indented code block

View source: R/md-chunk.R

md_indentR Documentation

Markdown indented code block

Description

Turn a character vector of lines into a single code block with each line indented four spaces. This markdown leaf block can be rendered as nested HTML ⁠<code>⁠ and ⁠<pre>⁠ tags. This is the code block format required by legacy Reddit-flavored Markdown.

Usage

md_indent(x, n = 4)

Arguments

x

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

n

A numeric vector

Details

An indented code block is composed of one or more indented chunks separated by blank lines. An indented chunk is a sequence of non-blank lines, each indented four or more spaces. The contents of the code block are the literal contents of the lines, including trailing line endings, minus four spaces of indentation. An indented code block has no info string.

Value

A glue object of length 1, with the elements of x preceded with 4 spaces and separated by a newline.

See Also

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

Examples

md_indent(deparse(md_bold))

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