diff --git a/Core.js b/Core.js
index a58621d..f5162a2 100644
--- a/Core.js
+++ b/Core.js
@@ -118,19 +118,18 @@ class SimonUp {
switch (type) {
case 'toc':
- let tocWrapper = '';
- tocWrapper = '
\n';
- if (meta) {
- tocWrapper += `
${meta}
\n`;
- }
- if (content.trim()) {
- const intro = lines.map(function(l) { return self._parseInline(l); }).join('
');
- tocWrapper += `
${intro}
\n`;
- }
- // Hier setzen wir den geheimen Platzhalter INSIDE den Wrapper:
- tocWrapper += '\n';
- tocWrapper += '
';
- return tocWrapper;
+ let tocWrapper = '\n';
+ if (meta) {
+ tocWrapper += `
${meta}
\n`;
+ }
+ if (content.trim()) {
+ const intro = lines.map(function(l) { return self._parseInline(l); }).join('
');
+ tocWrapper += `
${intro}
\n`;
+ }
+ // Eindeutiges Token exakt im Container platzieren
+ tocWrapper += '\n';
+ tocWrapper += '
';
+ return tocWrapper;
case 'c':
const langClass = meta ? ` class="language-${meta}"` : '';
@@ -222,6 +221,31 @@ class SimonUp {
html = html.replace(/\/\/(( \s|$))/g, '$1');
+ // 1. ZUERST: Standard Text-Inline-Rules parsen
+ const inlineRules = [
+ { tag: 'strong', symbol: '\\*\\*' },
+ { tag: 'span style="font-weight: 500;"', symbol: '\\*' },
+ { tag: 'em', symbol: '%' },
+ { tag: 'u', symbol: '_' },
+ { tag: 'del', symbol: '~' },
+ { tag: 'mark', symbol: '=' },
+ { tag: 'sup', symbol: '\\^' },
+ { tag: 'sub', symbol: '°' },
+ { tag: 'code', symbol: '`' }
+ ];
+
+ for (let k = 0; k < inlineRules.length; k++) {
+ let rule = inlineRules[k];
+ let tagSimple = rule.tag.split(' ')[0];
+
+ let regex = new RegExp(rule.symbol + '(.+?)\\\\' + rule.symbol, 'g');
+ html = html.replace(regex, `<${rule.tag}>$1${tagSimple}>`);
+
+ let resetRegex = new RegExp(rule.symbol + '(.+?)(?=' + rule.symbol + '|$)', 'g');
+ html = html.replace(resetRegex, `<${rule.tag}>$1${tagSimple}>`);
+ }
+
+ // 2. DANACH: Überschriften generieren (schützt generierte id="" Attribute vor den Regeln oben)
let self = this;
const processHeading = function(pattern, callback) {
let match;
@@ -261,29 +285,7 @@ class SimonUp {
return `${title}${rest}`;
});
- const inlineRules = [
- { tag: 'strong', symbol: '\\*\\*' },
- { tag: 'span style="font-weight: 500;"', symbol: '\\*' },
- { tag: 'em', symbol: '%' },
- { tag: 'u', symbol: '_' },
- { tag: 'del', symbol: '~' },
- { tag: 'mark', symbol: '=' },
- { tag: 'sup', symbol: '\\^' },
- { tag: 'sub', symbol: '°' },
- { tag: 'code', symbol: '`' }
- ];
-
- for (let k = 0; k < inlineRules.length; k++) {
- let rule = inlineRules[k];
- let tagSimple = rule.tag.split(' ')[0];
-
- let regex = new RegExp(rule.symbol + '(.+?)\\\\' + rule.symbol, 'g');
- html = html.replace(regex, `<${rule.tag}>$1${tagSimple}>`);
-
- let resetRegex = new RegExp(rule.symbol + '(.+?)(?=' + rule.symbol + '|$)', 'g');
- html = html.replace(resetRegex, `<${rule.tag}>$1${tagSimple}>`);
- }
-
+ // 3. RESTLICHE STRUKTUREN (Ausrichtungen, Links, Medien)
const alignMap = { 'l': 'left', 'r': 'right', 'c': 'center', 'j': 'justify' };
html = html.replace(/>([lrcj])\s+(.+?)\s*\/>/g, function(m, dir, content) {
return `${content}
`;
@@ -332,12 +334,10 @@ class SimonUp {
_injectTOC(html) {
const placeholder = '';
- // Wenn kein TOC-Block definiert wurde, machen wir nichts
if (!html.includes(placeholder)) {
return html;
}
- // Wenn keine Überschriften da sind, entfernen wir einfach den Platzhalter
if (this.headings.length === 0) {
return html.replace(placeholder, '');
}
@@ -364,7 +364,6 @@ class SimonUp {
}
tocListHtml += '\n';
- // Jetzt wird es exakt dort eingefügt, wo es hingehört!
return html.replace(placeholder, tocListHtml);
}
@@ -412,22 +411,19 @@ class SimonUp {
currentListType = type;
listBuffer.push(content);
} else if (element.startsWith("<") && !/^(||||||||||
|,
, , )
flushList();
flushParagraph();
processed.push(element);
} else {
- // Freier Text oder Inline-HTML -> Kommt in den Paragraph-Buffer
flushList();
if (element.trim() === "") {
- flushParagraph(); // Leere Zeile erzwingt neuen Absatz
+ flushParagraph();
} else {
paragraphBuffer.push(element);
}
}
}
- // Letzte Reste leeren
flushList();
flushParagraph();