'Replace marker with elem.'

def replace_marker(self, root, elem):

    for (p, c) in self.iterparent(root):
        text = u''.join(c.itertext()).strip()
        if (not text):
            continue
        if (c.text and (c.text.strip() == self.marker) and (not self.header_rgx.match(c.tag)) and (c.tag not in [u'pre', u'code'])):
            for i in range(len(p)):
                if (p[i] == c):
                    p[i] = elem
                    break
