diff --git a/python-markdown-extension/src/python_markdown_document_offsets_injection_extension/extension.py b/python-markdown-extension/src/python_markdown_document_offsets_injection_extension/extension.py index a2aa3b5b..1d6152a7 100644 --- a/python-markdown-extension/src/python_markdown_document_offsets_injection_extension/extension.py +++ b/python-markdown-extension/src/python_markdown_document_offsets_injection_extension/extension.py @@ -236,6 +236,9 @@ def run(self, parent: etree.Element, blocks: list[str]) -> bool: # append MARK_PREVENT_RECURSION to tail of the block to prevent recursion, we don't use a handled # flaglist because we don't know if there's some same block in the document self.parser.parseBlocks(parent, [block + MARK_PREVENT_RECURSION]) + # fix offset index out of range + if len(parent) == 0: + return True # fix multi blocks in same parents if self.meta["last_parent"] == parent[-1]: parent[-1].set("data-original-document-end", str(end))