18 lines
1.0 KiB
TypeScript
18 lines
1.0 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { htmlToMarkdown } from "../../../src/lib/workspace/htmlToMarkdown.ts";
|
|
|
|
test("Windows HTML clipboard fragment comments do not become table content", () => {
|
|
const html = '<html><body><!--StartFragment--><table><tr><th>Ticker</th><th>Name</th></tr><tr><td>ADBE.US</td><td>Adobe</td></tr><tr><td>ADSK.US</td><td>Autodesk</td></tr></table><!--EndFragment--></body></html>';
|
|
assert.equal(htmlToMarkdown(html), '| Ticker | Name |\n| --- | --- |\n| ADBE.US | Adobe |\n| ADSK.US | Autodesk |');
|
|
});
|
|
|
|
test("comments inside cells preserve adjacent text and formatting", () => {
|
|
const html = '<table><tr><th>Notes</th></tr><tr><td>First<!-- multi-line\n <b>comment</b> --> part<br><strong>Second</strong></td></tr></table>';
|
|
assert.equal(htmlToMarkdown(html), '| Notes |\n| --- |\n| First part<br>**Second** |');
|
|
});
|
|
|
|
test("escaped comment text remains user content", () => {
|
|
assert.equal(htmlToMarkdown('<p><!--Example--></p>'), '<!--Example-->');
|
|
});
|