mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-25 15:35:43 +01:00
@@ -49,7 +49,7 @@ export class MarkdownString implements IMarkdownString {
|
||||
// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
||||
this.value += (this.supportThemeIcons ? escapeCodicons(value) : value)
|
||||
.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&')
|
||||
.replace(/^([ \t]+)(.+)$/gm, (_match, g1, g2) => ' '.repeat(g1.length) + g2)
|
||||
.replace(/([ \t]+)/g, (_match, g1) => ' '.repeat(g1.length))
|
||||
.replace(/^>/gm, '\\>')
|
||||
.replace(/\n/g, newlineStyle === MarkdownStringTextNewlineStyle.Break ? '\\\n' : '\n\n');
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ suite('MarkdownRenderer', () => {
|
||||
mds.appendText('$(zap) $(not a theme icon) $(add)');
|
||||
|
||||
let result: HTMLElement = renderMarkdown(mds);
|
||||
assert.strictEqual(result.innerHTML, `<p>$(zap) $(not a theme icon) $(add)</p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p>$(zap) $(not a theme icon) $(add)</p>`);
|
||||
});
|
||||
|
||||
test('render appendMarkdown', () => {
|
||||
@@ -85,7 +85,7 @@ suite('MarkdownRenderer', () => {
|
||||
mds.appendText('$(zap) $(not a theme icon) $(add)');
|
||||
|
||||
let result: HTMLElement = renderMarkdown(mds);
|
||||
assert.strictEqual(result.innerHTML, `<p>$(zap) $(not a theme icon) $(add)</p>`);
|
||||
assert.strictEqual(result.innerHTML, `<p>$(zap) $(not a theme icon) $(add)</p>`);
|
||||
});
|
||||
|
||||
test('render appendMarkdown with escaped icon', () => {
|
||||
|
||||
@@ -11,13 +11,13 @@ suite('MarkdownString', () => {
|
||||
test('Escape leading whitespace', function () {
|
||||
const mds = new MarkdownString();
|
||||
mds.appendText('Hello\n Not a code block');
|
||||
assert.equal(mds.value, 'Hello\n\n Not a code block');
|
||||
assert.equal(mds.value, 'Hello\n\n Not a code block');
|
||||
});
|
||||
|
||||
test('MarkdownString.appendText doesn\'t escape quote #109040', function () {
|
||||
const mds = new MarkdownString();
|
||||
mds.appendText('> Text\n>More');
|
||||
assert.equal(mds.value, '\\> Text\n\n\\>More');
|
||||
assert.equal(mds.value, '\\> Text\n\n\\>More');
|
||||
});
|
||||
|
||||
test('appendText', () => {
|
||||
@@ -25,7 +25,7 @@ suite('MarkdownString', () => {
|
||||
const mds = new MarkdownString();
|
||||
mds.appendText('# foo\n*bar*');
|
||||
|
||||
assert.equal(mds.value, '\\# foo\n\n\\*bar\\*');
|
||||
assert.equal(mds.value, '\\# foo\n\n\\*bar\\*');
|
||||
});
|
||||
|
||||
suite('ThemeIcons', () => {
|
||||
@@ -36,7 +36,7 @@ suite('MarkdownString', () => {
|
||||
const mds = new MarkdownString(undefined, { supportThemeIcons: true });
|
||||
mds.appendText('$(zap) $(not a theme icon) $(add)');
|
||||
|
||||
assert.equal(mds.value, '\\\\$\\(zap\\) $\\(not a theme icon\\) \\\\$\\(add\\)');
|
||||
assert.equal(mds.value, '\\\\$\\(zap\\) $\\(not a theme icon\\) \\\\$\\(add\\)');
|
||||
});
|
||||
|
||||
test('appendMarkdown', () => {
|
||||
@@ -61,7 +61,7 @@ suite('MarkdownString', () => {
|
||||
const mds = new MarkdownString(undefined, { supportThemeIcons: false });
|
||||
mds.appendText('$(zap) $(not a theme icon) $(add)');
|
||||
|
||||
assert.equal(mds.value, '$\\(zap\\) $\\(not a theme icon\\) $\\(add\\)');
|
||||
assert.equal(mds.value, '$\\(zap\\) $\\(not a theme icon\\) $\\(add\\)');
|
||||
});
|
||||
|
||||
test('appendMarkdown', () => {
|
||||
|
||||
Reference in New Issue
Block a user