Learn R Programming

munch (version 0.0.3)

as_paragraph_md: Convert Markdown to a Paragraph Object

Description

Converts a markdown string to a paragraph object compatible with flextable. This allows using markdown syntax to format text in flextable cells.

Usage

as_paragraph_md(x, font_family_mono = "mono")

Value

A paragraph object (class "paragraph") that can be used with flextable::mk_par() or flextable::as_flextable().

Arguments

x

A character string containing markdown.

font_family_mono

Font family to use for inline code. Defaults to "mono".

Details

Supported markdown syntax:

  • **bold** or __bold__

  • *italic* or _italic_

  • `code` (monospace)

  • ~~strikethrough~~

  • [link](url) (underlined and colored)

  • ![alt](path) (images)

  • Line breaks with \n\n (paragraph) or two spaces + \n (hard break)

Examples

Run this code
library(flextable)

ft <- flextable(head(iris, 3))
ft <- mk_par(
  ft,
  j = 1,
  part = "body",
  value = as_paragraph_md("**Column1** has *values*")
)
ft

# With inline code
ft <- mk_par(
  ft,
  j = 2,
  part = "body",
  value = as_paragraph_md("Use `Sepal.Width` column")
)
ft

Run the code above in your browser using DataLab