Insert the PosMapExtension blockprocessor before any other
            extensions to make sure our own markers, inserted by the
            preprocessor, are removed before any other extensions get confused
            by them.

def extendMarkdown(self, md):
        """ Insert the PosMapExtension blockprocessor before any other
            extensions to make sure our own markers, inserted by the
            preprocessor, are removed before any other extensions get confused
            by them.
        """
        md.preprocessors.register(PosMapMarkPreprocessor(md), 'posmap_mark', 50)
        md.preprocessors.register(PosMapCleanPreprocessor(md), 'posmap_clean', 5)
        md.parser.blockprocessors.register(PosMapBlockProcessor(md.parser), 'posmap', 150)

        # Monkey patch CodeHilite constructor to remove the posmap markers from
        # text before highlighting it
        orig_codehilite_init = CodeHilite.__init__

        def new_codehilite_init(self, src=None, *args, **kwargs):
            src = POSMAP_MARKER_RE.sub('', src)
            orig_codehilite_init(self, src=src, *args, **kwargs)
        CodeHilite.__init__ = new_codehilite_init

        # Same for PyMdown Extensions if it is available
        if Highlight is not None:
            orig_highlight_highlight = Highlight.highlight

            def new_highlight_highlight(self, src, *args, **kwargs):
                src = POSMAP_MARKER_RE.sub('', src)
                return orig_highlight_highlight(self, src, *args, **kwargs)
            Highlight.highlight = new_highlight_highlight