Skip to content

Commit

Permalink
Merge pull request #55 from markmap/v2.4.2
Browse files Browse the repository at this point in the history
V2.4.2
  • Loading branch information
neatc0der authored Oct 5, 2023
2 parents 35e4776 + 2921de6 commit 85f06ad
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
4 changes: 4 additions & 0 deletions changelog/v2.4.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# v2.4.2

* Relaxes dependency to `attrs` (see [#47](https://github.com/markmap/mkdocs-markmap/issues/47))
* Fix for rendering in SPA (see [#42](https://github.com/markmap/mkdocs-markmap/issues/42))
2 changes: 1 addition & 1 deletion mkdocs_markmap/__meta__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PACKAGE_NAME: str = "mkdocs_markmap"
PROJECT_NAME: str = PACKAGE_NAME.replace("_", "-")
PROJECT_VERSION: str = "2.4.1"
PROJECT_VERSION: str = "2.4.2"

OWNER: str = "neatc0der"
ORGANISATION: str = "markmap"
Expand Down
4 changes: 2 additions & 2 deletions mkdocs_markmap/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def on_page_content(self, html: str, page: Page, **kwargs) -> str:
code = markmap
pre.name = "div"
pre["class"] = pre.get("class", []) + ["mkdocs-markmap"]
code.name = "script"
code["type"] = "text/template"
code.name = "markmap-data"
code.attrs["hidden"] = "true"

return str(soup)
24 changes: 12 additions & 12 deletions mkdocs_markmap/static_files/mkdocs-markmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@
});
}

function updateMarkmaps() {
const markmaps = document.getElementsByClassName('mkdocs-markmap');
for (var i = 0; i < markmaps.length; i++) {
const el = markmaps[i];
function updateMarkmaps(node) {
for (const el of node.querySelectorAll('.mkdocs-markmap')) {
renderMarkmap(el);
}
}

loading.then(() => {
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations) {
updateMarkmaps();
const observer = new MutationObserver((mutationList) => {
for (const mutation of mutationList) {
if (mutation.type === 'childList') {
for (const node of mutation.addedNodes) {
updateMarkmaps(node);
}
}
}
});

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

updateMarkmaps();
updateMarkmaps(document);
});
})();
2 changes: 1 addition & 1 deletion requirements/prod.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mkdocs>=1.3,<2
attrs==20.3.0
attrs>=20.3.0
beautifulsoup4>=4.6.3
requests<3

0 comments on commit 85f06ad

Please sign in to comment.