提交 1459824c 编写于 作者: J Joao Moreno

tokenize source in release notes editor

related to #13049
上级 ea194582
......@@ -91,6 +91,10 @@ code > div {
overflow: auto;
}
.monaco-tokenized-source {
white-space: pre;
}
/** Theming */
.vscode-light {
......
......@@ -25,6 +25,8 @@ import { Keybinding } from 'vs/base/common/keybinding';
import { IRequestService } from 'vs/platform/request/common/request';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import product from 'vs/platform/product';
import { IModeService } from 'vs/editor/common/services/modeService';
import {tokenizeToString} from 'vs/editor/common/modes/textToHtmlTokenizer';
function renderBody(body: string): string {
return `<!DOCTYPE html>
......@@ -52,7 +54,8 @@ export class ReleaseNotesEditor extends BaseEditor {
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IRequestService private requestService: IRequestService,
@IOpenerService private openerService: IOpenerService,
@IKeybindingService private keybindingService: IKeybindingService
@IKeybindingService private keybindingService: IKeybindingService,
@IModeService private modeService: IModeService
) {
super(ReleaseNotesEditor.ID, telemetryService);
this.disposables = [];
......@@ -81,7 +84,29 @@ export class ReleaseNotesEditor extends BaseEditor {
this.loadContents(() => this.requestService.request({ url })
.then(asText)
.then(text => this.patchKeybindings(text))
.then(marked.parse)
.then(text => {
// we first need to load the modes...
const result = [];
const renderer = new marked.Renderer();
renderer.code = (code, lang) => {
const modeId = this.modeService.getModeIdForLanguageName(lang);
result.push(this.modeService.getOrCreateMode(modeId));
return '';
};
marked(text, { renderer });
return TPromise.join(result).then(() => text);
})
.then(text => {
// then we can render
const renderer = new marked.Renderer();
renderer.code = (code, lang) => {
const modeId = this.modeService.getModeIdForLanguageName(lang);
return `<code>${ tokenizeToString(code, modeId) }</code>`;
};
return marked(text, { renderer });
})
.then(renderBody)
.then<void>(body => {
const webview = new WebView(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册