mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[ResponseOps] escape vertical bars in mustache variables when used with markdown (#136072)
resolves https://github.com/elastic/kibana/issues/135826 Escapes the character `|` in mustache variables used in markdown content, so that embedded `|` chars in a mustache variable can still be used in markdown tables (that use `|`).
This commit is contained in:
parent
ed1849688e
commit
e0b6517ae5
2 changed files with 3 additions and 0 deletions
|
@ -28,6 +28,7 @@ const variables = {
|
|||
st: '*',
|
||||
ul: '_',
|
||||
st_lt: '*<',
|
||||
vl: '|',
|
||||
};
|
||||
|
||||
describe('mustache_renderer', () => {
|
||||
|
@ -77,6 +78,7 @@ describe('mustache_renderer', () => {
|
|||
expect(renderMustacheString('{{bs}}', variables, 'markdown')).toBe('\\' + variables.bs);
|
||||
expect(renderMustacheString('{{st}}', variables, 'markdown')).toBe('\\' + variables.st);
|
||||
expect(renderMustacheString('{{ul}}', variables, 'markdown')).toBe('\\' + variables.ul);
|
||||
expect(renderMustacheString('{{vl}}', variables, 'markdown')).toBe('\\' + variables.vl);
|
||||
});
|
||||
|
||||
it('handles triple escapes', () => {
|
||||
|
|
|
@ -123,6 +123,7 @@ function escapeMarkdown(value: unknown): string {
|
|||
|
||||
return `${value}`
|
||||
.replace(/\\/g, '\\\\')
|
||||
.replace(/\|/g, '\\|')
|
||||
.replace(/`/g, '\\`')
|
||||
.replace(/\*/g, '\\*')
|
||||
.replace(/_/g, '\\_')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue