import { test } from 'node:test'; import assert from 'node:assert/strict'; import { loadTs } from './_loadts.mjs'; const { escapeHtml, highlightCommand } = await loadTs('src/lib/highlight.ts'); test('escapeHtml neutralises markup and attribute delimiters', () => { const out = escapeHtml('&'); assert.ok(!out.includes('<')); assert.ok(!out.includes('>')); assert.ok(!out.includes('"')); assert.equal(out, '<b onclick="x">&</b>'); assert.equal(escapeHtml(123), '123'); }); test('highlightCommand never emits raw input markup', () => { const out = highlightCommand('echo "a { const out = highlightCommand('sudo tar -cf /dev/null 10.10.10.10 | sh'); assert.match(out, /sudo<\/span>/); assert.match(out, /-cf<\/span>/); assert.match(out, /10\.10\.10\.10<\/span>/); assert.match(out, /\|<\/span>/); assert.equal(highlightCommand('# a comment'), '# a comment'); assert.equal(highlightCommand('a\nb').split('\n').length, 2); });