Skip to content

Commit a41d137

Browse files
mehalterchingor13
andauthored
fix: don't escape html tags inside of inline code in release notes (#2367)
Co-authored-by: Jeff Ching <chingor@google.com>
1 parent 050cf93 commit a41d137

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

__snapshots__/default-changelog-notes.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ exports['DefaultChangelogNotes buildNotes with commit parsing should handle html
153153
* render all imagesets as &lt;picture&gt; ([383fb14](https://github.com/googleapis/java-asset/commit/383fb14708ae91f7bb7e64bf0bacab38))
154154
`
155155

156+
exports['DefaultChangelogNotes buildNotes with commit parsing should handle html tags as inline code 1'] = `
157+
## [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
158+
159+
160+
### Features
161+
162+
* render all imagesets as &lt;picture&gt; \`<picture>\` \`\` \`<picture>\` \`\` ([82fcfaf](https://github.com/googleapis/java-asset/commit/82fcfaf039487566a6e2d49a215afe09))
163+
`
164+
156165
exports['DefaultChangelogNotes buildNotes with commit parsing should handle inline bug links 1'] = `
157166
## [1.2.3](https://github.com/googleapis/java-asset/compare/v1.2.2...v1.2.3) (1983-10-10)
158167

src/changelog-notes/default.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,7 @@ function replaceIssueLink(
123123
}
124124

125125
function htmlEscape(message: string): string {
126-
return message.replace('<', '&lt;').replace('>', '&gt;');
126+
return message.replace(/``[^`].*[^`]``|`[^`]*`|<|>/g, match =>
127+
match.length > 1 ? match : match === '<' ? '&lt;' : '&gt;'
128+
);
127129
}

test/changelog-notes/default-changelog-notes.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,20 @@ describe('DefaultChangelogNotes', () => {
276276
expect(notes).to.is.string;
277277
safeSnapshot(notes);
278278
});
279+
it('should handle html tags as inline code', async () => {
280+
const commits = [
281+
buildMockCommit(
282+
'feat: render all imagesets as <picture> `<picture>` `` `<picture>` ``'
283+
),
284+
];
285+
const changelogNotes = new DefaultChangelogNotes();
286+
const notes = await changelogNotes.buildNotes(
287+
parseConventionalCommits(commits),
288+
notesOptions
289+
);
290+
expect(notes).to.is.string;
291+
safeSnapshot(notes);
292+
});
279293
// it('ignores reverted commits', async () => {
280294
// const commits = [buildCommitFromFixture('multiple-messages')];
281295
// const changelogNotes = new DefaultChangelogNotes();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy