@alexnodeland/claude-telegram 0.3.3 → 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 +12 -11
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}$`);
|
|
@@ -104,17 +116,6 @@ function convertInlineFormatting(text: string): string {
|
|
|
104
116
|
// Bullet lists: leading "- " or "* " → "• "
|
|
105
117
|
s = s.replace(/^[\t ]*[-*]\s+/gm, "• ");
|
|
106
118
|
|
|
107
|
-
// Blockquotes: leading "> " → <blockquote>
|
|
108
|
-
// Collect consecutive quoted lines into a single blockquote
|
|
109
|
-
s = s.replace(/(?:^> (.+)$(?:\n|$))+/gm, (match) => {
|
|
110
|
-
const inner = match
|
|
111
|
-
.split("\n")
|
|
112
|
-
.map((line) => line.replace(/^> /, ""))
|
|
113
|
-
.filter((line) => line !== "")
|
|
114
|
-
.join("\n");
|
|
115
|
-
return `<blockquote>${inner}</blockquote>\n`;
|
|
116
|
-
});
|
|
117
|
-
|
|
118
119
|
return s;
|
|
119
120
|
})
|
|
120
121
|
.join("");
|