MCPcopy Create free account
hub / github.com/deepnote/deepnote / convertCellToBlock

Function convertCellToBlock

packages/convert/src/quarto-to-deepnote.ts:440–476  ·  view source on GitHub ↗
(cell: QuartoCell, index: number, idGenerator: () => string)

Source from the content-addressed store, hash-verified

438}
439
440function convertCellToBlock(cell: QuartoCell, index: number, idGenerator: () => string): DeepnoteBlock {
441 const blockType = cell.cellType === 'markdown' ? 'markdown' : 'code'
442
443 const metadata: Record<string, unknown> = {}
444
445 // Preserve Quarto options in metadata
446 if (cell.options) {
447 if (cell.options.label) {
448 metadata.quarto_label = cell.options.label
449 }
450 if (cell.options.echo === false) {
451 metadata.is_code_hidden = true
452 }
453 if (cell.options.figCap) {
454 metadata.quarto_fig_cap = cell.options.figCap
455 }
456 if (cell.options.tblCap) {
457 metadata.quarto_tbl_cap = cell.options.tblCap
458 }
459 if (cell.options.raw) {
460 metadata.quarto_options = cell.options.raw
461 }
462 }
463
464 if (cell.language && cell.language !== 'python') {
465 metadata.language = cell.language
466 }
467
468 return {
469 blockGroup: idGenerator(),
470 content: cell.content,
471 id: idGenerator(),
472 metadata: Object.keys(metadata).length > 0 ? metadata : {},
473 sortingKey: generateSortingKey(index),
474 type: blockType,
475 }
476}

Callers 1

Calls 1

generateSortingKeyFunction · 0.90

Tested by

no test coverage detected