g, currentSectionList) {
    let listItem = document.createElement("li");
    let anchor = document.createElement("a");
    anchor.innerHTML = heading.innerHTML;
    anchor.id = `${heading.id}-link`;
    anchor.href = `#${heading.id}`;
    listItem.appendChild(anchor);
    currentSectionList.appendChild(listItem);
  }
    
  function buildToc() {
    const tocElement = document.querySelector(`#${tocId}`);
    const main = document.querySelector("main");
    headings = main.querySelectorAll("h2, h3, h4, h5, 