diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index 9e30f3481aa195..83efca6a5c5974 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -25,9 +25,7 @@ as the abstract concept that is a resource. If [`Worker`][]s are used, each thread has an independent `async_hooks` interface, and each thread will use a new set of async IDs. -## Public API - -### Overview +## Overview Following is a simple overview of the public API. @@ -79,7 +77,7 @@ function destroy(asyncId) { } function promiseResolve(asyncId) { } ``` -#### `async_hooks.createHook(callbacks)` +## `async_hooks.createHook(callbacks)` ' + '

Describe Something in more detail here.

' }, @@ -111,19 +111,19 @@ const testData = [ }, { file: fixtures.path('document_with_links.md'), - html: '

Usage and ExampleUsage and Example#' + - '

Usage#

node \\[options\\] index.js' + + '

Usage#

node \\[options\\] index.js' + '

Please see the' + 'Command Line Optionsdocument for more information.

' + - '

' + + '

' + 'Example' + - '#

An example of a' + + '#

An example of a' + 'webserverwritten with Node.js which responds with' + '\'Hello, World!\':

' + - '

See also#

Check' + + '

See also#

Check' + 'out alsothis guide

' }, { diff --git a/tools/doc/html.js b/tools/doc/html.js index 67157ba6b5fb09..9089ce7e443232 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -66,10 +66,19 @@ const gtocHTML = unified() const templatePath = path.join(docPath, 'template.html'); const template = fs.readFileSync(templatePath, 'utf8'); -function wrapSections(content) { +function processContent(content) { + content = content.toString(); + // Increment header tag levels to avoid multiple h1 tags in a doc. + // This means we can't already have an
. + if (content.includes('
')) { + throw new Error('Cannot increment a level 6 header'); + } + // `++level` to convert the string to a number and increment it. + content = content.replace(/(?<=<\/?h)[1-5](?=[^<>]*>)/g, (level) => ++level); + // Wrap h3 tags in section tags. let firstTime = true; - return content.toString() - .replace(/

{ + return content + .replace(/

{ if (firstTime) { firstTime = false; return '
' + heading; @@ -91,7 +100,7 @@ function toHTML({ input, content, filename, nodeVersion, versions }) { .replace('__GTOC__', gtocHTML.replace( `class="nav-${id}"`, `class="nav-${id} active"`)) .replace('__EDIT_ON_GITHUB__', editOnGitHub(filename)) - .replace('__CONTENT__', wrapSections(content)); + .replace('__CONTENT__', processContent(content)); const docCreated = input.match( //);