You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Introduce a mechanism to duplicate/clone a node and all it's children? #560
When manipulating ASTs using nodes, sometimes you need to copy parts of the AST to a different place or part of the document.
The most naive approach I can think of is converting a document to a markdown string and parsing it again, but I'm sure there are subtle differences. It might be good for an initial implementation.
It might be nice to introduce a clone function which takes a node and returns a copy, including all children.
Activity
jgm commentedon Aug 22, 2024
This seems reasonable to me. @nwellnhof what do you think?
nwellnhof commentedon Aug 28, 2024
This should result in a perfect copy (except for source positions), but it's inefficient. A clone function certainly seems useful.
ioquatix commentedon Aug 28, 2024
Okay can I submit a PR?
jgm commentedon Aug 28, 2024
Yes!