diff --git a/src/lib/components/Preview.svelte b/src/lib/components/Preview.svelte index f7dfe03..0a1ffdb 100644 --- a/src/lib/components/Preview.svelte +++ b/src/lib/components/Preview.svelte @@ -150,30 +150,58 @@ {#snippet sectionHeading(title: string, depth: number)} - {#if depth === 0} -

- {title} -

- {:else if depth === 1} -

- {title} -

- {:else if depth === 2} -

- {title} -

- {:else if depth === 3} -

- {title} -

- {:else if depth === 4} -
- {title} -
+ {#if $pharosInstance.isFloatingTitle(rootId)} + {#if depth === 0} +

+ {title} +

+ {:else if depth === 1} +

+ {title} +

+ {:else if depth === 2} +

+ {title} +

+ {:else if depth === 3} +

+ {title} +

+ {:else if depth === 4} +
+ {title} +
+ {:else} +
+ {title} +
+ {/if} {:else} -
- {title} -
+ {#if depth === 0} +

+ {title} +

+ {:else if depth === 1} +

+ {title} +

+ {:else if depth === 2} +

+ {title} +

+ {:else if depth === 3} +

+ {title} +

+ {:else if depth === 4} +
+ {title} +
+ {:else} +
+ {title} +
+ {/if} {/if} {/snippet} diff --git a/src/lib/parser.ts b/src/lib/parser.ts index b9f9545..273c8a3 100644 --- a/src/lib/parser.ts +++ b/src/lib/parser.ts @@ -270,6 +270,21 @@ export default class Pharos { return block.convert(); } + /** + * Checks if the node with the given ID is a floating title (discrete header). + * @param id The ID of the node to check. + * @returns True if the node is a floating title, false otherwise. + */ + isFloatingTitle(id: string): boolean { + const normalizedId = this.normalizeId(id); + if (!normalizedId || !this.nodes.has(normalizedId)) { + return false; + } + + const context = this.eventToContextMap.get(normalizedId); + return context === 'floating_title'; + } + /** * Updates the `content` field of a Nostr event in-place. * @param dTag The d tag of the event to update.