MCPcopy
hub / github.com/simstudioai/sim / convertMarkdownToHTML

Function convertMarkdownToHTML

apps/sim/tools/telegram/utils.ts:8–22  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

6}
7
8export 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}

Callers 7

send_video.tsFile · 0.90
send_animation.tsFile · 0.90
send_photo.tsFile · 0.90
message.tsFile · 0.90
send_audio.tsFile · 0.90
route.tsFile · 0.90

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected