(value: string)
| 19 | }; |
| 20 | |
| 21 | const inlineMarkdownToHtml = (value: string): string => { |
| 22 | let result = escapeHtml(value); |
| 23 | |
| 24 | result = result.replace( |
| 25 | /!\[([^\]]*)\]\(([^)]+)\)/g, |
| 26 | (_, alt: string, url: string) => |
| 27 | `<img src="${escapeAttribute(url)}" alt="${alt}" />`, |
| 28 | ); |
| 29 | |
| 30 | result = result.replace( |
| 31 | /\[([^\]]+)\]\(([^)]+)\)/g, |
| 32 | (_, label: string, url: string) => |
| 33 | `<a href="${escapeAttribute(url)}">${label}</a>`, |
| 34 | ); |
| 35 | |
| 36 | return result |
| 37 | .split(/(<[^>]+>)/g) |
| 38 | .map((part) => |
| 39 | part.startsWith('<') ? part : applyInlineTextFormatting(part), |
| 40 | ) |
| 41 | .join(''); |
| 42 | }; |
| 43 | |
| 44 | /** |
| 45 | * Converts markdown to HTML using basic markdown syntax. |
no test coverage detected