(block: DeepnoteBlock)
| 194 | } |
| 195 | |
| 196 | function convertBlockToCell(block: DeepnoteBlock): QuartoCell { |
| 197 | const isMarkdown = isMarkdownBlockType(block.type) |
| 198 | |
| 199 | let content: string |
| 200 | if (isMarkdown) { |
| 201 | try { |
| 202 | content = createMarkdown(block) |
| 203 | } catch { |
| 204 | // Fallback to raw content for unsupported markdown block types |
| 205 | content = block.content || '' |
| 206 | } |
| 207 | } else if (block.type === 'code') { |
| 208 | content = block.content || '' |
| 209 | } else { |
| 210 | // For SQL, visualization, input blocks, etc., generate Python code |
| 211 | try { |
| 212 | content = createPythonCode(block) |
| 213 | } catch { |
| 214 | // Fallback to raw content for unsupported code block types |
| 215 | content = block.content || '' |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | // Build cell options from metadata |
| 220 | let options: QuartoCellOptions | undefined |
| 221 | const metadata = block.metadata || {} |
| 222 | |
| 223 | if (metadata.quarto_label || metadata.is_code_hidden || metadata.quarto_fig_cap || metadata.quarto_tbl_cap) { |
| 224 | options = {} |
| 225 | if (metadata.quarto_label) { |
| 226 | options.label = metadata.quarto_label as string |
| 227 | } |
| 228 | if (metadata.is_code_hidden) { |
| 229 | options.echo = false |
| 230 | } |
| 231 | if (metadata.quarto_fig_cap) { |
| 232 | options.figCap = metadata.quarto_fig_cap as string |
| 233 | } |
| 234 | if (metadata.quarto_tbl_cap) { |
| 235 | options.tblCap = metadata.quarto_tbl_cap as string |
| 236 | } |
| 237 | if (metadata.quarto_options) { |
| 238 | options.raw = metadata.quarto_options as Record<string, unknown> |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | const cell: QuartoCell = { |
| 243 | cellType: isMarkdown ? 'markdown' : 'code', |
| 244 | content, |
| 245 | ...(options ? { options } : {}), |
| 246 | } |
| 247 | |
| 248 | // Add language if specified in metadata |
| 249 | if (metadata.language && metadata.language !== 'python') { |
| 250 | cell.language = metadata.language as string |
| 251 | } |
| 252 | |
| 253 | return cell |
no test coverage detected