Skip to content

Commit

Permalink
Suggest linebreak. Fix #79840
Browse files Browse the repository at this point in the history
  • Loading branch information
octref committed Sep 30, 2019
1 parent 5f8dec8 commit eb5ec0f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/vs/base/common/htmlContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export class MarkdownString implements IMarkdownString {

appendText(value: string): MarkdownString {
// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
this.value += value.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&');
this.value += value
.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&')
.replace('\n', '\n\n');

return this;
}

Expand Down
19 changes: 19 additions & 0 deletions src/vs/base/test/common/markdownString.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as assert from 'assert';
import { MarkdownString } from 'vs/base/common/htmlContent';

suite('markdownString', () => {

test('escape', () => {

const mds = new MarkdownString();

mds.appendText('# foo\n*bar*');

assert.equal(mds.value, '\\# foo\n\n\\*bar\\*');
});
});

0 comments on commit eb5ec0f

Please sign in to comment.