From 46de34b8c27d8dca1f88388d608bbf56af06ceec Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Sat, 21 Jul 2018 08:20:11 -0400 Subject: [PATCH] tools: build API TOC using raw headers 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 https://github.com/nodejs/node/pull/21490#issuecomment-406785023 PR-URL: https://github.com/nodejs/node/pull/21922 Reviewed-By: Anna Henningsen Reviewed-By: Vse Mozhet Byt Reviewed-By: Rich Trott --- tools/doc/html.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/doc/html.js b/tools/doc/html.js index 8aaced7424e7fe..fa7cb7b81bcdec 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -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;