Skip to contents

as_qmd() creates a chunk for inline Quarto markdown content (text-level) that fits within a table cell paragraph. This enables cross-references (@fig-xxx, @tbl-xxx), links, bold/italic, math, inline code, shortcodes and other inline Quarto markdown features inside flextable cells.

It is not designed for block-level elements such as headings, bullet lists or fenced code blocks.

The chunk is used with compose(), append_chunks() or prepend_chunks(). It requires the flextable-qmd Lua filter extension (see use_flextable_qmd()) and works with HTML, PDF and Word (docx) Quarto output formats.

Usage

as_qmd(x, display = x)

Arguments

x

character vector of Quarto markdown content.

display

character vector of display text used as fallback when the Lua filter is not active. Defaults to x.

Setup

  1. Install the extension once per project:

flextable::use_flextable_qmd()

  1. Add the filter to your Quarto document YAML. For HTML and PDF, a single line is enough:

filters:
  - flextable-qmd

For Word (docx), an additional post-render filter removes the wrapper table that Quarto adds around labelled flextables:

filters:
  - flextable-qmd
  - at: post-render
    path: _extensions/flextable-qmd/unwrap-float.lua

Supported markdown

  • Cross-references: @fig-xxx, @tbl-xxx

  • Bold / italic: **bold**, *italic*

  • Inline code: `code`

  • Links: [text](url) (internal and external)

  • Math: $\\alpha + \\beta$

  • Shortcodes and other Quarto markdown constructs

Limitations

Each table cell in a flextable contains a single paragraph built from inline chunks (see as_paragraph()). There is no mechanism to insert block-level structures (multiple paragraphs, lists, headings, fenced code blocks, callouts, etc.) inside a cell. Because as_qmd() produces one of these inline chunks, only inline markdown is supported.

See also

Examples

library(flextable)

dat <- data.frame(
  label = c("Bold", "Link", "Code"),
  content = c(
    "This is **bold** text",
    "Visit [Quarto](https://quarto.org)",
    "Use `print()` here"
  )
)
ft <- flextable(dat)
ft <- mk_par(ft, j = "content",
  value = as_paragraph(as_qmd(content)))
ft

label

content

Bold

This is **bold** text

Link

Visit [Quarto](https://quarto.org)

Code

Use `print()` here