convert Markdown text as html. return the html file as string

def build(self):
        """convert Markdown text as html. return the html file as string"""
        markdown_html = markdown.markdown(self.markdown_text, extensions=[
                TocExtension(), 'fenced_code', 'markdown_checklist.extension',
                'markdown.extensions.tables'])
        markdown_soup = BeautifulSoup(markdown_html, 'html.parser')

        # include jquery & mermaid.js only if there are Mermaid graph
        if markdown_soup.find('code', attrs={'class': 'mermaid'}):
            self._add_mermaid_js()

        # search in markdown html if there are Dot Graph & replace it with .svg result
        for dot_tag in markdown_soup.find_all('code', attrs={'class': 'dotgraph'}):
            grap_svg = self._text_to_graphiz(dot_tag.string)
            graph_soup = BeautifulSoup(grap_svg, 'html.parser')
            dot_tag.parent.replaceWith(graph_soup)

        self.main_soup.body.append(markdown_soup)
        return self.main_soup.prettify()