Skip to content

Commit

Permalink
Avoid using an import from "mkdocs.tests." (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin authored Feb 2, 2024
1 parent 67eeec2 commit 0365433
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mkdocs_jupyter/plugin.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import os
import pathlib

import markdown
import mkdocs
from mkdocs.config import config_options
from mkdocs.structure.files import File, Files
from mkdocs.structure.pages import Page
from mkdocs.structure.toc import get_toc
from mkdocs.tests.base import get_markdown_toc

from . import convert

Expand Down Expand Up @@ -150,12 +150,18 @@ def on_post_page(self, output_content, page, config):
copyfile(nb_source, nb_target)


def _get_markdown_toc(markdown_source):
md = markdown.Markdown(extensions=["toc"])
md.convert(markdown_source)
return md.toc_tokens


def get_nb_toc(fpath):
"""Returns a TOC for the Notebook
It does that by converting first to MD
"""
body = convert.nb2md(fpath)
md_toc_tokens = get_markdown_toc(body)
md_toc_tokens = _get_markdown_toc(body)
toc = get_toc(md_toc_tokens)
title = None
for token in md_toc_tokens:
Expand Down

0 comments on commit 0365433

Please sign in to comment.