@@ -4,7 +4,6 @@ import { spawn, ChildProcess } from 'child_process';
4
4
import { dirname } from 'path' ;
5
5
import { inlineAll } from './inlineScripts' ;
6
6
7
-
8
7
interface RKernelRequest {
9
8
id : number ;
10
9
type : 'eval' | 'cancel' ;
@@ -339,7 +338,6 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
339
338
}
340
339
341
340
async renderHtmlOutput ( response ) {
342
-
343
341
const html = ( await vscode . workspace . fs . readFile ( vscode . Uri . parse ( response . result ) ) ) . toString ( ) ;
344
342
const htmlDir = dirname ( response . result )
345
343
const htmlInline = await inlineAll ( html , htmlDir )
@@ -358,6 +356,26 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
358
356
}
359
357
}
360
358
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
+
361
379
async renderOutput ( cell , response ) {
362
380
363
381
switch ( response . type ) {
@@ -382,6 +400,10 @@ export class RNotebookProvider implements vscode.NotebookContentProvider, vscode
382
400
} ] ;
383
401
break ;
384
402
}
403
+ case 'table' : {
404
+ cell . outputs = [ await this . renderTableOutput ( response ) ] ;
405
+ break ;
406
+ }
385
407
case 'error' : {
386
408
cell . metadata . runState = vscode . NotebookCellRunState . Error ;
387
409
cell . outputs = [ {
0 commit comments