mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-03-20 12:52:34 +00:00
Support mermaid inside backtick code block
* See: https://github.com/next-theme/hexo-theme-next/issues/347
This commit is contained in:
parent
358a3c080d
commit
a396c61a0a
9
source/js/third-party/tags/mermaid.js
vendored
9
source/js/third-party/tags/mermaid.js
vendored
@ -10,7 +10,14 @@ document.addEventListener('page:loaded', () => {
|
|||||||
const newElement = document.createElement('div');
|
const newElement = document.createElement('div');
|
||||||
newElement.innerHTML = element.innerHTML;
|
newElement.innerHTML = element.innerHTML;
|
||||||
newElement.className = element.className;
|
newElement.className = element.className;
|
||||||
element.parentNode.replaceChild(newElement, element);
|
const parent = element.parentNode;
|
||||||
|
// Fix issue #347
|
||||||
|
// Support mermaid inside backtick code block
|
||||||
|
if (parent.matches('pre')) {
|
||||||
|
parent.parentNode.replaceChild(newElement, parent);
|
||||||
|
} else {
|
||||||
|
parent.replaceChild(newElement, element);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
theme : CONFIG.darkmode && window.matchMedia('(prefers-color-scheme: dark)').matches ? CONFIG.mermaid.theme.dark : CONFIG.mermaid.theme.light,
|
theme : CONFIG.darkmode && window.matchMedia('(prefers-color-scheme: dark)').matches ? CONFIG.mermaid.theme.dark : CONFIG.mermaid.theme.light,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user