Removes all Markdown formatting from a character vector.
Details
This function relies on commonmark::markdown_text()
which supports the CommonMark specification plus the Github extensions. Unfortunately, Markdown footnotes can't be stripped
using commonmark::markdown_text()
. Therefore a separate option strip_footnotes
is offered which relies on regular expressions to remove inline footnotes
and footnote definitions and references.
See also
Other (Pandoc) Markdown functions:
as_md_list()
,
as_md_val_list()
,
as_md_vals()
,
md_verb()
,
pipe_table()
,
strip_md_footnotes()
Examples
pal::strip_md(
"A **MD** formatted [string](https://en.wikipedia.org/wiki/String_(computer_science))"
)
#> [1] "A MD formatted string"
# link references are only removed *iff* the reference is included in `x`:
pal::strip_md("[A reference link][refid]\n\n[refid]: https://example.com")
#> [1] "A reference link"
pal::strip_md("[A reference link][refid]\n\n_No ref here..._")
#> [1] "[A reference link][refid]\n\nNo ref here..."