From 4499d6ff09acd08902eb32153319ba6a0b370b77 Mon Sep 17 00:00:00 2001 From: Gamosoft Date: Thu, 18 Dec 2025 12:01:01 +0100 Subject: [PATCH] remove comments from full code blocks for outline --- frontend/app.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/app.js b/frontend/app.js index bce1f50..ce3e3ff 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -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) {