mirror of
https://github.com/SethCohen/github-releases-to-discord
synced 2026-09-14 20:13:23 +00:00
feat: enhance reduceHeadings function to handle indented and closed markdown headings and add tests for new functionality. resolves #51
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user