diff --git a/src/lib/components/publications/PublicationSection.svelte b/src/lib/components/publications/PublicationSection.svelte index 2b9aace..1379e27 100644 --- a/src/lib/components/publications/PublicationSection.svelte +++ b/src/lib/components/publications/PublicationSection.svelte @@ -12,6 +12,7 @@ import type { TableOfContents as TocType } from "./table_of_contents.svelte"; import { postProcessAdvancedAsciidoctorHtml } from "$lib/utils/markup/advancedAsciidoctorPostProcessor"; import { parseAdvancedmarkup } from "$lib/utils/markup/advancedMarkupParser"; + import NDK from "@nostr-dev-kit/ndk"; let { address, @@ -30,6 +31,7 @@ } = $props(); const asciidoctor: Asciidoctor = getContext("asciidoctor"); + const ndk: NDK = getContext("ndk"); let leafEvent: Promise = $derived.by( async () => await publicationTree.getEvent(address), @@ -62,7 +64,7 @@ } else { // For 30041 and 30818 events, use Asciidoctor (AsciiDoc) const converted = asciidoctor.convert(content); - const processed = await postProcessAdvancedAsciidoctorHtml(converted.toString()); + const processed = await postProcessAdvancedAsciidoctorHtml(converted.toString(), ndk); return processed; } }); diff --git a/src/lib/utils/markup/advancedAsciidoctorPostProcessor.ts b/src/lib/utils/markup/advancedAsciidoctorPostProcessor.ts index 2cde13e..14b2344 100644 --- a/src/lib/utils/markup/advancedAsciidoctorPostProcessor.ts +++ b/src/lib/utils/markup/advancedAsciidoctorPostProcessor.ts @@ -1,3 +1,4 @@ +import NDK from "@nostr-dev-kit/ndk"; import { postProcessAsciidoctorHtml } from "./asciidoctorPostProcessor.ts"; import plantumlEncoder from "plantuml-encoder"; @@ -10,11 +11,12 @@ import plantumlEncoder from "plantuml-encoder"; */ export async function postProcessAdvancedAsciidoctorHtml( html: string, + ndk?: NDK, ): Promise { if (!html) return html; try { // First apply the basic post-processing (wikilinks, nostr addresses) - let processedHtml = await postProcessAsciidoctorHtml(html); + let processedHtml = await postProcessAsciidoctorHtml(html, ndk); // Unified math block processing processedHtml = fixAllMathBlocks(processedHtml); // Process PlantUML blocks diff --git a/src/lib/utils/markup/asciidoctorPostProcessor.ts b/src/lib/utils/markup/asciidoctorPostProcessor.ts index 090ae94..f90dc42 100644 --- a/src/lib/utils/markup/asciidoctorPostProcessor.ts +++ b/src/lib/utils/markup/asciidoctorPostProcessor.ts @@ -1,3 +1,4 @@ +import NDK from "@nostr-dev-kit/ndk"; import { processAsciiDocAnchors, processImageWithReveal, @@ -54,6 +55,7 @@ function fixStemBlocks(html: string): string { */ export async function postProcessAsciidoctorHtml( html: string, + ndk?: NDK, ): Promise { if (!html) return html; @@ -63,7 +65,7 @@ export async function postProcessAsciidoctorHtml( // Then process wikilinks in [[...]] format (if any remain) processedHtml = processWikilinks(processedHtml); // Then process nostr addresses (but not those already in links) - processedHtml = await processNostrIdentifiersInText(processedHtml); + processedHtml = await processNostrIdentifiersInText(processedHtml, ndk); processedHtml = fixStemBlocks(processedHtml); // Fix math blocks for MathJax // Process image blocks to add reveal/enlarge functionality processedHtml = processImageBlocks(processedHtml); diff --git a/src/routes/my-notes/+page.svelte b/src/routes/my-notes/+page.svelte index 9e7dfa4..c8d645e 100644 --- a/src/routes/my-notes/+page.svelte +++ b/src/routes/my-notes/+page.svelte @@ -65,6 +65,7 @@ }); renderedContent[event.id] = await postProcessAsciidoctorHtml( html as string, + ndk, ); } // Collect unique tags by type