From 2533bde15ec3443bbbe207eadd91cebf9dd858ea Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Thu, 1 Feb 2024 00:41:14 +0100 Subject: [PATCH 1/2] Avoid using an import from "mkdocs.tests." "tests" will not be part of the package in the next releases --- src/mkdocs_jupyter/plugin.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/mkdocs_jupyter/plugin.py b/src/mkdocs_jupyter/plugin.py index a23d76b..46eb433 100644 --- a/src/mkdocs_jupyter/plugin.py +++ b/src/mkdocs_jupyter/plugin.py @@ -6,7 +6,6 @@ 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 @@ -150,12 +149,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: From f643619dc041a493c9cb5f0d7415d802cdce722d Mon Sep 17 00:00:00 2001 From: Oleh Prypin Date: Thu, 1 Feb 2024 08:29:52 +0100 Subject: [PATCH 2/2] Update plugin.py --- src/mkdocs_jupyter/plugin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mkdocs_jupyter/plugin.py b/src/mkdocs_jupyter/plugin.py index 46eb433..fb6fea8 100644 --- a/src/mkdocs_jupyter/plugin.py +++ b/src/mkdocs_jupyter/plugin.py @@ -1,6 +1,7 @@ import os import pathlib +import markdown import mkdocs from mkdocs.config import config_options from mkdocs.structure.files import File, Files