Skip to content

Commit 1fc1df8

Browse files
author
neatc0der
committed
Merges
2 parents ac200cb + 7d490da commit 1fc1df8

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,33 @@ extra_javascript:
8888
8989
:warning: The urls need to contain one of these keywords to be considered as deviation from default:
9090
91-
* `d3`
91+
* `markmap-d3`
9292
* `markmap-lib`
9393
* `markmap-view`
9494
95-
9695
## Troubleshooting
9796
9897
### Nav tree lists markmaps
9998
10099
1. Move your markmap files to a separate folder next to `docs`, e.g. `mindmaps`
101100
2. Configure `base_path` accordingly (see [Advanced Settings](#advanced-settings))
102101
102+
### Static javascript files not working
103+
104+
1. Ensure naming of javascript files matches the scheme (see [Advanced Settings](#advanced-settings))
105+
2. Copy all javascript files to `doc/js/`, otherwise `mkdocs` will not copy static files to `site/`
106+
3. Define all files in `extra_javascript`, e.g.
107+
108+
```yaml
109+
extra_javascript:
110+
- js/markmap-d3.js
111+
- js/markmap-lib.js
112+
- js/markmap-view.js
113+
```
114+
115+
### Usage of proxy is prevent download of javascript files
116+
117+
Usually proxies should be supported by `requests`, which is used for downloading all required javascript files. If the issue remains, try downloading the files yourself and store them accordingly (see [Static javascript files not working](#static-javascript-files-not-working))
103118
104119
## Credits :clap:
105120

changelog/v2.2.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# v2.2.1
2+
3+
* Fixes [static javascript files bug](https://github.com/neatc0der/mkdocs-markmap/issues/35)

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: str = 'mkdocs_markmap'
22
PROJECT_NAME: str = PACKAGE_NAME.replace('_', '-')
3-
PROJECT_VERSION: str = '2.2.0'
3+
PROJECT_VERSION: str = '2.2.1'
44

55
OWNER: str = 'neatc0der'
66
REPOSITORY_NAME: str = 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)