Skip to content

Commit

Permalink
doc: throw if id/href in marks do not match
Browse files Browse the repository at this point in the history
  • Loading branch information
foxxyz committed Jul 19, 2021
1 parent c266ec4 commit af39af5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/doc/allhtml.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ for (const link of toc.match(/<a.*?>/g)) {
apicontent += '<section>' + data.slice(match.index + match[0].length)
.replace(/<!-- API END -->[\s\S]*/, '</section>')
// Prefix all in-page anchor marks with module name
.replace(/<a class="mark" href="#([^"]+)" id="([^"]+)"/g, (match, anchor) => {
.replace(/<a class="mark" href="#([^"]+)" id="([^"]+)"/g, (match, anchor, id) => {
if (anchor !== id) throw new Error(`Mark does not match: ${anchor} should match ${id}`);
return `<a class="mark" href="#${moduleName}_${anchor}" id="${moduleName}_${anchor}"`;
})
// Prefix all in-page links with current module name
Expand Down

0 comments on commit af39af5

Please sign in to comment.