Skip to content

Commit

Permalink
docs(markdown): parse :::note's text as MD elements
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Sep 11, 2024
1 parent aaac57b commit 0d97fc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions utils/doclint/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,12 +802,12 @@ function generateSourceCodeComment(spec) {
node.codeLang = parseCodeLang(node.codeLang).highlighter;
if (node.type === 'note') {
// @ts-ignore
node.type = 'text';
node.text = '**NOTE** ' + node.text;
node.type = 'text'
node.text = `**NOTE** ` + (node.children || []).map(child => md.render([child], { flattenText: false, omitLastCR: true })).join('↵')
}
});
// 5 is a typical member doc offset.
return md.render(comments, { maxColumns: 120 - 5, omitLastCR: true, flattenText: true });
return md.render(comments, { maxColumns: 120 - 5, omitLastCR: true, flattenText: true });
}

/**
Expand Down
7 changes: 4 additions & 3 deletions utils/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@

/** @typedef {MarkdownBaseNode & {
* type: 'note',
* text: string,
* noteType: string,
* }} MarkdownNoteNode */

Expand Down Expand Up @@ -208,7 +207,7 @@ function buildTree(lines) {
tokens.push(line.substring(indent.length));
line = lines[++i];
}
node.text = tokens.join('↵');
node.children = buildTree(tokens);
appendNode(indent, node);
continue;
}
Expand Down Expand Up @@ -341,7 +340,9 @@ function innerRenderMdNode(indent, node, lastNode, result, options) {
if (node.type === 'note') {
newLine();
result.push(`${indent}:::${node.noteType}`);
result.push(wrapText(node.text, options, indent));
const children = node.children || [];
for (const child of children)
innerRenderMdNode(indent, child, children[children.length - 1], result, options);
result.push(`${indent}:::`);
newLine();
return;
Expand Down

0 comments on commit 0d97fc4

Please sign in to comment.