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
Exponential parsing performance for nested brackets #1735
Comments
Here's the root of the problem (trace added to
|
This version should be a bit more efficient. This doesn't help with #1735, however.
More diagnostics (with a trace inside
|
The problem is that, if we get something like
we first try to parse All of this is completely fixed in CommonMark. We worked hard on a set of rules for links that could be parsed efficiently, and cmark can handle thousands-deep nested brackets without batting an eye. So it may be that the best solution here would be to retrofit pandoc to use something like the same algorithm. This would be a pretty large change, though, and might break things in some corner cases. I am open to other ideas. There may be a good way of fixing this in pandoc without any substantive revisions, but I haven't thought of it. |
A fallback measure might be putting some kind of fixed limit on |
Note; a fixed limit on depth for |
The rewrite is much more direct, avoiding parseFromString. And it performs significantly better; unfortunately, parsing time still increases exponentially. See #1735.
Similar case from #7283:
|
I came across a further example of what I believe to be this problem, similar to #7283. Converting a sizeable Markdown document containing a large number of internal links. Two of these links were incorrectly formed, lacking a closing bracket for the link text, for example:
Input: Arguments:
Version:
|
An other example of this:
(log output with special sequences for coloring on the terminal) |
Would it be possible/sensible to issue a log message/warning, when reaching level 3 or so of |
This concerns the Markdown reader.
Parsing time doubles for each additional nesting.
See commonmark/commonmark-spec#166.
The text was updated successfully, but these errors were encountered: