# Buggy code
def run(self, parent, blocks, tail=None, nest=False):
    self._tag_data = self.parser.md.htmlStash.tag_data

    self.parser.blockprocessors.tag_counter += 1
    tag = self._tag_data[self.parser.blockprocessors.tag_counter]

    # Create Element
    markdown_value = tag["attrs"].pop("markdown")
    element = etree.SubElement(parent, tag["tag"], tag["attrs"])

    # Slice Off Block
    if nest:
        self.parser.parseBlocks(parent, tail)  # Process Tail
        block = blocks[1:]
    else:  # includes nests since a third level of nesting isn't supported
        block = blocks[tag["left_index"] + 1 : tag["right_index"]]
        del blocks[: tag["right_index"]]

    # Process Text
    if (
        self.parser.blockprocessors.contain_span_tags.match(  # Span Mode
            tag["tag"]
        )
        and markdown_value != "block"
    ) or markdown_value == "span":
        element.text = "\n".join(block)
    else:  # Block Mode
        i = self.parser.blockprocessors.tag_counter + 1
        if len(self._tag_data) > i and self._tag_data[i]["left_index"]:
            first_subelement_index = self._tag_data[i]["left_index"] - 1
            self.parser.parseBlocks(element, block[:first_subelement_index])
            if not nest:
                block = self._process_nests(element, block)
        else:
            self.parser.parseBlocks(element, block)


# Traceback (IndexError)
Traceback (most recent call last):
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/test_tools.py", line 117, in test
output = markdown(input, **kwargs)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 391, in markdown
return md.convert(text)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/core.py", line 268, in convert
root = self.parser.parseDocument(self.lines).getroot()
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 92, in parseDocument
self.parseChunk(self.root, '\n'.join(lines))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 107, in parseChunk
self.parseBlocks(parent, text.split('\n\n'))
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/blockparser.py", line 125, in parseBlocks
if processor.run(parent, blocks) is not False:
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 127, in run
block = self._process_nests(element, block)
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 95, in _process_nests
block[nest_index[-1][1]:], True)                      # nest
File "/home/ikus060/workspace/PDSL/markdown.git/markdown/extensions/extra.py", line 101, in run
tag = self._tag_data[self.parser.blockprocessors.tag_counter]
IndexError: list index out of range

# Fixed code
def run(self, parent, blocks):
    m = util.HTML_PLACEHOLDER_RE.match(blocks[0])
    if m:
        index = int(m.group(1))
        element = self.parser.md.htmlStash.rawHtmlBlocks[index]
        if isinstance(element, etree.Element):
            # We have a matched element. Process it.
            blocks.pop(0)
            self.parse_element_content(element)
            parent.append(element)
            # Cleanup stash. Replace element with empty string to avoid confusing postprocessor.
            self.parser.md.htmlStash.rawHtmlBlocks.pop(index)
            self.parser.md.htmlStash.rawHtmlBlocks.insert(index, "")
            # Comfirm the match to the blockparser.
            return True
    # No match found.
    return False