def run(self, root):
        """Searches for <div class="math"> that are children in <p> tags and corrects
        the invalid HTML that results"""

        math_tag_class = self.pelican_mathjax_extension.getConfig('math_tag_class')

        for parent in root:
            div_math = []
            children = list(parent)

            for div in parent.findall('div'):
                if div.get('class') == math_tag_class:
                    div_math.append(children.index(div))

            # Do not process further if no displayed math has been found
            if not div_math:
                continue

            insert_idx = list(root).index(parent)
            self.correct_html(root, children, div_math, insert_idx, parent.text) 
            root.remove(parent)  # Parent must be removed last for correct insertion index

        return root
def run ( self , root ) : math_tag_class = self . pelican_mathjax_extension . getConfig ( 'math_tag_class' ) for parent in root : div_math = [ ] children = list ( parent ) for div in parent . findall ( 'div' ) : if div . get ( 'class' ) == math_tag_class : div_math . append ( children . index ( div ) ) if not div_math : continue insert_idx = list ( root ) . index ( parent ) self . correct_html ( root , children , div_math , insert_idx , parent . text ) root . remove ( parent ) return root
Searches for <div class="math"> that are children in <p> tags and corrects
        the invalid HTML that results