;
    currentSectionList.appendChild(listItem);
  }
    
  function buildToc() {
    const tocElement = document.querySelector(`#${tocId}`);
    const main = document.querySelector("main");
    headings = main.querySelectorAll("h2, h3, h4, h5, h6");
    let previousHeading;
    let currentSectionList = document.createElement("ul");
    tocElement.appendChild(currentSectionList);
    
    headings.forEach((heading, index) => {
      currentSectionList = getTocList(
        heading,
        previousHeading,
 