( node: ParsedNode, options: RichTextOptions, )
| 230 | } |
| 231 | |
| 232 | function convertRichTextNode( |
| 233 | node: ParsedNode, |
| 234 | options: RichTextOptions, |
| 235 | ): RichText { |
| 236 | if (node.type === 'text') { |
| 237 | return buildRichText(node.textContent, options); |
| 238 | } |
| 239 | |
| 240 | if (node.type === 'br') { |
| 241 | return buildRichText('\n', { ...options, preserveWhitespace: true }); |
| 242 | } |
| 243 | |
| 244 | if (node.type === 'inline_math') { |
| 245 | return [{ equation: { expression: node.expression } }]; |
| 246 | } |
| 247 | |
| 248 | const updatedOptions = { ...options }; |
| 249 | |
| 250 | if (node.type === 'rich_text') { |
| 251 | updatedOptions.annotations = { |
| 252 | ...options.annotations, |
| 253 | ...node.annotations, |
| 254 | }; |
| 255 | if (node.link) { |
| 256 | updatedOptions.link = node.link; |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | return convertRichTextChildNodes(node.element, updatedOptions); |
| 261 | } |
| 262 | |
| 263 | function paragraphBlock(richText: RichText): ParagraphBlock { |
| 264 | return { paragraph: { rich_text: richText } }; |
no test coverage detected