コード例 #1
0
ファイル: plugin.py プロジェクト: bollwyvl/pytest-check-links
 def _html_from_markdown(self):
     """Return HTML from a markdown file"""
     # FIXME: use commonmark or a pluggable engine
     from nbconvert.filters import markdown2html
     with io.open(str(self.fspath), encoding=_ENC) as f:
         markdown = f.read()
     return markdown2html(markdown)
コード例 #2
0
ファイル: plugin.py プロジェクト: bollwyvl/pytest-check-links
    def _items_from_notebook(self):
        """Yield LinkItems from a notebook"""
        import nbformat
        from nbconvert.filters import markdown2html

        nb = nbformat.read(str(self.fspath), as_version=4)
        for cell_num, cell in enumerate(nb.cells):
            if cell.cell_type != 'markdown':
                continue

            html = markdown2html(cell.source)
            basename = 'Cell %i' % cell_num
            for item in links_in_html(basename, self, html):
                yield item
コード例 #3
0
def markdown2html(lst):
    text = ''.join(lst)
    return filters.markdown2html(text)