Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using an import from "mkdocs.tests." #184

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading