(text: string)
| 108 | } |
| 109 | |
| 110 | export function formatTelegramMessage(text: string): string { |
| 111 | const unwrapped = unwrapMarkdownSourceBlocks(text); |
| 112 | const placeholders: string[] = []; |
| 113 | const withFenced = protect( |
| 114 | unwrapped, |
| 115 | FENCED_CODE_BLOCK_RE, |
| 116 | placeholders, |
| 117 | (block: string) => { |
| 118 | const content = block |
| 119 | .replace(/^```[^\n]*\n/, "") |
| 120 | .replace(/\n```$/, ""); |
| 121 | return `<pre><code>${escapeHtml(content)}</code></pre>`; |
| 122 | }, |
| 123 | ); |
| 124 | const withInline = protect( |
| 125 | withFenced, |
| 126 | INLINE_CODE_RE, |
| 127 | placeholders, |
| 128 | (_match: string, code: string) => `<code>${escapeHtml(code)}</code>`, |
| 129 | ); |
| 130 | |
| 131 | return restore(formatTelegramInline(withInline), placeholders); |
| 132 | } |
no test coverage detected