| tbl_qmd_elements | R Documentation |
Functions to wrap content in HTML spans or divs with data-qmd attributes for Quarto processing within HTML tables. These functions are specifically designed for use with HTML table packages like kableExtra, gt, or DT where you need Quarto to process markdown content within table cells.
tbl_qmd_span(content, display = NULL, use_base64 = TRUE)
tbl_qmd_div(content, display = NULL, use_base64 = TRUE)
tbl_qmd_span_base64(content, display = NULL)
tbl_qmd_div_base64(content, display = NULL)
tbl_qmd_span_raw(content, display = NULL)
tbl_qmd_div_raw(content, display = NULL)
content |
Character string of content to wrap. This can include Markdown, LaTeX math, and Quarto shortcodes. |
display |
Optional display text (if different from content). Useful for fallback text when Quarto processing is not available or for better accessibility. |
use_base64 |
Logical, whether to base64 encode the content (recommended for complex content with special characters or when content includes quotes) |
These functions create HTML elements with data-qmd or data-qmd-base64
attributes that Quarto processes during document rendering. The base64
encoding is recommended for content with special characters, quotes, or
complex formatting.
Available functions:
tbl_qmd_span() and tbl_qmd_div() are the main functions with encoding options
tbl_qmd_span_base64() and tbl_qmd_div_base64() explicitly use base64 encoding
tbl_qmd_span_raw() and tbl_qmd_div_raw() explicitly use raw encoding
This feature requires Quarto version 1.3 or higher with HTML format outputs. For more information, see https://quarto.org/docs/authoring/tables.html#html-tables.
Character string containing the HTML element with appropriate data-qmd attributes
# Basic span usage in table cells
tbl_qmd_span("**bold text**")
tbl_qmd_span("$\\alpha + \\beta$", display = "Greek formula")
# Basic div usage in table cells
tbl_qmd_div("## Section Title\n\nContent here")
tbl_qmd_div("{{< video https://example.com >}}", display = "[Video content]")
# Explicit encoding choices
tbl_qmd_span_base64("Complex $\\LaTeX$ content")
tbl_qmd_span_raw("Simple text")
# Use with different HTML table packages
## Not run:
# With kableExtra
library(kableExtra)
df <- data.frame(
math = c(tbl_qmd_span("$x^2$"), tbl_qmd_span("$\\sum_{i=1}^n x_i$")),
text = c(tbl_qmd_span("**Important**", "bold"), tbl_qmd_span("`code`", "code"))
)
kbl(df, format = "html", escape = FALSE) |> kable_styling()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.