Skip to content

Commit b98bf82

Browse files
rubystargos
authored andcommitted
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 #21490 (comment) PR-URL: #21922 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent eabe907 commit b98bf82

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/doc/html.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,10 @@ function buildToc({ filename }) {
340340

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

347349
const hasStability = node.stability !== undefined;

0 commit comments

Comments
 (0)