Skip to content

Commit

Permalink
Issue #75 - fix issue where new itables would break toc.
Browse files Browse the repository at this point in the history
  • Loading branch information
JanPalasek committed Feb 23, 2024
1 parent 85c6214 commit 694ecbd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pretty-jupyter"
authors = [{name = "Jan Palasek"}]
description = "Exports Jupyter notebook into beautiful and dynamic HTML report."
license = {file = "LICENSE.md"}
version = "2.0.5"
version = "2.0.6"
readme = "README.md"
dependencies = [
"click",
Expand Down
7 changes: 0 additions & 7 deletions src/pretty_jupyter/templates/pj/index.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@

{# js files for notebooks: extend this to provide custom javascript #}
{% block notebook_js %}
<!-- hotfix to support interactive tables package -->
<script type="text/javascript">
if ($(".output_subarea.output_javascript").length > 0) {
jQuery.noConflict(false);
}
</script>

{{ resources.include_js("static/pj.js") }}

<script type="text/javascript">
Expand Down
14 changes: 12 additions & 2 deletions src/pretty_jupyter/templates/pj/static/pj.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,18 @@ window.initializeTOC = function (tocDepth, tocCollapsed, tocSmoothScroll, tocExt

options.smoothScroll = tocSmoothScroll;

// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
// invoke tocify.. if it fails with an error, solve jquery and run again
for (let i = 0; i < 5; i++) {
try {
// invoke tocify, if successful, break
$("#TOC").tocify(options).data("toc-tocify");
break;
}
catch {
// if tocify fails, try again
jQuery.noConflict(false);
}
}

if (!tocCollapsed) {
toc.setOptions({ "showAndHideOnScroll": false, "showAndHide": false });
Expand Down

0 comments on commit 694ecbd

Please sign in to comment.