Skip to content

Commit

Permalink
Merge pull request #53 from markmap/neatc0der-patch-1
Browse files Browse the repository at this point in the history
Update plugin.py
  • Loading branch information
neatc0der authored Sep 6, 2023
2 parents 3717ee8 + acea1c4 commit 35e4776
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog/v2.4.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# v2.4.1

* Support urls with files as well as directories
2 changes: 1 addition & 1 deletion mkdocs_markmap/__meta__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PACKAGE_NAME: str = "mkdocs_markmap"
PROJECT_NAME: str = PACKAGE_NAME.replace("_", "-")
PROJECT_VERSION: str = "2.4.0"
PROJECT_VERSION: str = "2.4.1"

OWNER: str = "neatc0der"
ORGANISATION: str = "markmap"
Expand Down
2 changes: 1 addition & 1 deletion mkdocs_markmap/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def extendMarkdown(self, md: Markdown) -> None:
md.preprocessors.register(MarkmapPreprocessor(md, self.getConfigs()), "include_markmap", 102)
for extension in md.registeredExtensions:
if extension.__class__.__name__ == "SuperFencesCodeExtension":
log.info(f"superfences detected by markmap")
log.debug(f"superfences detected by markmap")
try:
from pymdownx.superfences import default_validator, fence_code_format, _formatter, _validator
extension.extend_super_fences(
Expand Down
5 changes: 3 additions & 2 deletions mkdocs_markmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ def on_config(self, config: Config) -> Config:

def on_post_page(self, html: str, page: Page, config: Config, **kwargs) -> str:
if not getattr(page, "_found_markmap", False):
log.info(f"no markmap found: {page.file.name}")
log.debug(f"no markmap found: {page.file.name}")
return html

log.info(f"markmap found: {page.file.name}")
soup: BeautifulSoup = BeautifulSoup(html, "html.parser")
script_base_url: str = re.sub(r"[^/]+?/", "../", re.sub(r"/+?", "/", page.url)) + "js/"
script_base_url: str = re.sub(r"/[^/]*$", "/", re.sub(r"[^/]+?/", "../", re.sub(r"/+?", "/", page.url))) + "js/"
js_path: Path = Path(config["site_dir"]) / "js"
self._load_scripts(soup, script_base_url, js_path)
self._add_statics(soup)
Expand Down

0 comments on commit 35e4776

Please sign in to comment.