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) {