-
Notifications
You must be signed in to change notification settings - Fork 858
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
IndexError when defining links in nested block elements #584
Comments
Hmm, I may take a look at this in the next couple of days if I have a chance. Issue doesn't look obvious to me. |
Hmm, there could be a number of things going on here. Some initial thoughts without verifying anything... Do you have the I also find it peculiar that the only content within the first Finally, the second |
From what I recall, for each level of nested div you want to parse, |
Yes, that's where the
This is indeed just a minimal example. I noticed the error in a real Markdown document, and stripped it down to this. You can play around with the script below to find out when the error does, and does not, occur. To me, the pattern is not obvious.
Removing the Here's an executable test script: #!/usr/bin/env python3
# coding=utf-8
from markdown import Markdown, __version__
print('Markdown %s' % __version__.version)
md = Markdown(extensions=['markdown.extensions.extra'])
text = '''
<div markdown="1">
[link]: a_link
<div markdown="1">
</div>
</div>
'''
print(md.convert(text)) |
Is it possible you could give a stripped down practical application? It may prompt a quicker fix. The above example, while the simplest case, does not seem like it needs an urgent fix because it seems impractical. I plan to look into it regardless, but the critical nature of it may affect how quickly I get to it as the above example doesn't seem like a scenario we should run into very often. |
It seems by preserving the line where a reference was (before being stripped out) prevents bad indexing of the calculated positions of the content (calculated when parsing raw HTML). Essentially the reference preprocessor can change the tag_data indexing by removing the line in which it existed. I'll have a pull together shortly. |
Preserve the line which a reference was on to prevent raw HTML indexing issue. Ref #584.
When using nested block elements of the following kind:
An
IndexError
occurs:This happens only under very specific circumstances (but reliably so). For example, adding an extra blank line below the link definition will fix the error.
Hope this is useful!
The text was updated successfully, but these errors were encountered: