Skip to content

Commit

Permalink
Find anchor more robustly
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 30, 2024
1 parent 84b98ee commit e1bcb03
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function generate() {
}
var toc = [];
for (let heading of headings) {
let anchor = heading.querySelector('a[href]');
let anchor = heading.querySelector('a[href]') || heading.parentNode.querySelector('a.anchor[href]');
if (!anchor)
throw new Error(`Could not find out anchor for a heading: ${heading.textContent}`);
let href = anchor.getAttribute('href');
let indent = '';
let headingLevel = parseInt(heading.localName.charAt(1));
Expand Down

0 comments on commit e1bcb03

Please sign in to comment.