mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 22:30:41 +08:00
Replace marked namespaces with Marked instance
Based on a new addition to marked, this commits replaces the imported marked namespaces with a Marked class, that doesn't change when `marked.use` introduces new options or extensions. Also changes the naming slighty to use `markdown` as module, so it sounds more generic. Reference: https://github.com/markedjs/marked/pull/2831 Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
<script lang="ts">
|
||||
import dompurify from "dompurify";
|
||||
import { marked } from "marked";
|
||||
|
||||
import markdown from "@app/lib/markdown";
|
||||
import { twemoji } from "@app/lib/utils";
|
||||
|
||||
export let content: string;
|
||||
export let fontSize: "tiny" | "small" | "medium" = "small";
|
||||
|
||||
const render = (content: string): string =>
|
||||
dompurify.sanitize(marked.parseInline(content));
|
||||
dompurify.sanitize(markdown.parseInline(content));
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
import dompurify from "dompurify";
|
||||
import matter from "@radicle/gray-matter";
|
||||
import { afterUpdate } from "svelte";
|
||||
import { marked } from "marked";
|
||||
import { toDom } from "hast-util-to-dom";
|
||||
|
||||
import * as router from "@app/lib/router";
|
||||
import markdown from "@app/lib/markdown";
|
||||
import { Renderer } from "@app/lib/markdown";
|
||||
import { highlight } from "@app/lib/syntax";
|
||||
import { isUrl, twemoji, scrollIntoView, canonicalize } from "@app/lib/utils";
|
||||
import { Renderer } from "@app/lib/markdown";
|
||||
|
||||
export let content: string;
|
||||
// If present, resolve all relative links with respect to this URL
|
||||
@@ -53,12 +53,7 @@
|
||||
|
||||
function render(content: string): string {
|
||||
return dompurify.sanitize(
|
||||
marked.parse(content, {
|
||||
renderer: new Renderer(linkBaseUrl),
|
||||
// TODO: Disables deprecated options, remove once removed from marked
|
||||
mangle: false,
|
||||
headerIds: false,
|
||||
}),
|
||||
markdown.parse(content, { renderer: new Renderer(linkBaseUrl) }),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user