mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
[js] use textToMarkedString in JSON contributions
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
11
extensions/javascript/src/features/markedTextUtil.ts
Normal file
11
extensions/javascript/src/features/markedTextUtil.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* 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
|
||||
}
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user