def replace_marker(self, root, elem):
        ''' Replace marker with elem. '''
        for (p, c) in self.iterparent(root):
            text = ''.join(c.itertext()).strip()
            if not text:
                continue

            # To keep the output from screwing up the
            # validation by putting a <div> inside of a <p>
            # we actually replace the <p> in its entirety.
            # We do not allow the marker inside a header as that
            # would causes an enless loop of placing a new TOC
            # inside previously generated TOC.
            if c.text and c.text.strip() == self.marker and \
               not self.header_rgx.match(c.tag) and ['pre', 'code'] not in c.tag:
                for i in range(len(p)):
                    if p[i] == c:
                        p[i] = elem
                        break
dataset/ETHPy150Open dragondjf/QMarkdowner/markdown/extensions/toc.py/TocTreeprocessor.replace_marker/swapped operands of `not in`