Skip to content

Commit f3cbc81

Browse files
fix(ui): fix mixed bold/notbold markdown in title annotations (cherry-pick argoproj#16064 for 3.7) (argoproj#16229)
Signed-off-by: John Kelly <johnke@gmail.com> Co-authored-by: John Kelly <johnke@gmail.com>
1 parent 3d63982 commit f3cbc81

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

ui/src/shared/components/workflows-utils.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ describe('escapeInvalidMarkdown', () => {
1414
expect(escapeInvalidMarkdown('-# subheader')).toBe('subheader');
1515
expect(escapeInvalidMarkdown('\nthis\nis\ntext\nwith\nline\nbreaks\n')).toBe('this is text with line breaks');
1616
expect(escapeInvalidMarkdown('- list item\n* list item\n1. list item')).toBe('\\- list item \\* list item 1\\. list item');
17+
expect(escapeInvalidMarkdown('**bold** notbold')).toBe('**bold** notbold');
1718
});
1819
});

ui/src/workflows/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export function escapeInvalidMarkdown(markdown: string) {
22
return markdown
3-
.replace(/([-*])\s(.*\n*)/g, '\\$1 $2') // escape list items
4-
.replace(/(\d)\.\s(.*\n*)/g, '$1\\. $2') // escape ordered list items
3+
.replace(/^([-*])\s(.*)/gm, '\\$1 $2') // escape list items
4+
.replace(/^(\d)\.\s(.*)/gm, '$1\\. $2') // escape ordered list items
55
.replace(/(-#)\s/g, '') // remove subheaders
66
.replace(/\n/g, ' ') // remove line breaks
77
.replace(/`{3}/g, '') // remove code blocks

0 commit comments

Comments
 (0)