[label](https://evil.example)
").includes("\\[label\\]")); }); await t.test("escapes formatting characters", () => { assert.doesNotMatch(escapeMarkdown("**b** _i_ `c` ~s~ ||x||"), /(? { assert.ok(escapeMarkdown("\\[x](y)").startsWith("\\\\\\[")); }); await t.test("leaves ordinary punctuation readable", () => { // Escaping these too would be correct but makes normal prose unreadable, // and they're cosmetic at worst: no link can be forged with them. const prose = "Order #123 (shipped) - 50% off > see details"; assert.equal(escapeMarkdown(prose), prose); }); }); test("link rendering", async (t) => { await t.test("keeps the label and shows the real destination", () => { assert.equal( htmlToText('Click here'), "Click here (Hi
"), "Hi"); }); await t.test("strips invisible preheader padding", () => { assert.equal(htmlToText("Hi
"), "Hi"); }); await t.test("strips short screen-reader-only labels", () => { assert.equal(htmlToText('Company logoReal
'), "Real"); }); await t.test("keeps long hidden blocks, which are usually real content", () => { const long = "word ".repeat(100); assert.ok(htmlToText(``).includes("word")); }); });