Skip to content

Commit 98300f6

Browse files
author
neatc0der
committed
#35: Restores static javascript support
1 parent f6bfc8f commit 98300f6

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

mkdocs_markmap/__meta__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PACKAGE_NAME = 'mkdocs_markmap'
22
PROJECT_NAME = PACKAGE_NAME.replace('_', '-')
3-
PROJECT_VERSION = '2.2.0'
3+
PROJECT_VERSION = '2.2.1'
44

55
OWNER = 'neatc0der'
66
REPOSITORY_NAME = f'{OWNER}/{PROJECT_NAME}'

mkdocs_markmap/plugin.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from bs4 import BeautifulSoup, ResultSet, Tag
88
from mkdocs.plugins import BasePlugin
99
from mkdocs.structure.pages import Page
10-
from mkdocs.config.base import Config
10+
from mkdocs.config.base import Config, load_config
1111
from mkdocs.config.config_options import Type as PluginType
1212

1313
from .defaults import MARKMAP
@@ -21,6 +21,7 @@
2121
STYLE_PATH: Path = STATICS_PATH / 'mkdocs-markmap.css'
2222
SCRIPT_PATH: Path = STATICS_PATH / 'mkdocs-markmap.js'
2323

24+
2425
class MarkmapPlugin(BasePlugin):
2526
"""
2627
Plugin for markmap support
@@ -59,10 +60,15 @@ def markmap(self) -> Dict[str, str]:
5960

6061
def _load_scripts(self, soup: BeautifulSoup, script_base_url: str, js_path: Path) -> None:
6162
for script_url in self.markmap.values():
62-
try:
63-
src: str = script_base_url + download(js_path, script_url)
64-
except Exception as e:
65-
log.error(f'unable to download script: {script_url}')
63+
if script_url.lower().startswith("http"):
64+
try:
65+
src: str = script_base_url + download(js_path, script_url)
66+
except Exception as e:
67+
log.error(f'unable to download script: {script_url}')
68+
src = script_url
69+
70+
else:
71+
log.info(f"static script detected: {script_url}")
6672
src = script_url
6773

6874
script: Tag = soup.new_tag('script', src=src, type='text/javascript')
@@ -88,6 +94,7 @@ def on_config(self, config: Config) -> Config:
8894
for key, value in config['plugins'].get('markmap').config.items()
8995
if key in MarkmapExtension.config_defaults
9096
}
97+
self.config['extra_javascript'] = config.get('extra_javascript', [])
9198

9299
return config
93100

0 commit comments

Comments
 (0)