diff --git a/__tests__/changelog_entries.test.ts b/__tests__/changelog_entries.test.ts index cd68a9d..6b77580 100644 --- a/__tests__/changelog_entries.test.ts +++ b/__tests__/changelog_entries.test.ts @@ -97,6 +97,21 @@ test('Extract multiple changelog entries from markdown with regular line breaks' expect(extractEntriesFromMarkdown(txt)).toEqual(expectedOutput) }) +test('Changelog Entry with numbered change is extracted properly', async () => { + const txt = `## Changelog +### Changed +- [#1234](/hello-world) Test changelog modification` + + const expectedOutput : ChangelogEntry[] = [ + { + text: '[#1234](/hello-world) Test changelog modification', + type: 'changed' + } + ] + + expect(extractEntriesFromMarkdown(txt)).toEqual(expectedOutput) +}) + test('Extract multiple changelog entries from markdown with \r\n line breaks', async () => { const txt = '## Description\r\n\r\n\r\n## How Has This Been Tested?\r\n\r\n\r\n## Checklist:\r\n- [ ] My code is up to date with the development branch, i\'ve pulled in the latest changes\r\n- [ ] I\'ve added the build label to my PR\r\n\r\n## Changelog\r\n### Changed\r\n- [Hello](World) Hello world\r\n- [Hello](World) Hello world 2\r\n- [Hello](World) Hello world 3\r\nSomething that\'s not the correct format\r\n\r\n## Deprecated (incorrect)\r\n- [Hello](World) Incorrect deprecated change\r\n\r\n### Fixed\r\n- [A fix](www.vendic.nl) Fixed\r\n- A great fix!\r\n' const expectedOutput : ChangelogEntry[] = [ @@ -141,3 +156,5 @@ test('Extract CHANGELOG section from pull request body', async () => { expect(extractChangelogSection(fileContents)).toEqual(expectedResult) }) + + diff --git a/src/changelog_entries.ts b/src/changelog_entries.ts index 4b066ef..ff30d6e 100644 --- a/src/changelog_entries.ts +++ b/src/changelog_entries.ts @@ -23,7 +23,9 @@ export function extractEntriesFromMarkdown(markdown : string) : ChangelogEntry[] core.info('Extracting entries from markdown') core.debug('Searching through:') core.debug(markdown) - const themesContent = markdown.match(/###[^#]+/mg); + + const patternStr = new RegExp("###(.*(?:(?:\\n|\\r\\n).+)*(?:\\n|\\r\\n)?)", "mg") + const themesContent = markdown.match(patternStr); if (!Array.isArray(themesContent) || Array.isArray(themesContent) && themesContent.length === 0) { return []