chore(docs): remove unused generateToc function (#32111)

This commit is contained in:
Max Schmitt 2024-08-12 10:56:59 +02:00 committed by GitHub
parent 45c2e8a3ed
commit ba8f94df56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -461,24 +461,6 @@ function visit(node, visitor, depth = 0) {
visit(n, visitor, depth + 1);
}
/**
* @param {MarkdownNode[]} nodes
* @param {boolean=} h3
* @returns {string}
*/
function generateToc(nodes, h3) {
const result = [];
visitAll(nodes, (node, depth) => {
if (node.type === 'h1' || node.type === 'h2' || (h3 && node.type === 'h3')) {
let link = node.text.toLowerCase();
link = link.replace(/[ ]+/g, '-');
link = link.replace(/[^\w-_]/g, '');
result.push(`${' '.repeat(depth * 2)}- [${node.text}](#${link})`);
}
});
return result.join('\n');
}
/**
* @param {MarkdownNode[]} nodes
* @param {string} language
@ -509,4 +491,4 @@ function filterNodesForLanguage(nodes, language) {
return result;
}
module.exports = { parse, render, clone, visitAll, visit, generateToc, filterNodesForLanguage, wrapText };
module.exports = { parse, render, clone, visitAll, visit, filterNodesForLanguage, wrapText };