| 134 | } |
| 135 | |
| 136 | export function stripMarkdownFromTextBlock(block: TextBlock): string { |
| 137 | const content = block.content ?? '' |
| 138 | |
| 139 | if (block.type === 'text-cell-h1') { |
| 140 | return content.replace(/^#\s+/, '').trim() |
| 141 | } |
| 142 | |
| 143 | if (block.type === 'text-cell-h2') { |
| 144 | return content.replace(/^##\s+/, '').trim() |
| 145 | } |
| 146 | |
| 147 | if (block.type === 'text-cell-h3') { |
| 148 | // Also handle h4-h6 markdown (all map to h3 in Deepnote) |
| 149 | return content.replace(/^#{3,6}\s+/, '').trim() |
| 150 | } |
| 151 | |
| 152 | if (block.type === 'text-cell-bullet') { |
| 153 | return content.replace(/^-+\s+/, '').trim() |
| 154 | } |
| 155 | |
| 156 | if (block.type === 'text-cell-todo') { |
| 157 | return content.replace(/^-+\s+\[.\]\s+/, '').trim() |
| 158 | } |
| 159 | |
| 160 | if (block.type === 'text-cell-callout') { |
| 161 | return content.replace(/^>\s+/, '').trim() |
| 162 | } |
| 163 | |
| 164 | if (block.type === 'text-cell-p') { |
| 165 | return content.trim() |
| 166 | } |
| 167 | |
| 168 | throw new UnsupportedBlockTypeError('Unhandled block type.') |
| 169 | } |
| 170 | |
| 171 | export function createMarkdownForSeparatorBlock(_block: SeparatorBlock): string { |
| 172 | return '<hr>' |