feat: Add parent reference to AstNode #5
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a minor version bump and enhances the AST node structure by adding parent references to each node. This change allows for easier navigation from a child node to its parent in the AST, which can be useful for various tree traversal and manipulation tasks. The update touches both the Rust and Python layers to ensure the new
parentfield is properly exposed and initialized.AST Node Structure Enhancements
parentfield to thePyAstNodestruct in Rust, allowing each node to reference its parent node. Thefrom_comrak_nodemethod now takes an optional parent reference and sets it appropriately when constructing the AST. (src/astnode.rs) [1] [2]comrak.pyi) to include the newparentattribute onAstNode, ensuring Python consumers can access parent nodes. The constructor signature was also updated to accept the parent parameter.API and Versioning
0.1.2to0.1.3in bothCargo.tomlandpyproject.tomlto reflect the new feature. [1] [2]Internal API Changes
parse_markdownfunction to pass the new parent parameter (Nonefor the root node) when constructing the AST. (src/lib.rs)PyAstNode::newconstructor to initialize theparentfield toNoneby default. (src/astnode.rs)