Skip to content

Commit

Permalink
add logic to handle rendering of mermaid diagrams in tabs
Browse files Browse the repository at this point in the history
Signed-off-by: cosmicBboy <[email protected]>
  • Loading branch information
cosmicBboy committed Jun 23, 2021
1 parent b417207 commit 696cb9f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions src/furo/assets/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,24 @@ function main() {
}

document.addEventListener("DOMContentLoaded", main);


// Logic for handling the rendering of mermaid diagrams.
function renderMermaid() {
jQuery(".mermaid").each(function(i, el) {
if (jQuery(el).parent()[0].getAttribute("hidden") === 'true') {
// don't render mermaid charts whose parent node is hidden
} else {
mermaid.init(jQuery(el));
}
});
}

jQuery(function() {
renderMermaid()

// listen for clicks on tab buttons
jQuery("button.sphinx-tabs-tab").on("click", function() {
renderMermaid();
});
})
2 changes: 1 addition & 1 deletion src/furo/theme/furo/static/scripts/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 696cb9f

Please sign in to comment.