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 @@ @@ -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 @@ @@ -30,6 +31,7 @@
} = $props();
const asciidoctor: Asciidoctor = getContext("asciidoctor");
const ndk: NDK = getContext("ndk");
let leafEvent: Promise<NDKEvent | null> = $derived.by(
async () => await publicationTree.getEvent(address),
@ -62,7 +64,7 @@ @@ -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;
}
});

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

@ -1,3 +1,4 @@ @@ -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"; @@ -10,11 +11,12 @@ import plantumlEncoder from "plantuml-encoder";
*/
export async function postProcessAdvancedAsciidoctorHtml(
html: string,
ndk?: NDK,
): Promise<string> {
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

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

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
import NDK from "@nostr-dev-kit/ndk";
import {
processAsciiDocAnchors,
processImageWithReveal,
@ -54,6 +55,7 @@ function fixStemBlocks(html: string): string { @@ -54,6 +55,7 @@ function fixStemBlocks(html: string): string {
*/
export async function postProcessAsciidoctorHtml(
html: string,
ndk?: NDK,
): Promise<string> {
if (!html) return html;
@ -63,7 +65,7 @@ export async function postProcessAsciidoctorHtml( @@ -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);

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

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

Loading…
Cancel
Save