Skip to content

Commit

Permalink
tools: udpate doc tools to accommodate GFM footnotes
Browse files Browse the repository at this point in the history
PR-URL: #40477
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
Trott authored and targos committed Nov 6, 2021
1 parent 9f46fca commit 507f1db
Show file tree
Hide file tree
Showing 3 changed files with 426 additions and 166 deletions.
8 changes: 8 additions & 0 deletions tools/doc/allhtml.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ for (const link of toc.match(/<a.*?>/g)) {
.replace(/<a href="#(?!DEP[0-9]{4})([^"]+)"/g, (match, anchor) => {
return `<a href="#${moduleName}_${anchor}"`;
})
// Update footnote id attributes on anchors
.replace(/<a href="([^"]+)" id="(user-content-fn[^"]+)"/g, (match, href, id) => {
return `<a href="${href}" id="${moduleName}_${id}"`;
})
// Update footnote id attributes on list items
.replace(/<(\S+) id="(user-content-fn-\d+)"/g, (match, tagName, id) => {
return `<${tagName} id="${moduleName}_${id}"`;
})
// Prefix all links to other docs modules with those module names
.replace(/<a href="((\w[^#"]*)\.html)#/g, (match, href, linkModule) => {
if (!htmlFiles.includes(href)) return match;
Expand Down
Loading

0 comments on commit 507f1db

Please sign in to comment.