MCPcopy Index your code
hub / github.com/deepnote/deepnote / printBlock

Function printBlock

packages/cli/src/commands/cat.ts:191–226  ·  view source on GitHub ↗

* Print a single block with formatting.

(block: DeepnoteBlock, options: CatOptions)

Source from the content-addressed store, hash-verified

189 * Print a single block with formatting.
190 */
191async function printBlock(block: DeepnoteBlock, options: CatOptions): Promise<void> {
192 const chalk = getChalk()
193 const typeColor = getTypeColor(block.type)
194
195 output(`${chalk.dim('─'.repeat(60))}`)
196 output(`${typeColor(block.type)} ${chalk.dim(`(${block.id})`)}`)
197
198 // Show label for input blocks
199 if (block.type.startsWith('input-')) {
200 const metadata = block.metadata as { deepnote_variable_name?: string } | undefined
201 if (metadata?.deepnote_variable_name) {
202 output(chalk.dim(` Variable: ${metadata.deepnote_variable_name}`))
203 }
204 }
205
206 // Show content unless --tree mode
207 if (!options.tree) {
208 let content = getBlockContent(block)
209 if (content) {
210 output('')
211 if (block.type === 'markdown' || block.type.startsWith('text-cell-')) {
212 content = wrapAnsi(content, TEXT_BLOCK_MAX_WIDTH, { hard: true })
213 }
214 const highlighted = await highlightContent(content, block.type)
215 // Indent each line
216 const lines = highlighted.split('\n')
217 for (const line of lines) {
218 output(` ${line}`)
219 }
220 } else if (content === '') {
221 output(chalk.dim(' (empty)'))
222 }
223 }
224
225 output('')
226}
227
228/**
229 * Filter blocks by type if --type option is provided.

Callers 1

printBlocksFunction · 0.85

Calls 5

getChalkFunction · 0.90
outputFunction · 0.90
getTypeColorFunction · 0.85
highlightContentFunction · 0.85
getBlockContentFunction · 0.70

Tested by

no test coverage detected