Browse Source

Fix tag rendering for all event types in preview

- Fixed regex bug in attribute parsing (\s instead of \\s)
- Section-specific tags now extracted correctly from AsciiDoc attributes
- Added tag display for index events (30040) in preview
- Removed duplicate document header/tags rendering
- Tags now show for all 30040 and 30041 events at all parse levels

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
master
limina1 5 months ago
parent
commit
9f2aebfe4c
  1. 53
      src/lib/components/ZettelEditor.svelte
  2. 2
      src/lib/utils/publication_tree_processor.ts

53
src/lib/components/ZettelEditor.svelte

@ -922,37 +922,6 @@ @@ -922,37 +922,6 @@
Start typing to see the preview...
</div>
{:else}
<!-- Show document title and tags for articles -->
{#if contentType === "article" && publicationResult?.metadata.title}
<div
class="mb-8 pb-6 border-b border-gray-200 dark:border-gray-700"
>
<h1
class="text-2xl font-bold text-gray-900 dark:text-gray-100 mb-4"
>
{publicationResult.metadata.title}
</h1>
<!-- Document-level tags -->
{#if publicationResult.metadata.attributes.tags}
{@const tagsList =
publicationResult.metadata.attributes.tags
.split(",")
.map((t: string) => t.trim())}
{#if tagsList.length > 0}
<div class="flex flex-wrap gap-2">
{#each tagsList as tag}
<span
class="bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 px-3 py-1 rounded-full text-sm font-medium"
>
#{tag}
</span>
{/each}
</div>
{/if}
{/if}
</div>
{/if}
<div class="prose prose-sm dark:prose-invert max-w-none">
<!-- Render full document with title if it's an article -->
{#if contentType === "article" && publicationResult?.metadata.title}
@ -977,17 +946,35 @@ @@ -977,17 +946,35 @@
class="mb-6 pb-6 border-b border-gray-200 dark:border-gray-700 last:border-0"
>
{#if section.isIndex}
<!-- Index event: show as simple title -->
<!-- Index event: show title and tags -->
<div class="space-y-3">
<!-- Event type indicator -->
<div
class="text-sm font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wider mb-2"
class="text-sm font-semibold text-gray-600 dark:text-gray-400 uppercase tracking-wider"
>
Index Event (30040)
</div>
<!-- Title -->
<h2
class="text-lg font-bold text-gray-900 dark:text-gray-100"
>
{section.title}
</h2>
<!-- Tags -->
{#if section.tags && section.tags.length > 0}
<div class="flex flex-wrap gap-2">
{#each section.tags as tag}
<span
class="bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 px-2 py-1 rounded-full text-xs font-medium"
>
#{tag[1]}
</span>
{/each}
</div>
{/if}
</div>
{:else}
<!-- Content event: show title, tags, then content -->
<div class="space-y-3">

2
src/lib/utils/publication_tree_processor.ts

@ -319,7 +319,7 @@ function parseSegmentContent( @@ -319,7 +319,7 @@ function parseSegmentContent(
for (let i = 1; i < sectionLines.length; i++) {
const line = sectionLines[i].trim();
if (line.startsWith(":") && line.includes(":")) {
const match = line.match(/^:([^:]+):\\s*(.*)$/);
const match = line.match(/^:([^:]+):\s*(.*)$/);
if (match) {
attributes[match[1]] = match[2];
contentStartIdx = i + 1;

Loading…
Cancel
Save