@@ -52,15 +52,16 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
52
52
let executionId = 0 ;
53
53
for ( const cell of cells ) {
54
54
if ( token . isCancellationRequested ) return ;
55
-
56
55
executionId += 1 ;
57
56
58
57
progress . report ( { message : `Exporting ${ cell . document . languageId . toUpperCase ( ) } cell ${ executionId } of ${ cells . length } ..` } ) ;
59
58
59
+ const cellContents : string [ ] = [ ] ;
60
+
60
61
switch ( cell . document . languageId ) {
61
62
case `markdown` :
62
63
const markdown = cell . document . getText ( ) ;
63
- cellsHTML . push ( converter . makeHtml ( markdown ) ) ;
64
+ cellContents . push ( converter . makeHtml ( markdown ) ) ;
64
65
break ;
65
66
66
67
case `sql` :
@@ -73,7 +74,7 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
73
74
74
75
( { chartDetail, content } = getStatementDetail ( content , eol ) ) ;
75
76
76
- cellsHTML . push ( `<pre>${ content } </pre>` ) ;
77
+ cellContents . push ( `<pre>${ content } </pre>` ) ;
77
78
78
79
// Execute the query
79
80
const query = selected . job . query ( content ) ;
@@ -102,15 +103,15 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
102
103
const possibleChart = generateChart ( executionId , chartDetail , columns , table , generateChartHTMLEmbedded ) ;
103
104
if ( possibleChart ) {
104
105
scripts . push ( possibleChart . script ) ;
105
- cellsHTML . push ( possibleChart . html ) ;
106
+ cellContents . push ( possibleChart . html ) ;
106
107
fallbackToTable = false ;
107
108
requiresChartJs = true ;
108
109
}
109
110
}
110
111
}
111
112
112
113
if ( fallbackToTable ) {
113
- cellsHTML . push ( [
114
+ cellContents . push ( [
114
115
`<table style="width: 100%; margin-left: auto; margin-right: auto;">` ,
115
116
`<thead>` ,
116
117
`<tr>` ,
@@ -143,7 +144,7 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
143
144
144
145
case `cl` :
145
146
const commandText = cell . document . getText ( ) ;
146
- cellsHTML . push ( `<pre>${ commandText } </pre>` ) ;
147
+ cellContents . push ( `<pre>${ commandText } </pre>` ) ;
147
148
148
149
try {
149
150
const command = await connection . runCommand ( {
@@ -152,15 +153,15 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
152
153
} ) ;
153
154
154
155
if ( command . stdout ) {
155
- cellsHTML . push ( [
156
+ cellContents . push ( [
156
157
`<pre>` ,
157
158
command . stdout ,
158
159
`</pre>`
159
160
] . join ( `\n` ) ) ;
160
161
}
161
162
162
163
if ( command . stderr ) {
163
- cellsHTML . push ( [
164
+ cellContents . push ( [
164
165
`<pre>` ,
165
166
command . stderr ,
166
167
`</pre>`
@@ -177,7 +178,7 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
177
178
case `shellscript` :
178
179
const shellText = cell . document . getText ( ) ;
179
180
180
- cellsHTML . push ( `<pre>${ shellText } </pre>` ) ;
181
+ cellContents . push ( `<pre>${ shellText } </pre>` ) ;
181
182
182
183
try {
183
184
const command = await connection . runCommand ( {
@@ -186,15 +187,15 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
186
187
} ) ;
187
188
188
189
if ( command . stdout ) {
189
- cellsHTML . push ( [
190
+ cellContents . push ( [
190
191
`<pre>` ,
191
192
command . stdout ,
192
193
`</pre>`
193
194
] . join ( `\n` ) ) ;
194
195
}
195
196
196
197
if ( command . stderr ) {
197
- cellsHTML . push ( [
198
+ cellContents . push ( [
198
199
`<pre>` ,
199
200
command . stderr ,
200
201
`</pre>`
@@ -211,7 +212,8 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
211
212
break ;
212
213
}
213
214
214
- cellsHTML . push ( `<hr />` ) ;
215
+ cellsHTML . push ( asCell ( cellContents . join ( `<br />` ) ) ) ;
216
+ cellsHTML . push ( asCell ( `<hr />` ) ) ;
215
217
}
216
218
217
219
if ( cells . length > 0 ) {
@@ -228,12 +230,12 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
228
230
border: 0;
229
231
border-top: 1px solid #e8e8e8;
230
232
}
231
- tr {
233
+ .notebookCell {
232
234
padding-top: 1em;
233
235
padding-bottom: 1em;
234
236
}
235
237
@media print {
236
- td {
238
+ .notebookCell {
237
239
break-inside: avoid;
238
240
}
239
241
}
@@ -247,7 +249,7 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
247
249
<body>
248
250
<table style="margin-left: auto; margin-right: auto; width: 60%;">
249
251
<tbody style="width: 100%;">
250
- ${ cellsHTML . map ( content => `<tr><td style="padding-top: 0.2em; padding-bottom: 0.2em;"> ${ content } </td></tr>` ) . join ( `` ) }
252
+ ${ cellsHTML . join ( `` ) }
251
253
</tbody>
252
254
</table>
253
255
</body>
@@ -266,4 +268,8 @@ export const exportNotebookAsHtml = vscode.commands.registerCommand(`vscode-db2i
266
268
}
267
269
}
268
270
}
269
- } ) ;
271
+ } ) ;
272
+
273
+ function asCell ( content : string ) {
274
+ return `<tr><td class="notebookCell" style="padding-top: 0.2em; padding-bottom: 0.2em;">${ content } </td></tr>` ;
275
+ }
0 commit comments