Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle annotations in fenced code blocks #393

Merged
merged 1 commit into from
May 26, 2023
Merged

Conversation

rpaul-stripe
Copy link
Contributor

@rpaul-stripe rpaul-stripe commented May 26, 2023

This PR fixes issue #390 — annotations inside of fenced code blocks apply their attributes to the top-level document node. The expected behavior is for annotations inside of fenced code blocks to result in a validation error.

The logic inside of the parser sets the value of the inlineParent variable to the immediate parent when it detects that the current token has children. This behavior is mostly correct, because in markdown-it the only tokens that ever have a children array are "inline" tokens. The processing for fenced code blocks is, however, a special case — we modify the token and put the synthesized tokens for the parsed interior text content into the fence's children array. This inadvertently results in the fence's parent being treated as the inlineParent for the nodes nested inside of the fence.

To address this issue, I modified the parser logic so that it only sets the inlineParent variable when the current node type is explicitly "inline".

Closes #390

@rpaul-stripe rpaul-stripe merged commit 9b358c8 into main May 26, 2023
2 checks passed
@rpaul-stripe rpaul-stripe deleted the fix-390 branch May 26, 2023 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Annotations inside code blocks add annotations to the document node
2 participants