diff --git a/network-poc/frontend/src/pages/index.astro b/network-poc/frontend/src/pages/index.astro index 039cd68..4751da0 100644 --- a/network-poc/frontend/src/pages/index.astro +++ b/network-poc/frontend/src/pages/index.astro @@ -906,18 +906,71 @@ OUTPUT FORMAT: })(); function renderMd(md) { + const lines = md.split('\n'); let html = '', inCode = false, lang = '', buf = ''; - for (const line of md.split('\n')) { - if (line.startsWith('```')) { if (inCode) { html += `
${buf.replace(/`; inCode=false; buf=''; } else { inCode=true; lang=line.slice(3).trim()||'plaintext'; } continue; }
- if (inCode) { buf += (buf?'\n':'') + line; continue; }
- if (!line.trim()) { html += '$1')}${line.replace(/\*\*(.+?)\*\*/g,'$1').replace(/`(.+?)`/g,'$1')}
$1');
}
+
+ function flushTable() {
+ if (!inTable || tableRows.length < 2) { inTable = false; tableRows = []; return; }
+ const hdr = tableRows[0].split('|').filter(c => c.trim());
+ const body = tableRows.slice(2);
+ html += '| ${inline(c.trim())} | `).join('') + '
|---|
| ${inline(c.trim())} | `).join('') + '
${buf.replace(/`;
+ inCode = false; buf = '';
+ } else {
+ flushTable();
+ inCode = true; lang = line.slice(3).trim() || 'plaintext';
+ }
+ continue;
+ }
+ if (inCode) { buf += (buf ? '\n' : '') + line; continue; }
+
+ // Taulukot
+ if (line.includes('|') && line.trim().startsWith('|')) {
+ if (!inTable) inTable = true;
+ tableRows.push(line);
+ continue;
+ } else { flushTable(); }
+
+ // Tyhjä rivi
+ if (!line.trim()) { html += ''; continue; }
+
+ // Otsikot
+ if (line.startsWith('# ')) { html += `${inline(line)}
`; + } + flushTable(); return html; } // === Settings panel ===