mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
@@ -8,7 +8,7 @@
|
||||
export let fontSize: "tiny" | "small" | "medium" = "small";
|
||||
|
||||
const render = (content: string): string =>
|
||||
dompurify.sanitize(markdown.parseInline(content));
|
||||
dompurify.sanitize(markdown.parseInline(content) as string);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -53,7 +53,9 @@
|
||||
|
||||
function render(content: string): string {
|
||||
return dompurify.sanitize(
|
||||
markdown.parse(content, { renderer: new Renderer(linkBaseUrl) }),
|
||||
markdown.parse(content, {
|
||||
renderer: new Renderer(linkBaseUrl),
|
||||
}) as string,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+5
-9
@@ -1,4 +1,4 @@
|
||||
import type { marked } from "marked";
|
||||
import type { Tokens } from "marked";
|
||||
|
||||
import dompurify from "dompurify";
|
||||
import katexMarkedExtension from "marked-katex-extension";
|
||||
@@ -28,7 +28,7 @@ const emojisMarkedExtension = {
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer: (token: marked.Tokens.Generic): string =>
|
||||
renderer: (token: Tokens.Generic): string =>
|
||||
`<span>${token.text in emojis ? emojis[token.text] : token.text}</span>`,
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ const footnoteReferenceMarkedExtension = {
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer: (token: marked.Tokens.Generic): string =>
|
||||
renderer: (token: Tokens.Generic): string =>
|
||||
`<sup class="footnote-ref" id="${referencePrefix}:${token.text}"><a href="#${footnotePrefix}:${token.text}">[${token.text}]</a></sup>`,
|
||||
};
|
||||
const footnoteMatch = /^\[\^([^\]]+)\]:\s([\S]*)/;
|
||||
@@ -69,7 +69,7 @@ const footnoteMarkedExtension = {
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer: (token: marked.Tokens.Generic): string =>
|
||||
renderer: (token: Tokens.Generic): string =>
|
||||
`${
|
||||
token.reference === "0" ? "<hr />" : ""
|
||||
}<p class="txt-small" id="${footnotePrefix}:${token.reference}">${
|
||||
@@ -97,8 +97,7 @@ const anchorMarkedExtension = {
|
||||
};
|
||||
}
|
||||
},
|
||||
renderer: (token: marked.Tokens.Generic): string =>
|
||||
`<a name="${token.text}"></a>`,
|
||||
renderer: (token: Tokens.Generic): string => `<a name="${token.text}"></a>`,
|
||||
};
|
||||
|
||||
export class Renderer extends BaseRenderer {
|
||||
@@ -151,9 +150,6 @@ const markedInstance = new Marked(
|
||||
footnoteReferenceMarkedExtension,
|
||||
anchorMarkedExtension,
|
||||
],
|
||||
// TODO: Disables deprecated options, remove once removed from marked
|
||||
mangle: false,
|
||||
headerIds: false,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
export let baseUrl: BaseUrl;
|
||||
export let peer: string | undefined = undefined;
|
||||
export let project: Project;
|
||||
|
||||
const render = (content: string): string =>
|
||||
dompurify.sanitize(markdown.parse(content) as string);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -122,7 +125,7 @@
|
||||
</div>
|
||||
|
||||
<div class="description" use:twemoji>
|
||||
{@html dompurify.sanitize(markdown.parse(project.description))}
|
||||
{@html render(project.description)}
|
||||
</div>
|
||||
|
||||
<Header {project} {activeTab} {baseUrl} />
|
||||
|
||||
Reference in New Issue
Block a user