(text: string)
| 6 | } |
| 7 | |
| 8 | export function convertMarkdownToHTML(text: string): string { |
| 9 | return ( |
| 10 | text |
| 11 | // Bold: **text** or __text__ -> <b>text</b> |
| 12 | .replace(/\*\*(.*?)\*\*/g, '<b>$1</b>') |
| 13 | .replace(/__(.*?)__/g, '<b>$1</b>') |
| 14 | // Italic: *text* or _text_ -> <i>text</i> |
| 15 | .replace(/\*(.*?)\*/g, '<i>$1</i>') |
| 16 | .replace(/_(.*?)_/g, '<i>$1</i>') |
| 17 | // Code: `text` -> <code>text</code> |
| 18 | .replace(/`(.*?)`/g, '<code>$1</code>') |
| 19 | // Links: [text](url) -> <a href="url">text</a> |
| 20 | .replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>') |
| 21 | ) |
| 22 | } |
no test coverage detected