Expand description
Query API for finding elements in AST
This module provides query methods for finding elements in the AST that match certain conditions.
§Example
use markdown_ppp::ast::*;
use markdown_ppp::ast_transform::Query;
let doc = Document {
blocks: vec![
Block::Paragraph(vec![
Inline::Text("hello".to_string()),
Inline::Autolink("https://example.com".to_string()),
]),
],
};
// Find all autolinks
let autolinks = doc.find_all_inlines(|inline| {
matches!(inline, Inline::Autolink(_))
});
assert_eq!(autolinks.len(), 1);
// Count text nodes
let text_count = doc.count_inlines(|inline| {
matches!(inline, Inline::Text(_))
});
assert_eq!(text_count, 1);Traits§
- Query
- Query trait for finding elements in AST structures