From 251c257dfa8bd7fbd8f356c601d8f4ee79d0c27d Mon Sep 17 00:00:00 2001 From: Claude Code Date: Mon, 6 Apr 2026 18:51:51 +0200 Subject: [PATCH] fix: mdToHtml rendert Ueberschriften und Listen korrekt Vorherige Version entfernte alle ## Headlines und ignorierte Aufzaehlungen. Neue Version rendert h2/h3 und ul/li. Co-Authored-By: Claude Opus 4.6 (1M context) --- vorschau/js/app.js | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/vorschau/js/app.js b/vorschau/js/app.js index 940e430..a1b22f7 100644 --- a/vorschau/js/app.js +++ b/vorschau/js/app.js @@ -113,21 +113,36 @@ }); /* ==================== SIMPLE MARKDOWN ==================== */ - function mdToHtml(md) { +function mdToHtml(md) { if (!md) return ''; - return md - .replace(/^## .+$/gm, '') - .replace(/^### .+$/gm, '') - .replace(/\*\*(.+?)\*\*/g, '$1') - .replace(/\[(\d+[a-z]?)\]/g, '') - .replace(/\n{3,}/g, '\n\n') - .trim() - .split('\n\n') - .filter(function (p) { return p.trim().length > 0; }) - .map(function (p) { return '

' + p.trim().replace(/\n/g, ' ') + '

'; }) - .join(''); + var lines = md.split('\n'); + var html = ''; + var inList = false; + for (var i = 0; i < lines.length; i++) { + var line = lines[i].trim(); + if (!line) { + if (inList) { html += ''; inList = false; } + continue; + } + line = line.replace(/\[(\d+[a-z]?)\]/g, ''); + line = line.replace(/\*\*(.+?)\*\*/g, '$1'); + if (/^## /.test(line)) { + if (inList) { html += ''; inList = false; } + html += '

' + line.replace(/^## /, '') + '

'; + } else if (/^### /.test(line)) { + if (inList) { html += ''; inList = false; } + html += '

' + line.replace(/^### /, '') + '

'; + } else if (/^- /.test(line)) { + if (!inList) { html += ''; inList = false; } + html += '

' + line + '

'; + } + } + if (inList) html += ''; + return html; } - /* ==================== LIVE DATA ==================== */ function timeAgo(dateStr) { var diffMin = Math.floor((Date.now() - new Date(dateStr).getTime()) / 60000);