提交 757650b2 编写于 作者: M Martin Aeschlimann

[js] use textToMarkedString in JSON contributions

上级 4e235375
......@@ -8,6 +8,7 @@ import {MarkedString, CompletionItemKind, CompletionItem, DocumentSelector} from
import {IJSONContribution, ISuggestionsCollector} from './jsonContributions';
import {XHRRequest} from 'request-light';
import {Location} from 'jsonc-parser';
import {textToMarkedString} from './markedTextUtil';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
......@@ -173,7 +174,7 @@ export class BowerJSONContribution implements IJSONContribution {
htmlContent.push(localize('json.bower.package.hover', '{0}', pack));
return this.getInfo(pack).then(documentation => {
if (documentation) {
htmlContent.push({ language: 'string', value: documentation});
htmlContent.push(textToMarkedString(documentation));
}
return htmlContent;
});
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import {MarkedString} from 'vscode';
export function textToMarkedString(text: string) : MarkedString {
return text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import {MarkedString, CompletionItemKind, CompletionItem, DocumentSelector} from
import {IJSONContribution, ISuggestionsCollector} from './jsonContributions';
import {XHRRequest} from 'request-light';
import {Location} from 'jsonc-parser';
import {textToMarkedString} from './markedTextUtil';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
......@@ -214,7 +215,7 @@ export class PackageJSONContribution implements IJSONContribution {
htmlContent.push(localize('json.npm.package.hover', '{0}', pack));
return this.getInfo(pack).then(infos => {
infos.forEach(info => {
htmlContent.push({language: 'string', value: info});
htmlContent.push(textToMarkedString(info));
});
return htmlContent;
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册