@alexnodeland/claude-telegram 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/html.ts +15 -0
package/package.json
CHANGED
package/src/html.ts
CHANGED
|
@@ -53,6 +53,18 @@ export function markdownToTelegramHtml(md: string): string {
|
|
|
53
53
|
return `\n${PLACEHOLDER_PREFIX}${codeBlocks.length - 1}${PLACEHOLDER_SUFFIX}`;
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
// 1c. Extract blockquotes — inner content gets inline formatting
|
|
57
|
+
withPlaceholders = withPlaceholders.replace(/(?:^|\n)((?:> .+(?:\n|$))+)/g, (_match, block: string) => {
|
|
58
|
+
const inner = block
|
|
59
|
+
.split("\n")
|
|
60
|
+
.map((line) => line.replace(/^> /, ""))
|
|
61
|
+
.filter((line) => line !== "")
|
|
62
|
+
.join("\n");
|
|
63
|
+
const html = `<blockquote>${convertInlineFormatting(inner)}</blockquote>`;
|
|
64
|
+
codeBlocks.push(html);
|
|
65
|
+
return `\n${PLACEHOLDER_PREFIX}${codeBlocks.length - 1}${PLACEHOLDER_SUFFIX}`;
|
|
66
|
+
});
|
|
67
|
+
|
|
56
68
|
// 2. Process non-code-block text
|
|
57
69
|
const placeholderRe = new RegExp(`(${PLACEHOLDER_PREFIX}\\d+${PLACEHOLDER_SUFFIX})`, "g");
|
|
58
70
|
const matchRe = new RegExp(`^${PLACEHOLDER_PREFIX}(\\d+)${PLACEHOLDER_SUFFIX}$`);
|
|
@@ -98,6 +110,9 @@ function convertInlineFormatting(text: string): string {
|
|
|
98
110
|
// Links: [text](url)
|
|
99
111
|
s = s.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
|
|
100
112
|
|
|
113
|
+
// Numbered lists: leading "1. " → keep number with period
|
|
114
|
+
s = s.replace(/^[\t ]*(\d+)\.\s+/gm, "$1. ");
|
|
115
|
+
|
|
101
116
|
// Bullet lists: leading "- " or "* " → "• "
|
|
102
117
|
s = s.replace(/^[\t ]*[-*]\s+/gm, "• ");
|
|
103
118
|
|