Skip to content

Commit f6bfc8f

Browse files
authored
Merge pull request #32 from neatc0der/release/v2.2.0
Release/v2.2.0
2 parents dff5d6a + d11fd64 commit f6bfc8f

File tree

10 files changed

+63
-32
lines changed

10 files changed

+63
-32
lines changed

.github/workflows/distribute.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Prepare Python
1717
uses: actions/setup-python@v2
1818
with:
19-
python-version: 3.8
19+
python-version: 3.9
2020

2121
- name: Install Dependencies
2222
run: |
@@ -28,4 +28,4 @@ jobs:
2828
env:
2929
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3030
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}
31-
run: inv distribute --tag ${GITHUB_REF#refs/*/} --no-dry-run
31+
run: inv distribute --tag v$(python setup.py --version 2> /dev/null) --no-dry-run

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Prepare Python
1717
uses: actions/setup-python@v2
1818
with:
19-
python-version: 3.8
19+
python-version: 3.9
2020

2121
- name: Install Dependencies
2222
run: |

.github/workflows/verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Prepare Python
1717
uses: actions/setup-python@v2
1818
with:
19-
python-version: 3.8
19+
python-version: 3.9
2020

2121
- name: Install Dependencies
2222
run: |

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This is a plugin and an extension for [mkdocs](https://github.com/mkdocs/mkdocs/
1414

1515
This plugin was tested with, but is not limited to:
1616

17-
* Python 3.8
17+
* Python 3.9
1818
* mkdocs 1.1
1919

2020
## Quickstart
@@ -73,7 +73,7 @@ plugins:
7373
encoding: utf-8
7474
file_extension: .mm.md
7575
d3_version: 6.7.0
76-
lib_version: 0.11.5
76+
lib_version: 0.11.6
7777
view_version: 0.2.6
7878
```
7979
@@ -82,7 +82,7 @@ In addition, feel free to define your favourite source urls like this:
8282
```yaml
8383
extra_javascript:
8484
- https://unpkg.com/[email protected]/dist/d3.min.js
85-
- https://unpkg.com/[email protected].5/dist/browser/index.min.js
85+
- https://unpkg.com/[email protected].6/dist/browser/index.min.js
8686
- https://unpkg.com/[email protected]/dist/index.min.js
8787
```
8888
@@ -92,6 +92,15 @@ extra_javascript:
9292
* `markmap-lib`
9393
* `markmap-view`
9494
95+
96+
## Troubleshooting
97+
98+
### Nav tree lists markmaps
99+
100+
1. Move your markmap files to a separate folder next to `docs`, e.g. `mindmaps`
101+
2. Configure `base_path` accordingly (see [Advanced Settings](#advanced-settings))
102+
103+
95104
## Credits :clap:
96105
97106
Some of the development approaches are based on implementations provided by the following projects:

changelog/v2.2.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# v2.2.0
2+
3+
* Adds [support for mkdocs-encryptcontent-plugin](https://github.com/neatc0der/mkdocs-markmap/issues/26)
4+
* Adds troubleshooting for [nav tree lists markmap files](https://github.com/neatc0der/mkdocs-markmap/issues/33)
5+
* Fixes distribute workflow

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.1.3'
3+
PROJECT_VERSION = '2.2.0'
44

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

mkdocs_markmap/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class JsModuleConfig(object):
1414
)
1515

1616
MARKMAP_LIB: JsModuleConfig = JsModuleConfig(
17-
version='0.11.5',
17+
version='0.11.6',
1818
uri='https://unpkg.com/markmap-lib@{}/dist/browser/index.min.js',
1919
)
2020

mkdocs_markmap/plugin.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,24 @@ def on_config(self, config: Config) -> Config:
9191

9292
return config
9393

94-
def on_post_page(self, output_content: str, config: Config, **kwargs) -> str:
95-
soup: BeautifulSoup = BeautifulSoup(output_content, 'html.parser')
96-
page: Page = kwargs.get('page')
97-
98-
markmaps: ResultSet = soup.find_all(class_='language-markmap')
99-
if not any(markmaps):
94+
def on_post_page(self, html: str, page: Page, config: Config, **kwargs) -> str:
95+
if not getattr(page, '_found_markmap', False):
10096
log.info(f"no markmap found: {page.file.name}")
101-
return output_content
97+
return html
10298

99+
soup: BeautifulSoup = BeautifulSoup(html, 'html.parser')
103100
script_base_url: str = re.sub(r'[^/]+?/', '../', re.sub(r'/+?', '/', page.url)) + 'js/'
104101
js_path: Path = Path(config['site_dir']) / 'js'
105102
self._load_scripts(soup, script_base_url, js_path)
106103
self._add_statics(soup)
107104

105+
return str(soup)
106+
107+
def on_page_content(self, html: str, page: Page, **kwargs) -> str:
108+
soup: BeautifulSoup = BeautifulSoup(html, 'html.parser')
109+
markmaps: ResultSet = soup.find_all(class_='language-markmap')
110+
setattr(page, '_found_markmap', any(markmaps))
111+
108112
for index, markmap in enumerate(markmaps):
109113
markmap: Tag
110114
tag_id: str = f'markmap-{index}'
Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
(function initializeMarkmap() {
2-
const markmap_transformer = new markmap.Transformer();
3-
const markmaps = document.getElementsByClassName('mkdocs-markmap');
4-
var el, content, svg, root, m;
5-
for (var i = 0; i < markmaps.length; i++) {
6-
el = markmaps[i];
7-
content = el.getAttribute('data-markdown').replaceAll('&#10;', '\n');
8-
svg = el.querySelector('svg');
9-
root = markmap_transformer.transform(content).root;
10-
m = markmap.Markmap.create(svg, null, root);
2+
function update_markmaps() {
3+
const markmap_transformer = new markmap.Transformer();
4+
const markmaps = document.getElementsByClassName('mkdocs-markmap');
5+
var el, content, svg, root, m;
6+
for (var i = 0; i < markmaps.length; i++) {
7+
el = markmaps[i];
8+
content = el.getAttribute('data-markdown').replaceAll('&#10;', '\n');
9+
svg = el.querySelector('svg');
10+
root = markmap_transformer.transform(content).root;
11+
m = markmap.Markmap.create(svg, null, root);
1112

12-
(function(obj, e, r) {
13-
obj.rescale(1).then(function() {
14-
e.parentElement.style.height = (e.getBBox().height + 10) + "px";
15-
requestAnimationFrame(() => { obj.fit(); })
16-
});
17-
})(m, svg, root);
13+
(function(obj, e, r) {
14+
obj.rescale(1).then(function() {
15+
e.parentElement.style.height = (e.getBBox().height + 10) + "px";
16+
requestAnimationFrame(() => { obj.fit(); })
17+
});
18+
})(m, svg, root);
19+
}
1820
}
21+
22+
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
23+
var observer = new MutationObserver(function(mutations) {
24+
update_markmaps();
25+
});
26+
27+
var target = document.getElementById('mkdocs-decrypted-content');
28+
if (undefined != target) {
29+
observer.observe(target, { childList: true });
30+
}
31+
32+
update_markmaps();
1933
})();

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ def get_requirements(filename: str, base_dir: str = 'requirements') -> List[str]
3636
license='MIT',
3737
python_requires='>=3.6',
3838
install_requires=get_requirements('prod.txt'),
39-
setup_requirements=get_requirements('build.txt'),
4039
classifiers=[
4140
'Development Status :: 5 - Production/Stable',
4241
'Intended Audience :: Developers',

0 commit comments

Comments
 (0)