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) <noreply@anthropic.com>
Dieser Commit ist enthalten in:
Claude Code
2026-04-06 18:51:51 +02:00
Ursprung 4b49ba04ff
Commit 251c257dfa

Datei anzeigen

@@ -115,19 +115,34 @@
/* ==================== SIMPLE MARKDOWN ==================== */ /* ==================== SIMPLE MARKDOWN ==================== */
function mdToHtml(md) { function mdToHtml(md) {
if (!md) return ''; if (!md) return '';
return md var lines = md.split('\n');
.replace(/^## .+$/gm, '') var html = '';
.replace(/^### .+$/gm, '') var inList = false;
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>') for (var i = 0; i < lines.length; i++) {
.replace(/\[(\d+[a-z]?)\]/g, '') var line = lines[i].trim();
.replace(/\n{3,}/g, '\n\n') if (!line) {
.trim() if (inList) { html += '</ul>'; inList = false; }
.split('\n\n') continue;
.filter(function (p) { return p.trim().length > 0; }) }
.map(function (p) { return '<p>' + p.trim().replace(/\n/g, ' ') + '</p>'; }) line = line.replace(/\[(\d+[a-z]?)\]/g, '');
.join(''); line = line.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
if (/^## /.test(line)) {
if (inList) { html += '</ul>'; inList = false; }
html += '<h2>' + line.replace(/^## /, '') + '</h2>';
} else if (/^### /.test(line)) {
if (inList) { html += '</ul>'; inList = false; }
html += '<h3>' + line.replace(/^### /, '') + '</h3>';
} else if (/^- /.test(line)) {
if (!inList) { html += '<ul>'; inList = true; }
html += '<li>' + line.replace(/^- /, '') + '</li>';
} else {
if (inList) { html += '</ul>'; inList = false; }
html += '<p>' + line + '</p>';
}
}
if (inList) html += '</ul>';
return html;
} }
/* ==================== LIVE DATA ==================== */ /* ==================== LIVE DATA ==================== */
function timeAgo(dateStr) { function timeAgo(dateStr) {
var diffMin = Math.floor((Date.now() - new Date(dateStr).getTime()) / 60000); var diffMin = Math.floor((Date.now() - new Date(dateStr).getTime()) / 60000);