@unified-semantics/mdast-util-semtree
Version:
Transformer utility for semantically nesting mdast nodes to their proper hierarchy
24 lines (23 loc) • 809 B
TypeScript
import type { Root, RootContent } from 'mdast';
/**
* Configuration options for the semantic tree transformer
*/
export interface SemtreeOptions {
/**
* Whether to preserve the original list item structure (default: true)
*/
preserveListStructure?: boolean;
}
/**
* Creates a transformer function that organizes mdast nodes into a semantic hierarchy
* based on their heading levels
*/
export declare function semtree(options?: SemtreeOptions): (tree: Root) => Root;
/**
* Utility function to extract content belonging to a specific heading
*/
export declare function extractHeadingContent(tree: Root, headingText: string): RootContent[];
/**
* Creates a valid mdast tree from a node and its ancestors
*/
export declare function createSubtree(tree: Root, headingText: string): Root;