-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat: flatten childToken arrays #3172
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@calculuschild this should work to walk arrays of arrays of tokens. One question: Should we flatten with infinite depth? or should we only flatten 1 or 2 levels deep? The only issue I found with doing Infinite depth is there can be a stack overflow if there is a circular dependency. I don't think that is a big issue but something to think about. a = [1]
b = [2]
a.push(b)
b.push(a)
a.flat(Infinity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think infinite depth shouldn't be a problem. If people are designing extensions in such a way to cause a cyclic dependency, that's a fault of the extension, not Marked, right?
I agree. This shouldn't affect core marked at all. Only extensions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could also use a large-ish depth instead of Infinity, perhaps 1000, and still cover most use cases.
But I agree, its only for self-referencing extensions which is probably a small minority.
Marked version: 11.1.1
Description
Flatten custom extension childToken arrays before running them through walk tokens. This will allow custom extensions to have child tokens like the
table
token where therows
field is an array of arrays of tokens.Contributor
Committer
In most cases, this should be a different person than the contributor.