@@ -25,6 +25,8 @@ import { Keybinding } from 'vs/base/common/keybinding';
2525import { IRequestService } from 'vs/platform/request/common/request' ;
2626import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
2727import product from 'vs/platform/product' ;
28+ import { IModeService } from 'vs/editor/common/services/modeService' ;
29+ import { tokenizeToString } from 'vs/editor/common/modes/textToHtmlTokenizer' ;
2830
2931function renderBody ( body : string ) : string {
3032 return `<!DOCTYPE html>
@@ -52,7 +54,8 @@ export class ReleaseNotesEditor extends BaseEditor {
5254 @IWorkbenchEditorService private editorService : IWorkbenchEditorService ,
5355 @IRequestService private requestService : IRequestService ,
5456 @IOpenerService private openerService : IOpenerService ,
55- @IKeybindingService private keybindingService : IKeybindingService
57+ @IKeybindingService private keybindingService : IKeybindingService ,
58+ @IModeService private modeService : IModeService
5659 ) {
5760 super ( ReleaseNotesEditor . ID , telemetryService ) ;
5861 this . disposables = [ ] ;
@@ -81,7 +84,29 @@ export class ReleaseNotesEditor extends BaseEditor {
8184 this . loadContents ( ( ) => this . requestService . request ( { url } )
8285 . then ( asText )
8386 . then ( text => this . patchKeybindings ( text ) )
84- . then ( marked . parse )
87+ . then ( text => {
88+ // we first need to load the modes...
89+ const result = [ ] ;
90+ const renderer = new marked . Renderer ( ) ;
91+ renderer . code = ( code , lang ) => {
92+ const modeId = this . modeService . getModeIdForLanguageName ( lang ) ;
93+ result . push ( this . modeService . getOrCreateMode ( modeId ) ) ;
94+ return '' ;
95+ } ;
96+
97+ marked ( text , { renderer } ) ;
98+ return TPromise . join ( result ) . then ( ( ) => text ) ;
99+ } )
100+ . then ( text => {
101+ // then we can render
102+ const renderer = new marked . Renderer ( ) ;
103+ renderer . code = ( code , lang ) => {
104+ const modeId = this . modeService . getModeIdForLanguageName ( lang ) ;
105+ return `<code>${ tokenizeToString ( code , modeId ) } </code>` ;
106+ } ;
107+
108+ return marked ( text , { renderer } ) ;
109+ } )
85110 . then ( renderBody )
86111 . then < void > ( body => {
87112 const webview = new WebView (
0 commit comments