From bfc636f636fec169a940be9ca835da3d9eeaa895 Mon Sep 17 00:00:00 2001 From: Gamosoft Date: Fri, 9 Jan 2026 10:57:34 +0100 Subject: [PATCH] fixed misalignment of list items when using syntax highlight --- frontend/app.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/app.js b/frontend/app.js index 8595b8b..83f482d 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -800,9 +800,17 @@ function noteApp() { // Links [text](url) html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '[$1]($2)'); - // Lists - html = html.replace(/^(\s*)([-*+])\s/gm, '$1$2 '); - html = html.replace(/^(\s*)(\d+\.)\s/gm, '$1$2 '); + // Lists - use [ \t] instead of \s to avoid matching newlines + // Capture rest of line to handle empty bullets properly (issue #142) + html = html.replace(/^(\s*)([-*+])[ \t](.*)$/gm, (match, indent, bullet, rest) => { + // If rest is empty/whitespace-only, add zero-width space to prevent line collapse + const content = rest.trim() === '' ? '\u200B' : rest; + return `${indent}${bullet} ${content}`; + }); + html = html.replace(/^(\s*)(\d+\.)[ \t](.*)$/gm, (match, indent, bullet, rest) => { + const content = rest.trim() === '' ? '\u200B' : rest; + return `${indent}${bullet} ${content}`; + }); // Blockquotes html = html.replace(/^(>.*)$/gm, '$1');