Skip to content

Commit 817efa5

Browse files
authored
Update plugin.py
Support for urls with files instead of directories
1 parent 3717ee8 commit 817efa5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mkdocs_markmap/plugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,12 @@ def on_config(self, config: Config) -> Config:
9797

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

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

0 commit comments

Comments
 (0)