Fix link URL formatting and fence blank-line collapse in Markdown converter

Claude-Session: https://claude.ai/code/session_01JtuZTCMW9TyogEmBgGf8JT
This commit is contained in:
EugeneTes
2026-09-06 14:34:35 +02:00
parent 9affcc1c03
commit 23bd63b2c6
2 changed files with 13 additions and 0 deletions

View File

@@ -54,4 +54,17 @@ describe("markdownToTelegramHtml", () => {
it("collapses runs of blank lines and trims", () => {
expect(markdownToTelegramHtml("\n\na\n\n\n\nb\n\n")).toBe("a\n\nb");
});
it("protects URL from emphasis formatting (regression: __init__.py)", () => {
expect(markdownToTelegramHtml("See [the init file](https://github.com/org/repo/blob/main/__init__.py) for details")).toBe(
'See <a href="https://github.com/org/repo/blob/main/__init__.py">the init file</a> for details',
);
});
it("preserves blank lines inside fenced code blocks (regression: blank line collapse)", () => {
const md = "```python\ndef foo():\n\n pass\n```";
expect(markdownToTelegramHtml(md)).toBe(
'<pre><code class="language-python">def foo():\n\n pass</code></pre>',
);
});
});

Binary file not shown.