@@ -4,7 +4,6 @@ import { spawn, ChildProcess } from 'child_process';
44import { dirname } from 'path' ;
55import { inlineAll } from './inlineScripts' ;
66
7-
87interface RKernelRequest {
98 id : number ;
109 type : 'eval' | 'cancel' ;
@@ -339,7 +338,6 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
339338 }
340339
341340 async renderHtmlOutput ( response ) {
342-
343341 const html = ( await vscode . workspace . fs . readFile ( vscode . Uri . parse ( response . result ) ) ) . toString ( ) ;
344342 const htmlDir = dirname ( response . result )
345343 const htmlInline = await inlineAll ( html , htmlDir )
@@ -358,6 +356,26 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
358356 }
359357 }
360358
359+ async renderTableOutput ( response ) {
360+ const html = `
361+ <div id="chunk-table-${ response . id } "></div>
362+ <script>
363+ $('#example').DataTable({
364+ data: JSON.parse('${ JSON . stringify ( response . result ) } ')
365+ })
366+ </script>
367+ `
368+
369+ return {
370+ outputKind : vscode . CellOutputKind . Rich ,
371+ data : {
372+ 'text/html' : response . result . html ,
373+ 'text/markdown' : response . result . markdown ,
374+ 'text/plain' : response . result . markdown
375+ } ,
376+ }
377+ }
378+
361379 async renderOutput ( cell , response ) {
362380
363381 switch ( response . type ) {
@@ -382,6 +400,10 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
382400 } ] ;
383401 break ;
384402 }
403+ case 'table' : {
404+ cell . outputs = [ await this . renderTableOutput ( response ) ] ;
405+ break ;
406+ }
385407 case 'error' : {
386408 cell . metadata . runState = vscode . NotebookCellRunState . Error ;
387409 cell . outputs = [ {
0 commit comments