---
import './code-component.css';
interface Props {
code: string;
ins?: string;
del?: string;
__test_mode?: boolean;
}
const { code, del, ins, __test_mode = false } = Astro.props;
const escapeHtml = (s: string) =>
s
.replaceAll('&', '&')
.replaceAll('<', '<')
.replaceAll('>', '>')
.replaceAll('"', '"')
.replaceAll("'", ''');
const htmlCode = code
.split('\n')
.map((line) => `${escapeHtml(line)}`)
.join('\n');
const props: Record = {};
/* v8 ignore start */
if (del) {
props['data-lines-deleted'] = del;
}
if (ins) {
props['data-lines-inserted'] = ins;
}
/* v8 ignore stop */
const id = __test_mode ? 'test-id' : Math.random().toString(36).substring(2, 9);
---