diff --git a/__snapshots__/default-changelog-notes.js b/__snapshots__/default-changelog-notes.js index 1116f347e..0ebca5644 100644 --- a/__snapshots__/default-changelog-notes.js +++ b/__snapshots__/default-changelog-notes.js @@ -153,6 +153,15 @@ exports['DefaultChangelogNotes buildNotes with commit parsing should handle html * render all imagesets as <picture> ([383fb14](https://github.com/googleapis/java-asset/commit/383fb14708ae91f7bb7e64bf0bacab38)) ` +exports['DefaultChangelogNotes buildNotes with commit parsing should handle html tags as inline code 1'] = ` +## [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10) + + +### Features + +* render all imagesets as <picture> \`\` \`\` \`\` \`\` ([82fcfaf](https://github.com/googleapis/java-asset/commit/82fcfaf039487566a6e2d49a215afe09)) +` + exports['DefaultChangelogNotes buildNotes with commit parsing should handle inline bug links 1'] = ` ## [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10) diff --git a/src/changelog-notes/default.ts b/src/changelog-notes/default.ts index 49405aa08..e3e47f6b6 100644 --- a/src/changelog-notes/default.ts +++ b/src/changelog-notes/default.ts @@ -123,5 +123,7 @@ function replaceIssueLink( } function htmlEscape(message: string): string { - return message.replace('<', '<').replace('>', '>'); + return message.replace(/``[^`].*[^`]``|`[^`]*`|<|>/g, match => + match.length > 1 ? match : match === '<' ? '<' : '>' + ); } diff --git a/test/changelog-notes/default-changelog-notes.ts b/test/changelog-notes/default-changelog-notes.ts index e78e48d10..ffb9baa9d 100644 --- a/test/changelog-notes/default-changelog-notes.ts +++ b/test/changelog-notes/default-changelog-notes.ts @@ -276,6 +276,20 @@ describe('DefaultChangelogNotes', () => { expect(notes).to.is.string; safeSnapshot(notes); }); + it('should handle html tags as inline code', async () => { + const commits = [ + buildMockCommit( + 'feat: render all imagesets as `` `` `` ``' + ), + ]; + const changelogNotes = new DefaultChangelogNotes(); + const notes = await changelogNotes.buildNotes( + parseConventionalCommits(commits), + notesOptions + ); + expect(notes).to.is.string; + safeSnapshot(notes); + }); // it('ignores reverted commits', async () => { // const commits = [buildCommitFromFixture('multiple-messages')]; // const changelogNotes = new DefaultChangelogNotes();