Arguments
- dir
For
parse_qmd_dir(), the directory to scan. Forwrite_qmd_dir(), the destination directory;NULL(the default) writes each document back to the path it was read from.- pattern
A regular expression selecting files (default
"\\.qmd$").- recurse
Whether to descend into subdirectories.
- quiet
Suppress per-file diagnostic signaling (default
TRUE; diagnostics are still attached to each document's@diagnostics).- prune_errors
Passed to
parse_qmd().- x
A
qmd_collection.
Details
qmd_collection is a lightweight container holding several parsed
pandoc documents, modeled on parsermd's document collections. It
lets you parse a directory of .qmd files once and then run the same
selection and rewriting verbs across every document in a single pipe.
The selection and mutation verbs from select_nodes() dispatch on a
collection:
Selection verbs (
select_nodes,select_descendants,select_children,select_first) map over the documents and return a named list of per-document results (so you keep track of which document each match came from).Mutation verbs (
map_nodes,replace_nodes,delete_nodes,splice_nodes,insert_before,insert_after) rewrite every document and return a newqmd_collection.walk_nodesapplies a side effect to every document and returns the collection invisibly.ast_summary()returns a combineddata.framewith a leadingdoccolumn naming the source document, andas_df()returns a per-document named list of its tables.
The document-level helpers (ast_sections(), ast_toc(),
select_section(), split_sections(), ast_filter()) are
not collection-aware; map them over @docs yourself.
Examples
if (FALSE) { # \dontrun{
coll = parse_qmd_dir("docs", pattern = "\\.qmd$")
coll |>
map_nodes(is(pandoc_header), .f = \(h) add_class(h, "tagged")) |>
write_qmd_dir("docs-tagged")
ast_summary(coll)
} # }