remove comments from full code blocks for outline

This commit is contained in:
Gamosoft 2025-12-18 12:01:01 +01:00
parent 3c03935ff4
commit 4499d6ff09
1 changed files with 11 additions and 3 deletions

View File

@ -1182,9 +1182,9 @@ function noteApp() {
const lines = content.split('\n');
const slugCounts = {}; // Track duplicate slugs
// Skip frontmatter
// Skip frontmatter and code blocks
let inFrontmatter = false;
let frontmatterEnded = false;
let inCodeBlock = false;
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
@ -1197,11 +1197,19 @@ function noteApp() {
if (inFrontmatter) {
if (line.trim() === '---') {
inFrontmatter = false;
frontmatterEnded = true;
}
continue;
}
// Handle fenced code blocks (``` or ~~~)
if (line.trim().startsWith('```') || line.trim().startsWith('~~~')) {
inCodeBlock = !inCodeBlock;
continue;
}
if (inCodeBlock) {
continue;
}
// Match heading lines (# to ######)
const match = line.match(/^(#{1,6})\s+(.+)$/);
if (match) {