Skip to content

add node depth limit#422

Merged
robinst merged 9 commits intocommonmark:mainfrom
spirit-at-canva:spirit-add-node-depth-limit
Mar 31, 2026
Merged

add node depth limit#422
robinst merged 9 commits intocommonmark:mainfrom
spirit-at-canva:spirit-add-node-depth-limit

Conversation

@spirit-at-canva
Copy link
Copy Markdown
Contributor

@spirit-at-canva spirit-at-canva commented Mar 30, 2026

Why

I want to limit the max depth of node traversal.

What

We apply the limit when constructing the AST, by dropping deeper node generation (we collapse it into plain text).

@spirit-at-canva spirit-at-canva force-pushed the spirit-add-node-depth-limit branch 2 times, most recently from 137fc23 to bfe2c5a Compare March 30, 2026 09:23
@spirit-at-canva spirit-at-canva force-pushed the spirit-add-node-depth-limit branch from bfe2c5a to f8f7684 Compare March 30, 2026 09:23
@spirit-at-canva
Copy link
Copy Markdown
Contributor Author

cc @robinst

Copy link
Copy Markdown
Collaborator

@robinst robinst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to DocumentParser, Parser, ParserTest LGTM, with some minor comments to address.

The visitor changes: Can you take them out of this PR? I'm not sure I want to include this by default on every visitor, and it's something that's pretty straightforward to add in subclasses (overriding the protected visitChildren method).

spirit-at-canva and others added 3 commits March 31, 2026 12:59
Co-authored-by: Robin Stocker <robinst@canva.com>
@spirit-at-canva spirit-at-canva requested a review from robinst March 31, 2026 02:02
@robinst robinst merged commit f40ff54 into commonmark:main Mar 31, 2026
6 checks passed
@robinst
Copy link
Copy Markdown
Collaborator

robinst commented Mar 31, 2026

Released in 0.28.0 now, thanks for the contribution 🎉!: https://github.com/commonmark/commonmark-java/blob/main/CHANGELOG.md#0280---2026-03-31

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.

2 participants