Browse Source

Fixed npub display on Asciidoc

master
silberengel 7 months ago
parent
commit
fb7419a508
  1. 4
      src/lib/components/publications/PublicationSection.svelte
  2. 4
      src/lib/utils/markup/advancedAsciidoctorPostProcessor.ts
  3. 4
      src/lib/utils/markup/asciidoctorPostProcessor.ts
  4. 1
      src/routes/my-notes/+page.svelte

4
src/lib/components/publications/PublicationSection.svelte

@ -12,6 +12,7 @@
import type { TableOfContents as TocType } from "./table_of_contents.svelte"; import type { TableOfContents as TocType } from "./table_of_contents.svelte";
import { postProcessAdvancedAsciidoctorHtml } from "$lib/utils/markup/advancedAsciidoctorPostProcessor"; import { postProcessAdvancedAsciidoctorHtml } from "$lib/utils/markup/advancedAsciidoctorPostProcessor";
import { parseAdvancedmarkup } from "$lib/utils/markup/advancedMarkupParser"; import { parseAdvancedmarkup } from "$lib/utils/markup/advancedMarkupParser";
import NDK from "@nostr-dev-kit/ndk";
let { let {
address, address,
@ -30,6 +31,7 @@
} = $props(); } = $props();
const asciidoctor: Asciidoctor = getContext("asciidoctor"); const asciidoctor: Asciidoctor = getContext("asciidoctor");
const ndk: NDK = getContext("ndk");
let leafEvent: Promise<NDKEvent | null> = $derived.by( let leafEvent: Promise<NDKEvent | null> = $derived.by(
async () => await publicationTree.getEvent(address), async () => await publicationTree.getEvent(address),
@ -62,7 +64,7 @@
} else { } else {
// For 30041 and 30818 events, use Asciidoctor (AsciiDoc) // For 30041 and 30818 events, use Asciidoctor (AsciiDoc)
const converted = asciidoctor.convert(content); const converted = asciidoctor.convert(content);
const processed = await postProcessAdvancedAsciidoctorHtml(converted.toString()); const processed = await postProcessAdvancedAsciidoctorHtml(converted.toString(), ndk);
return processed; return processed;
} }
}); });

4
src/lib/utils/markup/advancedAsciidoctorPostProcessor.ts

@ -1,3 +1,4 @@
import NDK from "@nostr-dev-kit/ndk";
import { postProcessAsciidoctorHtml } from "./asciidoctorPostProcessor.ts"; import { postProcessAsciidoctorHtml } from "./asciidoctorPostProcessor.ts";
import plantumlEncoder from "plantuml-encoder"; import plantumlEncoder from "plantuml-encoder";
@ -10,11 +11,12 @@ import plantumlEncoder from "plantuml-encoder";
*/ */
export async function postProcessAdvancedAsciidoctorHtml( export async function postProcessAdvancedAsciidoctorHtml(
html: string, html: string,
ndk?: NDK,
): Promise<string> { ): Promise<string> {
if (!html) return html; if (!html) return html;
try { try {
// First apply the basic post-processing (wikilinks, nostr addresses) // First apply the basic post-processing (wikilinks, nostr addresses)
let processedHtml = await postProcessAsciidoctorHtml(html); let processedHtml = await postProcessAsciidoctorHtml(html, ndk);
// Unified math block processing // Unified math block processing
processedHtml = fixAllMathBlocks(processedHtml); processedHtml = fixAllMathBlocks(processedHtml);
// Process PlantUML blocks // Process PlantUML blocks

4
src/lib/utils/markup/asciidoctorPostProcessor.ts

@ -1,3 +1,4 @@
import NDK from "@nostr-dev-kit/ndk";
import { import {
processAsciiDocAnchors, processAsciiDocAnchors,
processImageWithReveal, processImageWithReveal,
@ -54,6 +55,7 @@ function fixStemBlocks(html: string): string {
*/ */
export async function postProcessAsciidoctorHtml( export async function postProcessAsciidoctorHtml(
html: string, html: string,
ndk?: NDK,
): Promise<string> { ): Promise<string> {
if (!html) return html; if (!html) return html;
@ -63,7 +65,7 @@ export async function postProcessAsciidoctorHtml(
// Then process wikilinks in [[...]] format (if any remain) // Then process wikilinks in [[...]] format (if any remain)
processedHtml = processWikilinks(processedHtml); processedHtml = processWikilinks(processedHtml);
// Then process nostr addresses (but not those already in links) // 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 processedHtml = fixStemBlocks(processedHtml); // Fix math blocks for MathJax
// Process image blocks to add reveal/enlarge functionality // Process image blocks to add reveal/enlarge functionality
processedHtml = processImageBlocks(processedHtml); processedHtml = processImageBlocks(processedHtml);

1
src/routes/my-notes/+page.svelte

@ -65,6 +65,7 @@
}); });
renderedContent[event.id] = await postProcessAsciidoctorHtml( renderedContent[event.id] = await postProcessAsciidoctorHtml(
html as string, html as string,
ndk,
); );
} }
// Collect unique tags by type // Collect unique tags by type

Loading…
Cancel
Save