diff --git a/src/lib/components/ZettelEditor.svelte b/src/lib/components/ZettelEditor.svelte index e3fb92e..a993d26 100644 --- a/src/lib/components/ZettelEditor.svelte +++ b/src/lib/components/ZettelEditor.svelte @@ -101,6 +101,18 @@ Understanding the nature of knowledge itself... return detectContentType(content); }); + // Helper function to get section level from content + function getSectionLevel(sectionContent: string): number { + const lines = sectionContent.split(/\r?\n/); + for (const line of lines) { + const match = line.match(/^(=+)\s+/); + if (match) { + return match[1].length; + } + } + return 2; // Default to level 2 + } + // Parse sections for preview display let parsedSections = $derived.by(() => { if (!parsedContent) return []; @@ -108,11 +120,13 @@ Understanding the nature of knowledge itself... return parsedContent.sections.map((section: { metadata: AsciiDocMetadata; content: string; title: string }) => { // Use simple parsing directly on section content for accurate tag extraction const tags = parseSimpleAttributes(section.content); + const level = getSectionLevel(section.content); return { title: section.title || "Untitled", content: section.content.trim(), tags, + level, }; }); }); @@ -230,136 +244,139 @@ Understanding the nature of knowledge itself... {/if} -