Arguments
- input
Either a
ts_tree(re-renders to QMD viato_qmd()then re-parses), a single string treated as text/file path (perparse_qmd()'s rules), or raw text.- query_text
A tree-sitter query string (S-expression form). See https://github.com/quarto-dev/q2/tree/main/crates/tree-sitter-qmd/tree-sitter-markdown/queries/ for live examples.
Value
A list with one element per match. Each match is itself a
named list whose names are the capture identifiers in query_text
and whose values are ts_node objects. Returns list() when no
matches are found.
Details
Power-user escape hatch alongside select_nodes(). Compiles
query_text against the tree-sitter-qmd grammar and returns one
entry per match, with captures keyed by name.
This bypasses the tidyselect-style mask entirely; use select_nodes()
if a CSS/predicate query is enough. ts_query() is the right tool when
you need full structural pattern matching, captures, or predicates
(#eq?, #match?, ...) from the tree-sitter query language.
Examples
if (FALSE) { # \dontrun{
ts = parse_qmd("# Heading\n\nbody\n", ast = "ts")
ts_query(ts, "(atx_heading) @h")
} # }