Skip to content

Commit

Permalink
tools: build API TOC using raw headers
Browse files Browse the repository at this point in the history
Markdown interprets the syntax for optional arguments as a form of a link,
so instead of trying to build up the contents using the node value, use
grab the raw original markup instead.

Fixes regression noted in nodejs#21490 (comment)
  • Loading branch information
rubys committed Jul 21, 2018
1 parent 9466865 commit 484646c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,10 @@ function buildToc({ filename }) {

depth = node.depth;
const realFilename = path.basename(realFilenames[0], '.md');
const headingText = node.children.map((child) => child.value)
.join().trim();
const headingText = node.children.map((child) =>
file.contents.slice(child.position.start.offset,
child.position.end.offset)
).join('').trim();
const id = getId(`${realFilename}_${headingText}`, idCounters);

const hasStability = node.stability !== undefined;
Expand Down

0 comments on commit 484646c

Please sign in to comment.