diff --git a/doc/template.html b/doc/template.html
index 391b1a0ec7b924..f57bf50bb67334 100644
--- a/doc/template.html
+++ b/doc/template.html
@@ -55,10 +55,7 @@
__CONTENT__
diff --git a/tools/doc/allhtml.js b/tools/doc/allhtml.js
index 5a24cee4292656..93197f812e10c6 100644
--- a/tools/doc/allhtml.js
+++ b/tools/doc/allhtml.js
@@ -59,9 +59,11 @@ let all = toc.replace(/index\.html/g, 'all.html')
all = all.replace(/
.*?\| /, '');
// Insert the combined table of contents.
-const tocStart = /<\w+ id="toc"[^>]*>\s*<\w+>.*?<\/\w+>\s*/.exec(all);
+const tocStart = //.exec(all);
all = all.slice(0, tocStart.index + tocStart[0].length) +
+ 'Table of contents
\n' +
'\n' +
+ ' \n' +
all.slice(tocStart.index + tocStart[0].length);
// Replace apicontent with the concatenated set of apicontents from each source.
diff --git a/tools/doc/html.js b/tools/doc/html.js
index d35fd47b601e09..6eb3484052bc69 100644
--- a/tools/doc/html.js
+++ b/tools/doc/html.js
@@ -382,13 +382,19 @@ function buildToc({ filename, apilinks }) {
node.children.push({ type: 'html', value: anchor });
});
- file.toc = unified()
- .use(markdown)
- .use(gfm)
- .use(remark2rehype, { allowDangerousHtml: true })
- .use(raw)
- .use(htmlStringify)
- .processSync(toc).toString();
+ if (toc !== '') {
+ file.toc = 'Table of contents
' +
+ unified()
+ .use(markdown)
+ .use(gfm)
+ .use(remark2rehype, { allowDangerousHtml: true })
+ .use(raw)
+ .use(htmlStringify)
+ .processSync(toc).toString() +
+ ' ';
+ } else {
+ file.toc = '';
+ }
};
}