(
markdown: string,
options: MarkdownRenderOptions = {},
)
| 1007 | } |
| 1008 | |
| 1009 | export function renderMarkdown( |
| 1010 | markdown: string, |
| 1011 | options: MarkdownRenderOptions = {}, |
| 1012 | ): ReactNode { |
| 1013 | try { |
| 1014 | const palette = resolvePalette(options.palette) |
| 1015 | const codeBlockWidth = options.codeBlockWidth ?? 80 |
| 1016 | const state = createRenderState(palette, codeBlockWidth) |
| 1017 | const ast = processor.parse(markdown) as Root |
| 1018 | applyInlineFallbackFormatting(ast) |
| 1019 | const nodes = renderNode(ast, state, ast.type, undefined) |
| 1020 | return normalizeOutput(nodes) |
| 1021 | } catch (error) { |
| 1022 | logger.error(error, 'Failed to parse markdown') |
| 1023 | return markdown |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | export function hasMarkdown(content: string): boolean { |
| 1028 | return /[*_`#>\-\+]|\[.*\]\(.*\)|```/.test(content) |
no test coverage detected