feat: enhance reduceHeadings function to handle indented and closed markdown headings and add tests for new functionality. resolves #51

This commit is contained in:
SethCohen
2026-04-03 12:32:35 -04:00
parent b96a33520f
commit 80aca15d72
3 changed files with 26 additions and 2 deletions
+15 -2
View File
@@ -61,8 +61,21 @@ const removeGithubReferenceLinks = (text) => text
* @returns {string} The text with reduced heading sizes.
*/
const reduceHeadings = (text) => text
.replace(/^###\s+(.+)$/gm, '**__$1__**') // Convert H3 to bold + underline
.replace(/^##\s+(.+)$/gm, '**$1**'); // Convert H2 to bold
.split('\n')
.map((line) => {
const h3 = line.match(/^\s*###\s+(.+?)\s*#*\s*$/);
if (h3) {
return `**__${h3[1].trim()}__**`;
}
const h2 = line.match(/^\s*##\s+(.+?)\s*#*\s*$/);
if (h2) {
return `**${h2[1].trim()}**`;
}
return line;
})
.join('\n');
/**
* Converts PR, issue, and changelog links to markdown format, ignoring existing markdown links.