// Automatische Kapitel-Nummerierung document.addEventListener('DOMContentLoaded', function() { let chapterCounter = 0; let sectionCounter = 0; let subsectionCounter = 0; // Alle Überschriften finden und nummerieren const headings = document.querySelectorAll('.heading-level-1, .heading-level-2, .heading-level-3'); headings.forEach(heading => { if (heading.classList.contains('heading-level-1')) { chapterCounter++; sectionCounter = 0; subsectionCounter = 0; heading.innerHTML = chapterCounter + ' ' + heading.innerHTML; } else if (heading.classList.contains('heading-level-2')) { sectionCounter++; subsectionCounter = 0; heading.innerHTML = chapterCounter + '.' + sectionCounter + ' ' + heading.innerHTML; } else if (heading.classList.contains('heading-level-3')) { subsectionCounter++; heading.innerHTML = chapterCounter + '.' + sectionCounter + '.' + subsectionCounter + ' ' + heading.innerHTML; } }); });