Skip to contents

Convenience wrapper around pander::pandoc.list.return() to convert a character vector (or something coercible to) to a Markdown list.

Usage

as_md_list(
  x,
  type = c("unordered", "ordered", "ordered_roman"),
  tight = TRUE,
  indent_lvl = 0L,
  wrap = NULL
)

Arguments

x

R object, e.g. a character vector. Each element of x will become an item in the resulting Markdown list.

type

Markdown list type. One of

  • "unordered" for an unordered aka bullet list. Corresponds to <ul> in HTML.

  • "ordered" for an ordered aka numbered list. Corresponds to <ol> in HTML.

  • "ordered_roman" for a variation of an ordered/numbered list with uppercase roman numerals instead of Arabic numerals as list markers.

tight

Whether or not to add additional spacing between list items.

indent_lvl

Level of indentation of the resulting Markdown list. For each level, four additional spaces are added in front of every list item. An integer scalar.

wrap

An optional string to wrap the list items in.

Value

If x is empty, a character vector of length zero. Otherwise, a character scalar.

See also

Other (Pandoc) Markdown functions: as_md_val_list(), as_md_vals(), md_verb(), pipe_table(), strip_md(), strip_md_footnotes()

Examples

rownames(mtcars) |>
  pal::as_md_list() |>
  cat()
#> * Mazda RX4 
#> * Mazda RX4 Wag 
#> * Datsun 710 
#> * Hornet 4 Drive 
#> * Hornet Sportabout 
#> * Valiant 
#> * Duster 360 
#> * Merc 240D 
#> * Merc 230 
#> * Merc 280 
#> * Merc 280C 
#> * Merc 450SE 
#> * Merc 450SL 
#> * Merc 450SLC 
#> * Cadillac Fleetwood 
#> * Lincoln Continental 
#> * Chrysler Imperial 
#> * Fiat 128 
#> * Honda Civic 
#> * Toyota Corolla 
#> * Toyota Corona 
#> * Dodge Challenger 
#> * AMC Javelin 
#> * Camaro Z28 
#> * Pontiac Firebird 
#> * Fiat X1-9 
#> * Porsche 914-2 
#> * Lotus Europa 
#> * Ford Pantera L 
#> * Ferrari Dino 
#> * Maserati Bora 
#> * Volvo 142E