From 3a5f2a75abc47cc78ab7d19860387e8696cfc074 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Wed, 19 Mar 2025 14:00:32 -0700 Subject: [PATCH 1/6] added discrete headers to .css --- src/app.css | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/app.css b/src/app.css index 358d034..187a433 100644 --- a/src/app.css +++ b/src/app.css @@ -74,7 +74,7 @@ @apply hover:bg-primary-100 dark:hover:bg-primary-800; } - /* Heading */ + /* Section headers */ h1.h-leather, h2.h-leather, h3.h-leather, @@ -108,6 +108,30 @@ @apply text-base font-semibold; } + /* Discrete headers */ + h3.discrete, + h4.discrete, + h5.discrete, + h6.discrete { + @apply text-gray-800 dark:text-gray-300; + } + + h3.discrete { + @apply text-2xl font-bold; + } + + h4.discrete { + @apply text-xl font-bold; + } + + h5.discrete { + @apply text-lg font-semibold; + } + + h6.discrete { + @apply text-base font-semibold; + } + /* Modal */ div.modal-leather > div { @apply bg-primary-0 dark:bg-primary-950 border-b-[1px] border-primary-100 dark:border-primary-600; From 6eed77b967b55264ece6ff65e81bcf4a0c05b061 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Wed, 19 Mar 2025 14:03:21 -0700 Subject: [PATCH 2/6] Addresses issue#201 --- src/app.css | 24 ------------------------ src/styles/publications.css | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/app.css b/src/app.css index 187a433..011ebd9 100644 --- a/src/app.css +++ b/src/app.css @@ -108,30 +108,6 @@ @apply text-base font-semibold; } - /* Discrete headers */ - h3.discrete, - h4.discrete, - h5.discrete, - h6.discrete { - @apply text-gray-800 dark:text-gray-300; - } - - h3.discrete { - @apply text-2xl font-bold; - } - - h4.discrete { - @apply text-xl font-bold; - } - - h5.discrete { - @apply text-lg font-semibold; - } - - h6.discrete { - @apply text-base font-semibold; - } - /* Modal */ div.modal-leather > div { @apply bg-primary-0 dark:bg-primary-950 border-b-[1px] border-primary-100 dark:border-primary-600; diff --git a/src/styles/publications.css b/src/styles/publications.css index b2b2847..fe30740 100644 --- a/src/styles/publications.css +++ b/src/styles/publications.css @@ -229,4 +229,28 @@ .audioblock .content audio { @apply w-full; } + + /* Discrete headers */ + h3.discrete, + h4.discrete, + h5.discrete, + h6.discrete { + @apply text-gray-800 dark:text-gray-300; + } + + h3.discrete { + @apply text-2xl font-bold; + } + + h4.discrete { + @apply text-xl font-bold; + } + + h5.discrete { + @apply text-lg font-semibold; + } + + h6.discrete { + @apply text-base font-semibold; + } } \ No newline at end of file From a5c80b6567663874b06848c89484abf008315574 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 5 Apr 2025 15:55:00 +0200 Subject: [PATCH 3/6] catch all 404 errors, that haven't been handled --- src/routes/[...catchall]/+page.svelte | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/routes/[...catchall]/+page.svelte diff --git a/src/routes/[...catchall]/+page.svelte b/src/routes/[...catchall]/+page.svelte new file mode 100644 index 0000000..b1910e2 --- /dev/null +++ b/src/routes/[...catchall]/+page.svelte @@ -0,0 +1,14 @@ + + +
+

404 - Page Not Found

+

The page you are looking for does not exist or has been moved.

+
+ + +
+
From a263a6fec6ca0643d61de9ffea43a6a7c3537898 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 5 Apr 2025 16:01:38 +0200 Subject: [PATCH 4/6] fix formatting on 404 page --- src/routes/[...catchall]/+page.svelte | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/routes/[...catchall]/+page.svelte b/src/routes/[...catchall]/+page.svelte index b1910e2..dd838c9 100644 --- a/src/routes/[...catchall]/+page.svelte +++ b/src/routes/[...catchall]/+page.svelte @@ -4,11 +4,11 @@ import { Button, P } from 'flowbite-svelte'; -
-

404 - Page Not Found

-

The page you are looking for does not exist or has been moved.

+
+

404 - Page Not Found

+

The page you are looking for does not exist or has been moved.

- - + +
From d62c424a102082b66790dbf2020739fc502f8178 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 5 Apr 2025 16:14:29 +0200 Subject: [PATCH 5/6] Handle discrete headings --- src/lib/components/Preview.svelte | 74 +++++++++++++++++++++---------- src/lib/parser.ts | 15 +++++++ 2 files changed, 66 insertions(+), 23 deletions(-) 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. From aa091014875904c7bcfc615a4ae468574a2c99a7 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sun, 6 Apr 2025 08:43:58 +0200 Subject: [PATCH 6/6] made header handling more concise and dynamic section/disrete --- src/lib/components/Preview.svelte | 59 ++++--------------------------- 1 file changed, 6 insertions(+), 53 deletions(-) diff --git a/src/lib/components/Preview.svelte b/src/lib/components/Preview.svelte index 0a1ffdb..6130feb 100644 --- a/src/lib/components/Preview.svelte +++ b/src/lib/components/Preview.svelte @@ -150,59 +150,12 @@ {#snippet sectionHeading(title: string, depth: number)} - {#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} - {#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} + {@const headingLevel = Math.min(depth + 1, 6)} + {@const className = $pharosInstance.isFloatingTitle(rootId) ? 'discrete' : 'h-leather'} + + + {title} + {/snippet} {#snippet contentParagraph(content: string, publicationType: string)}