export function render(buffer, cursor) { const html = buffer.map((line, i) => { if (i !== cursor.line) return `${escapeHtml(line)}`; const before = escapeHtml(line.slice(0, cursor.col)); const after = escapeHtml(line.slice(cursor.col)); return `${before}${after}`; }); document.getElementById("text").innerHTML = html.join("
"); } function escapeHtml(s) { return s.replace(/&/g, "&").replace(//g, ">"); }