| as_qmd | R Documentation |
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.
as_qmd(x, display = x)
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 |
Install the extension once per project:
flextable::use_flextable_qmd()
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
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
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.
use_flextable_qmd() to install the Lua filter extension,
knit_print.flextable() for rendering options in knitr documents.
Other chunk elements for paragraph:
as_b(),
as_bracket(),
as_chunk(),
as_equation(),
as_highlight(),
as_i(),
as_image(),
as_strike(),
as_sub(),
as_sup(),
as_word_field(),
colorize(),
gg_chunk(),
grid_chunk(),
hyperlink_text(),
linerange(),
minibar(),
plot_chunk()
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.