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 ==================== */
function mdToHtml(md) {
if (!md) return '';
return md
.replace(/^## .+$/gm, '')
.replace(/^### .+$/gm, '')
.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
.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>' + p.trim().replace(/\n/g, ' ') + '</p>'; })
.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 += '</ul>'; inList = false; }
continue;
}
line = line.replace(/\[(\d+[a-z]?)\]/g, '');
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 ==================== */
function timeAgo(dateStr) {
var diffMin = Math.floor((Date.now() - new Date(dateStr).getTime()) / 60000);