Skip to content

Commit 85f06ad

Browse files
authored
Merge pull request #55 from markmap/v2.4.2
V2.4.2
2 parents 35e4776 + 2921de6 commit 85f06ad

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

changelog/v2.4.2.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# v2.4.2
2+
3+
* Relaxes dependency to `attrs` (see [#47](https://github.com/markmap/mkdocs-markmap/issues/47))
4+
* Fix for rendering in SPA (see [#42](https://github.com/markmap/mkdocs-markmap/issues/42))

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.4.1"
3+
PROJECT_VERSION: str = "2.4.2"
44

55
OWNER: str = "neatc0der"
66
ORGANISATION: str = "markmap"

mkdocs_markmap/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def on_page_content(self, html: str, page: Page, **kwargs) -> str:
127127
code = markmap
128128
pre.name = "div"
129129
pre["class"] = pre.get("class", []) + ["mkdocs-markmap"]
130-
code.name = "script"
131-
code["type"] = "text/template"
130+
code.name = "markmap-data"
131+
code.attrs["hidden"] = "true"
132132

133133
return str(soup)

mkdocs_markmap/static_files/mkdocs-markmap.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,25 @@
3838
});
3939
}
4040

41-
function updateMarkmaps() {
42-
const markmaps = document.getElementsByClassName('mkdocs-markmap');
43-
for (var i = 0; i < markmaps.length; i++) {
44-
const el = markmaps[i];
41+
function updateMarkmaps(node) {
42+
for (const el of node.querySelectorAll('.mkdocs-markmap')) {
4543
renderMarkmap(el);
4644
}
4745
}
4846

4947
loading.then(() => {
50-
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
51-
var observer = new MutationObserver(function(mutations) {
52-
updateMarkmaps();
48+
const observer = new MutationObserver((mutationList) => {
49+
for (const mutation of mutationList) {
50+
if (mutation.type === 'childList') {
51+
for (const node of mutation.addedNodes) {
52+
updateMarkmaps(node);
53+
}
54+
}
55+
}
5356
});
5457

55-
var target = document.getElementById('mkdocs-decrypted-content');
56-
if (undefined != target) {
57-
observer.observe(target, { childList: true });
58-
}
58+
observer.observe(document.body, { childList: true });
5959

60-
updateMarkmaps();
60+
updateMarkmaps(document);
6161
});
6262
})();

requirements/prod.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mkdocs>=1.3,<2
2-
attrs==20.3.0
2+
attrs>=20.3.0
33
beautifulsoup4>=4.6.3
44
requests<3
55

0 commit comments

Comments
 (0)