@@ -35,56 +35,60 @@ export const renderOutputsPlugin: JupyterFrontEndPlugin<void> = {
35
35
app : JupyterFrontEnd ,
36
36
rendermime : IRenderMimeRegistry
37
37
) : Promise < void > => {
38
- // TODO: Typeset a fake element to get MathJax loaded, remove this hack once
39
- // MathJax 2 is removed.
40
- await rendermime . latexTypesetter ?. typeset ( document . createElement ( 'div' ) ) ;
41
-
42
- // Render latex in markdown cells
43
- const mdOutput = document . body . querySelectorAll ( 'div.jp-MarkdownOutput' ) ;
44
- mdOutput . forEach ( ( md ) => {
45
- rendermime . latexTypesetter ?. typeset ( md as HTMLElement ) ;
46
- } ) ;
47
- // Render code cell
48
- const cellOutputs = document . body . querySelectorAll (
49
- 'script[type="application/vnd.voila.cell-output+json"]'
50
- ) ;
51
- cellOutputs . forEach ( async ( cellOutput ) => {
52
- const model = JSON . parse ( cellOutput . innerHTML ) ;
53
-
54
- const mimeType = rendermime . preferredMimeType ( model . data , 'any' ) ;
55
-
56
- if ( ! mimeType ) {
57
- return null ;
58
- }
59
- const output = rendermime . createRenderer ( mimeType ) ;
60
- output . renderModel ( model ) . catch ( ( error ) => {
61
- // Manually append error message to output
62
- const pre = document . createElement ( 'pre' ) ;
63
- pre . textContent = `Javascript Error: ${ error . message } ` ;
64
- output . node . appendChild ( pre ) ;
65
-
66
- // Remove mime-type-specific CSS classes
67
- pre . className = 'lm-Widget jp-RenderedText' ;
68
- pre . setAttribute ( 'data-mime-type' , 'application/vnd.jupyter.stderr' ) ;
38
+ app . started . then ( ( ) => {
39
+ // TODO: Typeset a fake element to get MathJax loaded, remove this hack once
40
+ // MathJax 2 is removed.
41
+ rendermime . latexTypesetter ?. typeset ( document . createElement ( 'div' ) ) ;
42
+
43
+ // Render latex in markdown cells
44
+ const mdOutput = document . body . querySelectorAll ( 'div.jp-MarkdownOutput' ) ;
45
+ mdOutput . forEach ( ( md ) => {
46
+ rendermime . latexTypesetter ?. typeset ( md as HTMLElement ) ;
69
47
} ) ;
48
+ // Render code cell
49
+ const cellOutputs = document . body . querySelectorAll (
50
+ 'script[type="application/vnd.voila.cell-output+json"]'
51
+ ) ;
52
+ cellOutputs . forEach ( async ( cellOutput ) => {
53
+ const model = JSON . parse ( cellOutput . innerHTML ) ;
54
+
55
+ const mimeType = rendermime . preferredMimeType ( model . data , 'any' ) ;
56
+ console . log ( 'mimetype' , mimeType , rendermime ) ;
70
57
71
- output . addClass ( 'jp-OutputArea-output' ) ;
58
+ if ( ! mimeType ) {
59
+ return null ;
60
+ }
61
+ const output = rendermime . createRenderer ( mimeType ) ;
62
+ console . log ( 'rendering model' , model ) ;
63
+ output . renderModel ( model ) . catch ( ( error ) => {
64
+ // Manually append error message to output
65
+ const pre = document . createElement ( 'pre' ) ;
66
+ pre . textContent = `Javascript Error: ${ error . message } ` ;
67
+ output . node . appendChild ( pre ) ;
72
68
73
- if ( cellOutput . parentElement ) {
74
- const container = cellOutput . parentElement ;
69
+ // Remove mime-type-specific CSS classes
70
+ pre . className = 'lm-Widget jp-RenderedText' ;
71
+ pre . setAttribute ( 'data-mime-type' , 'application/vnd.jupyter.stderr' ) ;
72
+ } ) ;
75
73
76
- container . removeChild ( cellOutput ) ;
74
+ output . addClass ( 'jp-OutputArea-output' ) ;
77
75
78
- // Attach output
79
- Widget . attach ( output , container ) ;
80
- }
81
- } ) ;
76
+ if ( cellOutput . parentElement ) {
77
+ const container = cellOutput . parentElement ;
82
78
83
- const node = document . getElementById ( 'rendered_cells' ) ;
84
- if ( node ) {
85
- const cells = new RenderedCells ( { node } ) ;
86
- app . shell . add ( cells , 'main' ) ;
87
- }
79
+ container . removeChild ( cellOutput ) ;
80
+
81
+ // Attach output
82
+ Widget . attach ( output , container ) ;
83
+ }
84
+ } ) ;
85
+
86
+ const node = document . getElementById ( 'rendered_cells' ) ;
87
+ if ( node ) {
88
+ const cells = new RenderedCells ( { node } ) ;
89
+ app . shell . add ( cells , 'main' ) ;
90
+ }
91
+ } )
88
92
}
89
93
} ;
90
94
0 commit comments