diff --git a/tools/doc/html.js b/tools/doc/html.js index 60cacd5b791bcb..dfd0f22c7c8330 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -56,7 +56,7 @@ function toHTML({ input, filename, nodeVersion, analytics }, cb) { const section = firstHeading ? firstHeading.text : 'Index'; preprocessText(lexed); - preprocessElements(lexed); + preprocessElements(lexed, filename); // Generate the table of contents. This mutates the lexed contents in-place. const toc = buildToc(lexed, filename); @@ -171,7 +171,7 @@ function linkJsTypeDocs(text) { } // Preprocess stability blockquotes and YAML blocks. -function preprocessElements(lexed) { +function preprocessElements(lexed, filename) { const STABILITY_RE = /(.*:)\s*(\d)([\s\S]*)/; let state = null; let headingIndex = -1; @@ -205,10 +205,16 @@ function preprocessElements(lexed) { headingIndex = -1; heading = null; } + + // Do not link to the section we are already in. + const noLinking = filename === 'documentation' && + heading !== null && heading.text === 'Stability Index'; token.text = `