This commit is contained in:
2026-06-30 20:23:53 +02:00
commit 594c4c674d
5 changed files with 1547 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
export function render(buffer, cursor) {
const html = buffer.map((line, i) => {
if (i !== cursor.line) return `<span>${escapeHtml(line)}</span>`;
const before = escapeHtml(line.slice(0, cursor.col));
const after = escapeHtml(line.slice(cursor.col));
return `<span>${before}<span class="cursor"></span>${after}</span>`;
});
document.getElementById("text").innerHTML = html.join("<br>");
}
function escapeHtml(s) {
return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}