Turn a character vector into a vector of valid markdown ATX headings. These markdown leaf blocks can be rendered as the <h1> through <h6> HTML tags. See md_setext() to create setext (underlined) headings.

md_heading(x, level = 1)

Arguments

x

A character vector of heading text.

level

A numeric vector of use to determine the number of heading hash characters to preceed each element of x. The heading level is equal to the number of # characters in the opening sequence.

Value

A glue vector of headings with length equal to x.

Details

An ATX heading consists of a string of characters, parsed as inline content, between an opening sequence of 1–6 unescaped # characters and an optional closing sequence of any number of unescaped # characters. The opening sequence of # characters must be followed by a space or by the end of line. The optional closing sequence of #s must be preceded by a space and may be followed by spaces only. The opening # character may be indented 0-3 spaces. The raw contents of the heading are stripped of leading and trailing spaces before being parsed as inline content. The heading level is equal to the number of # characters in the opening sequence.

See also

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

Examples

md_heading("Overview")
#> # Overview
md_heading(x = c("One", "Two"), level = 1:2)
#> # One
#> ## Two
md_heading(x = c("Installation", "Usage"), level = 2)
#> ## Installation
#> ## Usage