Skip to content

Commit

Permalink
Merge pull request #1101 from josh-gree/master
Browse files Browse the repository at this point in the history
Fix for #1100
  • Loading branch information
greenape committed Aug 7, 2023
2 parents 026a5b2 + 12993ea commit 408e3fd
Show file tree
Hide file tree
Showing 10 changed files with 2,846 additions and 2,142 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


### Fixed
- Fixed import error with MkdDocs > 1.5.0. [#1000](https://github.com/greenape/mknotebooks/issues/100). (Thanks to [@josh-gree](https://github.com/josh-gree))


### Removed
Expand Down
1,240 changes: 707 additions & 533 deletions examples/binder_logo/Pipfile.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions examples/binder_logo/docs/docs_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"import pandas as pd\n",
"import numpy as np\n",
"import datetime\n",
"\n",
"%matplotlib inline"
]
},
Expand Down Expand Up @@ -80,8 +81,8 @@
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame({\"time\":np.arange(0, 10, 0.1)})\n",
"df[\"amplitude\"] = np.sin(df.time)"
"df = pd.DataFrame({\"time\": np.arange(0, 10, 0.1)})\n",
"df[\"amplitude\"] = np.sin(df.time)"
]
},
{
Expand Down
1,239 changes: 707 additions & 532 deletions examples/cell_tag_remove/Pipfile.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions examples/cell_tag_remove/docs/docs_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"import pandas as pd\n",
"import numpy as np\n",
"import datetime\n",
"\n",
"%matplotlib inline"
]
},
Expand Down Expand Up @@ -87,8 +88,8 @@
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame({\"time\":np.arange(0, 10, 0.1)})\n",
"df[\"amplitude\"] = np.sin(df.time)"
"df = pd.DataFrame({\"time\": np.arange(0, 10, 0.1)})\n",
"df[\"amplitude\"] = np.sin(df.time)"
]
},
{
Expand Down
1,240 changes: 707 additions & 533 deletions examples/execute_with_preamble/Pipfile.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions examples/execute_with_preamble/docs/docs_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"import pandas as pd\n",
"import numpy as np\n",
"import datetime\n",
"\n",
"%matplotlib inline"
]
},
Expand Down Expand Up @@ -80,8 +81,8 @@
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame({\"time\":np.arange(0, 10, 0.1)})\n",
"df[\"amplitude\"] = np.sin(df.time)"
"df = pd.DataFrame({\"time\": np.arange(0, 10, 0.1)})\n",
"df[\"amplitude\"] = np.sin(df.time)"
]
},
{
Expand Down
1,240 changes: 707 additions & 533 deletions examples/no_code/Pipfile.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions examples/no_code/docs/docs_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"import pandas as pd\n",
"import numpy as np\n",
"import datetime\n",
"\n",
"%matplotlib inline"
]
},
Expand Down Expand Up @@ -80,8 +81,8 @@
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame({\"time\":np.arange(0, 10, 0.1)})\n",
"df[\"amplitude\"] = np.sin(df.time)"
"df = pd.DataFrame({\"time\": np.arange(0, 10, 0.1)})\n",
"df[\"amplitude\"] = np.sin(df.time)"
]
},
{
Expand Down
8 changes: 5 additions & 3 deletions mknotebooks/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import git
from mkdocs.config.base import Config as MkDocsConfig
from mkdocs.structure.files import File, Files
from mkdocs.structure.pages import Page, _RelativePathExtension
from mkdocs.structure.pages import Page, _RelativePathTreeprocessor
from mkdocs.structure.toc import get_toc
from nbconvert import HTMLExporter, MarkdownExporter
from traitlets.config import Config
Expand All @@ -34,7 +34,6 @@


def get_git_root(path):

git_repo = git.Repo(path, search_parent_directories=True)
git_root = git_repo.git.rev_parse("--show-toplevel")
return git_root
Expand Down Expand Up @@ -295,12 +294,15 @@ def on_page_content(
):
log.debug(f"Re-rendering page with markdown in divs: {page}")
extensions = [
_RelativePathExtension(page.file, files),
"markdown.extensions.md_in_html",
] + config["markdown_extensions"]
md = markdown.Markdown(
extensions=extensions, extension_configs=config["mdx_configs"] or {}
)

relative_path_ext = _RelativePathTreeprocessor(page.file, files, config)
relative_path_ext._register(md)

html = md.convert(page.markdown)
page.toc = get_toc(getattr(md, "toc_tokens", []))

Expand Down

0 comments on commit 408e3fd

Please sign in to comment.