Skip to content

Question: How to insert a node during DocumentParsedEvent #633

Answered by colinodell
aarondfrancis asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the kind feedback!

Inserting new nodes during DocumentParsedEvent is a little weird due to inconsistencies with how nodes and parsing is implemented in 1.x. In a nutshell, you can't rely on finalize(), finalStringContents, or any block constructor parameter that accepts inner contents. These only exist for the sake of the previous parsing step. During parsing, the engine will use that information to construct all of the child elements. But once parsing is completed the engine will no longer look at those properties or do anything with them.

(In 2.x we're removing all node methods and properties that are solely used for parsing, as it incorrectly mixes two responsibilities into …

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by colinodell
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question General questions about the project or usage
2 participants
Converted from issue

This discussion was converted from issue #606 on June 12, 2021 13:52.