From 0428c0d37fd632c757461a40c2159025c721099e Mon Sep 17 00:00:00 2001 From: simonpipe Date: Thu, 9 Jul 2026 23:21:48 +0200 Subject: [PATCH] Update Core.js --- Core.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Core.js b/Core.js index f81bcd1..edcf6eb 100644 --- a/Core.js +++ b/Core.js @@ -34,7 +34,10 @@ class SimonUp { } } + // Phase 1: Blöcke und Inline-Strukturen parsen (sammelt auch alle Überschriften) html = this._parseBlocks(html); + + // Phase 2: Das Inhaltsverzeichnis nachträglich in die vorbereitete Box einsetzen html = this._injectTOC(html); if (this.plugins && this.plugins.length > 0) { @@ -126,6 +129,7 @@ class SimonUp { const intro = lines.map(function(l) { return self._parseInline(l); }).join('
'); tocWrapper += `

${intro}

\n`; } + // HIER IST JETZT DER ECHTE PLATZHALTER: tocWrapper += '\n'; tocWrapper += ''; return tocWrapper; @@ -270,7 +274,7 @@ class SimonUp { const numStr = self._getAutoNumber(level); const fullTitle = `${numStr} ${title}`; const id = self._slugify(fullTitle); - self.headings.push({ level: level, text: fullTitle, id: id }); + self.headings.push({ level: level, text: title, id: id }); // Speichert nur den puren Titel ohne Nummer für das TOC Link-Markup return `${fullTitle}${rest}`; }); @@ -331,19 +335,20 @@ class SimonUp { * INTERN: Erzeugt die fertige HTML-Liste des TOC und injiziert sie in den Block */ _injectTOC(html) { + // HIER STEHT JETZT DEFINITIV DAS RECHTE TOKEN: const placeholder = ''; - + if (!html.includes(placeholder)) { return html; } - + if (this.headings.length === 0) { return html.replace(placeholder, ''); } - + let tocListHtml = '
\n\n'.repeat(diffFinal); } tocListHtml += '\n
'; - + return html.replace(placeholder, tocListHtml); } @@ -395,7 +400,7 @@ class SimonUp { for (let i = 0; i < elements.length; i++) { let element = elements[i]; if (!element) continue; - + let isUlItem = element.startsWith(""); let isOlItem = element.startsWith(""); @@ -403,7 +408,7 @@ class SimonUp { flushParagraph(); let type = isUlItem ? "ul" : "ol"; let content = isUlItem ? element.replace(/<\/?ul-item>/g, "") : element.replace(/<\/?ol-item>/g, ""); - + if (currentListType && currentListType !== type) { flushList(); }