testDiffWithHtmlKeepsEachLinesHtml
A coloured diff reads as the plain one does: each line's HTML is that line's, from the side it comes from.
import { diffWithHtml } from "#codebase/tcmts/share"; import assert from "node:assert/strict"; export const testDiffWithHtmlKeepsEachLinesHtml = () => { const side = (lines: string[], tag: string) => ({ lines, html: lines.map((l) => `<${tag}>${l}</${tag}>`), }); const d = diffWithHtml(side(["a", "b", "c", "d"], "o"), side(["a", "x", "c", "d", "e"], "n")); assert.deepEqual(d.lines, [ [" ", "a"], ["-", "b"], ["+", "x"], [" ", "c"], [" ", "d"], ["+", "e"], ]); assert.deepEqual(d.html, [ "<n>a</n>", "<o>b</o>", "<n>x</n>", "<n>c</n>", "<n>d</n>", "<n>e</n>", ]); }