1 document
.addEventListener('DOMContentLoaded', function () {
2 // If section divs is used, we need to put the anchor in the child header
3 const headers
= document
.querySelectorAll("div.hasAnchor.section[class*='level'] > :first-child")
5 headers
.forEach(function (x
) {
6 // Add to the header node
7 if (!x
.classList
.contains('hasAnchor')) x
.classList
.add('hasAnchor')
8 // Remove from the section or div created by Pandoc
9 x
.parentElement
.classList
.remove('hasAnchor')