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

Function createMarkdownForTextBlock

packages/blocks/src/blocks/text-blocks.ts:97–134  ·  view source on GitHub ↗
(block: TextBlock)

Source from the content-addressed store, hash-verified

95}
96
97export function createMarkdownForTextBlock(block: TextBlock): string {
98 const content = block.content ?? ''
99
100 if (block.type === 'text-cell-h1') {
101 return `# ${escapeMarkdown(content)}`
102 }
103
104 if (block.type === 'text-cell-h2') {
105 return `## ${escapeMarkdown(content)}`
106 }
107
108 if (block.type === 'text-cell-h3') {
109 return `### ${escapeMarkdown(content)}`
110 }
111
112 if (block.type === 'text-cell-bullet') {
113 const metadata = block.metadata as BulletTextBlockMetadata
114 const indent = ' '.repeat(metadata?.indent_level ?? 0)
115 return `${indent}- ${escapeMarkdown(content)}`
116 }
117
118 if (block.type === 'text-cell-todo') {
119 const metadata = block.metadata as TodoTextBlockMetadata
120 const checkbox = metadata?.checked ? '[x]' : '[ ]'
121
122 return `- ${checkbox} ${escapeMarkdown(content)}`
123 }
124
125 if (block.type === 'text-cell-callout') {
126 return `> ${escapeMarkdown(content)}`
127 }
128
129 if (block.type === 'text-cell-p') {
130 return escapeMarkdown(content)
131 }
132
133 throw new UnsupportedBlockTypeError('Unhandled block type.')
134}
135
136export function stripMarkdownFromTextBlock(block: TextBlock): string {
137 const content = block.content ?? ''

Callers 1

createMarkdownFunction · 0.90

Calls 1

escapeMarkdownFunction · 0.85

Tested by

no test coverage detected