Skip to content

Commit

Permalink
Fix race condition bug where highlighter engine is not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
themkat committed Sep 13, 2024
1 parent 95929a8 commit 609af16
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/styles/sunburst.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js" async></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/languages/lisp.min.js" async integrity="sha512-/opdFSi4yauKgOKsTeN7MPbPp2QnhX2y7WvaS682VYwmtSsTwM1qsePlN1Vn+iTWL3PvXI5vtFQFPLNrPphBJA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/languages/lisp.min.js" integrity="sha512-/opdFSi4yauKgOKsTeN7MPbPp2QnhX2y7WvaS682VYwmtSsTwM1qsePlN1Vn+iTWL3PvXI5vtFQFPLNrPphBJA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
{% endif %}

<!-- Global site tag (gtag.js) - Google Analytics -->
Expand Down Expand Up @@ -156,15 +156,17 @@
</div>
</div>

{% if page.path contains '_posts' %}
<script>
// Highlight Org mode exported source code blocks if any
document.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll('pre.src').forEach((block) => {
// hack to get hljs to cooperate with my org mode settings
block.className = block.className.replace('src-', 'language-');
hljs.highlightElement(block);
});
});
// Highlight Org mode exported source code blocks if any
document.addEventListener('DOMContentLoaded', (event) => {
document.querySelectorAll('pre.src').forEach((block) => {
// hack to get hljs to cooperate with my org mode settings
block.className = block.className.replace('src-', 'language-');
hljs.highlightElement(block);
});
});
{% endif %}

// hamburger menu helper for mobile phones
function toggleHamburgerMenu() {
Expand Down

0 comments on commit 609af16

Please sign in to comment.