Package index
Parsing and rendering
Convert between QMD text/files and q2r’s two AST representations, and render an AST back to QMD source.
-
parse_qmd()experimental - Parse QMD input with pampa
-
to_qmd()experimental - Render an R-side AST back to QMD text
-
render_qmd()experimental - Render an AST to an output document with Quarto
Diagnostics
Structured parse diagnostics emitted by the reader, plus the lazy text renderer used by print() / format().
-
pampa_diagnostic() - Parse diagnostic produced by the pampa parser
Files and collections
File round-trip sugar over parse_qmd() / to_qmd(), and a lightweight container for parsing and writing back a whole directory of QMD documents at once.
-
read_qmd()write_qmd()edit_qmd()experimental - Read, write, and edit QMD files
-
qmd_collection()parse_qmd_dir()write_qmd_dir()experimental - A collection of QMD documents
Querying and rewriting the AST
A predicate-driven query/rewrite vocabulary shared across both the Pandoc S7 AST and the tree-sitter AST.
Locating nodes
tidyselect-style verbs for locating nodes by predicate. Predicates are unquoted expressions evaluated against a per-node data mask that exposes slot names and helpers (is(), has_class(), has_id(), has_attr(), is_leaf(), …).
-
select_nodes()select_descendants()select_children()select_first()walk_nodes()map_nodes()replace_nodes()delete_nodes()splice_nodes()insert_before()insert_after()experimental - Select, filter, and rewrite nodes in a Pandoc or tree-sitter AST
Mutating nodes
Predicate-driven mutation verbs. Each return value is a node, a list of nodes (splice), or NULL (delete). The walker is post-order, matching Pandoc Lua filters’ default.
-
select_nodes()select_descendants()select_children()select_first()walk_nodes()map_nodes()replace_nodes()delete_nodes()splice_nodes()insert_before()insert_after()experimental - Select, filter, and rewrite nodes in a Pandoc or tree-sitter AST
Filter-table rewriting (Lua-filter-style)
ast_filter() rewrites multiple node types in one pass using a table of S7-class-keyed handlers, with optional top-down traversal and list-level dispatch on pandoc_inlines / pandoc_blocks. ast_text() flattens a subtree to plain text.
-
ast_filter()experimental - Apply a table of type-keyed handlers to a pandoc AST
-
ast_skip()experimental - Mark a value as "use as-is, do not descend" inside ast_filter()
-
ast_text()experimental - Flatten a pandoc subtree to plain text
Attribute helpers
Concise immutable getters and setters for the @attr slot (id, classes, key-value attributes) found on headers, divs, code, links, spans, and friends.
-
has_class()add_class()remove_class()get_id()set_id()get_attr()set_attr()experimental - Attribute manipulation helpers
Constructing content
Ergonomic coercion helpers that accept strings, single nodes, or lists and produce the canonical pandoc_inlines / pandoc_blocks wrappers.
-
as_inlines()as_blocks()experimental - Coerce flexible input into pandoc_inlines or pandoc_blocks
Tables
Convert between a pandoc_table and a data.frame: flatten a parsed table to columns, or build a renderable table from a data frame (alignment, caption, and id ride along as attributes).
-
as_df()as_table()experimental - Convert between pandoc tables and data frames
Code cells
Read and edit Quarto executable cells: engine, label, body, and #| options on a pandoc_code_block, plus collect_code() to tangle a document’s cells. Inside a predicate the mask also exposes is_code_cell() and has_option().
-
is_code_cell()cell_engine()cell_options()cell_code()cell_label()set_cell_options()set_cell_label()collect_code()experimental - Quarto code-cell helpers
Document structure
Author-altitude helpers over the top-level block stream: the enclosing-heading chain, section slicing and splitting, a tabular overview, and a generated table of contents.
-
ast_sections()experimental - Heading-section path for each top-level block
-
select_section()experimental - Select the blocks belonging to a heading section
-
ast_summary()experimental - Tabular overview of a document's top-level blocks
-
ast_toc()experimental - Build a table of contents from a document's headings
-
split_sections()experimental - Split a document into per-section sub-documents
Tree-sitter queries
Raw tree-sitter .scm query escape hatch with capture support, for cases where the predicate API is not expressive enough.
-
ts_query()experimental - Run a tree-sitter
.scmquery against QMD source
Pandoc AST
The S7 class hierarchy returned by parse_qmd() (the default ast = "pd") and accepted by to_qmd().
Root and abstract classes
pandoc is the document root and pandoc_node the common ancestor for every concrete node (with the abstract pandoc_block / pandoc_inline parents). pandoc_blocks / pandoc_inlines are the strict-typed list wrappers used in content slots. pandoc_children / pandoc_format_label are the generics behind the tree display, which print.pandoc documents.
-
pandoc() - Top-level Pandoc document
-
pandoc_node()pandoc_block()pandoc_inline() - Virtual parent classes
-
pandoc_blocks()pandoc_inlines() - Typed list wrappers
-
pandoc_children() - Children of a pandoc AST node for tree display
-
pandoc_format_label() - Label a pandoc AST node for tree display
-
print.pandocprint.pandoc_nodeprint.pandoc_blocksprint.pandoc_inlines - Print a Pandoc AST
Block constructors
Constructors for the concrete block-level node classes, collected on a single page (one alias and usage entry per constructor).
-
pandoc_plain()pandoc_paragraph()pandoc_line_block()pandoc_code_block()pandoc_raw_block()pandoc_block_quote()pandoc_ordered_list()pandoc_bullet_list()pandoc_definition_list()pandoc_header()pandoc_horizontal_rule()pandoc_figure()pandoc_div()pandoc_table()pandoc_block_metadata()pandoc_note_definition_para()pandoc_note_definition_fenced_block()pandoc_caption_block()pandoc_custom_block() - Block constructors
Inline constructors
Constructors for the concrete inline node classes, collected on a single page (one alias and usage entry per constructor).
-
pandoc_str()pandoc_emph()pandoc_underline()pandoc_strong()pandoc_strikeout()pandoc_superscript()pandoc_subscript()pandoc_small_caps()pandoc_quoted()pandoc_cite()pandoc_code()pandoc_space()pandoc_soft_break()pandoc_line_break()pandoc_math()pandoc_raw_inline()pandoc_link()pandoc_image()pandoc_note()pandoc_span()pandoc_shortcode()pandoc_note_reference()pandoc_attr_inline()pandoc_insert()pandoc_delete()pandoc_highlight()pandoc_edit_comment()pandoc_custom_inline() - Inline constructors
Support types
Helper types that appear inside concrete nodes: attributes, table substructures, citations, captions, metadata.
-
pandoc_attr()pandoc_list_attributes()pandoc_citation()pandoc_caption()pandoc_definition_item()pandoc_col_spec()pandoc_cell()pandoc_row() - Pandoc AST support types
-
pandoc_table_head()pandoc_table_body()pandoc_table_foot() - Table head / body / foot
-
pandoc_meta_value()pandoc_config_value() - Pandoc meta / config value
Tree-sitter AST
S7 classes for the tree-sitter concrete syntax tree returned by parse_qmd(ast = "ts"). The tree is structurally faithful to the source bytes; use it when to_qmd() round-trip equivalence matters. print.ts_tree documents the tree display and its position / ascii knobs.
-
ts_point()ts_range()ts_nodes()ts_node()ts_tree() - Tree-sitter AST classes
-
print.ts_treeprint.ts_node - Print a tree-sitter AST