@@ -2,6 +2,7 @@ import {KernelManager} from './kernel-manager';
22import { Kernel } from './kernel' ;
33import * as vscode from 'vscode' ;
44import { TextDocumentContentProvider } from './resultView' ;
5+ const anser = require ( 'anser' ) ;
56
67const jupyterSchema = 'jupyter-result-viewer' ;
78let previewUri = vscode . Uri . parse ( jupyterSchema + '://authority/jupyter' ) ;
@@ -87,14 +88,18 @@ export class Jupyter {
8788 let htmlResponse = '' ;
8889 return kernel . execute ( code , ( result : { type : string , stream : string , data : { [ key : string ] : string } | string } ) => {
8990 if ( result . type === 'text' && result . stream === 'stdout' && typeof result . data [ 'text/plain' ] === 'string' ) {
90- htmlResponse = htmlResponse + `<p><pre>${ result . data [ 'text/plain' ] } </pre></p>` ;
91+ const htmlText = anser . ansiToHtml ( anser . escapeForHtml ( result . data [ 'text/plain' ] ) ) ;
92+ htmlResponse = htmlResponse + `<p><pre>${ htmlText } </pre></p>` ;
9193 }
9294 if ( result . type === 'text' && result . stream === 'pyout' && typeof result . data [ 'text/plain' ] === 'string' ) {
93- htmlResponse = htmlResponse + `<p><pre>${ result . data [ 'text/plain' ] } </pre></p>` ;
95+ const htmlText = anser . ansiToHtml ( anser . escapeForHtml ( result . data [ 'text/plain' ] ) ) ;
96+ htmlResponse = htmlResponse + `<p><pre>${ htmlText } </pre></p>` ;
9497 }
9598 if ( result . type === 'text' && result . stream === 'error' && typeof result . data [ 'text/plain' ] === 'string' ) {
96- let rawError = ( result . data [ 'text/plain' ] as string ) . replace ( '\n' , '<br/>' ) ;
97- htmlResponse = htmlResponse + `<p style="color:red;">${ rawError } </p>` ;
99+ const htmlText = anser . ansiToHtml ( anser . escapeForHtml ( result . data [ 'text/plain' ] ) ) ;
100+ let rawError = htmlText . replace ( '\n' , '<br/>' ) ;
101+ // htmlResponse = htmlResponse + `<p style="color:black;background-color:white">${rawError}</p>`;
102+ htmlResponse = htmlResponse + `<p><pre>${ rawError } </pre></p>` ;
98103 return resolve ( htmlResponse ) ;
99104 }
100105 if ( result . type === 'text/html' && result . stream === 'pyout' && typeof result . data [ 'text/html' ] === 'string' ) {
0 commit comments