Skip to content

How to reference the text below a heading? #2576

Answered by avinal
avinal asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks Tony, I did something that feels almost illegal to do. I observed that if I don't provide closing tags, then somehow the necessary closing tags are automatically added. I know for sure that nothing else can appear between the two sections. So I wrote logic to add closing tags in between sections and left the last one to be auto-completed. Here is my code:

var numberOfHeadings = 0;
renderer.heading = (text, level) => {
  if (level === 1) {
    return `<h${level}>${text}</h${level}>`;
  }
  const escapedText = text
    .trim()
    .toLowerCase()
    .replace(/[^\w]+/g, "-");
  const endSection = `</div></section>`;
  const sectionContent = `
<section aria-labelledby="${escapedText}">
<h

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@UziTech
Comment options

@avinal
Comment options

Answer selected by avinal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants