md_link: Markdown inline link (6.6)

View source: R/md-link.R

md_linkR Documentation

Markdown inline link (6.6)

Description

Take character vectors of link texts, link destinations, and optional titles and return single glue vector of valid markdown inline links. This inline is rendered as the ⁠<href>⁠ HTML tag.

Usage

md_link(text, url, title = NULL, ..., .name = FALSE)

Arguments

text

A character vector of text with another vector of URLs passed to the url argument.

url

A character vector of URLs.

title

The optional title of the link.

...

A sequence of text = "/url" named vector pairs. If any such pairs are provided, .name will be considered TRUE.

.name

logical; if TRUE, the pairs in ... will be used instead of any values supplied to x and url.

Details

A link contains link text (the visible text), a link destination (the URI that is the link destination), and optionally a link title. There are two basic kinds of links in Markdown. In inline links the destination and title are given immediately after the link text.

A link text consists of a sequence of zero or more inline elements enclosed by square brackets ([ and ⁠]⁠)...

An inline link consists of a link text followed immediately by a left parenthesis (, optional whitespace, an optional link destination, an optional link title separated from the link destination by whitespace, optional whitespace, and a right parenthesis ⁠)⁠. The link’s text consists of the inlines contained in the link text (excluding the enclosing square brackets). The link’s URI consists of the link destination, excluding enclosing ⁠<...>⁠ if present, with backslash-escapes in effect as described above. The link’s title consists of the link title, excluding its enclosing delimiters, with backslash-escapes in effect as described above.

Value

A glue vector of collapsed display text and associated URLs.

See Also

Other inline functions: md_autolink(), md_bold(), md_code(), md_convert(), md_disallow(), md_escape(), md_hardline(), md_image(), md_issue(), md_italic(), md_softline(), md_strike(), md_text()

Examples

md_link(1:5, glue::glue("https://{state.abb[1:5]}.gov"), state.name[1:5])
md_link(CRAN = "https://cran.r-project.org/")

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