diff --git a/src/vs/base/common/htmlContent.ts b/src/vs/base/common/htmlContent.ts
index 3943f6f8114..24d3d8dbbde 100644
--- a/src/vs/base/common/htmlContent.ts
+++ b/src/vs/base/common/htmlContent.ts
@@ -67,8 +67,8 @@ function markedStringEqual(a:MarkedString, b:MarkedString): boolean {
);
}
-export function textAsCodeBlock(text: string) : MarkedString {
- return { language: 'string', value: text };
+export function textToMarkedString(text: string) : MarkedString {
+ return text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
}
diff --git a/src/vs/editor/common/services/modelServiceImpl.ts b/src/vs/editor/common/services/modelServiceImpl.ts
index 74a1aafdd76..ca99a8a8246 100644
--- a/src/vs/editor/common/services/modelServiceImpl.ts
+++ b/src/vs/editor/common/services/modelServiceImpl.ts
@@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
import network = require('vs/base/common/network');
import Event, {Emitter} from 'vs/base/common/event';
import {EmitterEvent} from 'vs/base/common/eventEmitter';
-import {MarkedString, textAsCodeBlock} from 'vs/base/common/htmlContent';
+import {MarkedString, textToMarkedString} from 'vs/base/common/htmlContent';
import {IDisposable} from 'vs/base/common/lifecycle';
import Severity from 'vs/base/common/severity';
import URI from 'vs/base/common/uri';
@@ -147,7 +147,7 @@ class ModelMarkerHandler {
if (source) {
message = nls.localize('sourceAndDiagMessage', "[{0}] {1}", source, message);
}
- hoverMessage = [textAsCodeBlock(message)];
+ hoverMessage = [textToMarkedString(message)];
}
return {
diff --git a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
index c61d16844e7..9817cc4957c 100644
--- a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
+++ b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
@@ -9,7 +9,7 @@ import 'vs/css!./goToDeclaration';
import * as nls from 'vs/nls';
import {Throttler} from 'vs/base/common/async';
import {onUnexpectedError} from 'vs/base/common/errors';
-import {MarkedString, textAsCodeBlock} from 'vs/base/common/htmlContent';
+import {MarkedString, textToMarkedString} from 'vs/base/common/htmlContent';
import {KeyCode, KeyMod} from 'vs/base/common/keyCodes';
import * as platform from 'vs/base/common/platform';
import Severity from 'vs/base/common/severity';
@@ -388,7 +388,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
value: text
};
} else {
- hoverMessage = textAsCodeBlock(text);
+ hoverMessage = textToMarkedString(text);
}
}
diff --git a/src/vs/editor/contrib/hover/browser/modesContentHover.ts b/src/vs/editor/contrib/hover/browser/modesContentHover.ts
index 1b1afb521c7..ee34fbc1c66 100644
--- a/src/vs/editor/contrib/hover/browser/modesContentHover.ts
+++ b/src/vs/editor/contrib/hover/browser/modesContentHover.ts
@@ -21,7 +21,7 @@ import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
import {getHover} from '../common/hover';
import {HoverOperation, IHoverComputer} from './hoverOperation';
import {ContentHoverWidget} from './hoverWidgets';
-import {textAsCodeBlock, MarkedString} from 'vs/base/common/htmlContent';
+import {textToMarkedString, MarkedString} from 'vs/base/common/htmlContent';
class ModesContentComputer implements IHoverComputer {
@@ -113,7 +113,7 @@ class ModesContentComputer implements IHoverComputer {
private _getLoadingMessage(): Hover {
return {
range: this._range,
- contents: [textAsCodeBlock(nls.localize('modesContentHover.loading', "Loading..."))]
+ contents: [textToMarkedString(nls.localize('modesContentHover.loading', "Loading..."))]
};
}
}