| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b0c9b1f commit 8099bfb
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,10 +55,7 @@ <h1>Node.js __VERSION__ Documentation</h1> | |||
| 55 | 55 | <hr> | |
| 56 | 56 | </header> | |
| 57 | 57 | ||
| 58 | - <details id="toc" open> | ||
| 59 | - <summary>Table of Contents</summary> | ||
| 60 | - __TOC__ | ||
| 61 | - </details> | ||
| 58 | + __TOC__ | ||
| 62 | 59 | ||
| 63 | 60 | <div id="apicontent"> | |
| 64 | 61 | __CONTENT__ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,9 +59,11 @@ let all = toc.replace(/index\.html/g, 'all.html') | |||
| 59 | 59 | all = all.replace(/<title>.*?\| /, '<title>'); | |
| 60 | 60 | ||
| 61 | 61 | // Insert the combined table of contents. | |
| 62 | - const tocStart = /<\w+ id="toc"[^>]*>\s*<\w+>.*?<\/\w+>\s*/.exec(all); | ||
| 62 | + const tocStart = /<!-- TOC -->/.exec(all); | ||
| 63 | 63 | all = all.slice(0, tocStart.index + tocStart[0].length) + | |
| 64 | + '<details id="toc" open><summary>Table of contents</summary>\n' + | ||
| 64 | 65 | '<ul>\n' + contents + '</ul>\n' + | |
| 66 | + '</details>\n' + | ||
| 65 | 67 | all.slice(tocStart.index + tocStart[0].length); | |
| 66 | 68 | ||
| 67 | 69 | // Replace apicontent with the concatenated set of apicontents from each source. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -382,13 +382,19 @@ function buildToc({ filename, apilinks }) { | |||
| 382 | 382 | node.children.push({ type: 'html', value: anchor }); | |
| 383 | 383 | }); | |
| 384 | 384 | ||
| 385 | - file.toc = unified() | ||
| 386 | - .use(markdown) | ||
| 387 | - .use(gfm) | ||
| 388 | - .use(remark2rehype, { allowDangerousHtml: true }) | ||
| 389 | - .use(raw) | ||
| 390 | - .use(htmlStringify) | ||
| 391 | - .processSync(toc).toString(); | ||
| 385 | + if (toc !== '') { | ||
| 386 | + file.toc = '<details id="toc" open><summary>Table of contents</summary>' + | ||
| 387 | + unified() | ||
| 388 | + .use(markdown) | ||
| 389 | + .use(gfm) | ||
| 390 | + .use(remark2rehype, { allowDangerousHtml: true }) | ||
| 391 | + .use(raw) | ||
| 392 | + .use(htmlStringify) | ||
| 393 | + .processSync(toc).toString() + | ||
| 394 | + '</details>'; | ||
| 395 | + } else { | ||
| 396 | + file.toc = '<!-- TOC -->'; | ||
| 397 | + } | ||
| 392 | 398 | }; | |
| 393 | 399 | } | |
| 394 | 400 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments