Skip to content

IndexError when defining links in nested block elements #584

@smathot

Description

@smathot

When using nested block elements of the following kind:

<div markdown="1">

[link]: a_link

<div markdown="1">

</div>

</div>

An IndexError occurs:

doc-pelican (0.7)$ python3 test.py 
Markdown 2.6.9
Traceback (most recent call last):
  File "test.py", line 22, in <module>
    print(md.convert(text))
  File "/usr/lib/python3/dist-packages/markdown/__init__.py", line 371, in convert
    root = self.parser.parseDocument(self.lines).getroot()
  File "/usr/lib/python3/dist-packages/markdown/blockparser.py", line 65, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
  File "/usr/lib/python3/dist-packages/markdown/blockparser.py", line 80, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
  File "/usr/lib/python3/dist-packages/markdown/blockparser.py", line 98, in parseBlocks
    if processor.run(parent, blocks) is not False:
  File "/usr/lib/python3/dist-packages/markdown/extensions/extra.py", line 130, in run
    block = self._process_nests(element, block)
  File "/usr/lib/python3/dist-packages/markdown/extensions/extra.py", line 97, in _process_nests
    self.run(element, block[nest_index[-1][0]:nest_index[-1][1]],  # last
IndexError: list index out of range

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug report.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions