mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 19:30:38 +08:00
Handle absolute markdown links with leading slash
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
import markdown from "@app/lib/markdown";
|
||||
import { twemoji } from "@app/lib/utils";
|
||||
import { activeUnloadedRouteStore } from "@app/lib/router";
|
||||
import { Renderer } from "@app/lib/markdown";
|
||||
|
||||
export let content: string;
|
||||
@@ -13,7 +14,9 @@
|
||||
const render = (content: string): string =>
|
||||
dompurify.sanitize(
|
||||
markdown.parseInline(content, {
|
||||
renderer: new Renderer(undefined, stripEmphasizedStyling),
|
||||
renderer: new Renderer($activeUnloadedRouteStore, {
|
||||
stripEmphasizedStyling,
|
||||
}),
|
||||
}) as string,
|
||||
);
|
||||
</script>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
import ErrorModal from "@app/modals/ErrorModal.svelte";
|
||||
import markdown from "@app/lib/markdown";
|
||||
import { Renderer } from "@app/lib/markdown";
|
||||
import { activeUnloadedRouteStore } from "@app/lib/router";
|
||||
import { highlight } from "@app/lib/syntax";
|
||||
import {
|
||||
isUrl,
|
||||
@@ -22,8 +23,6 @@
|
||||
import { mimes } from "@app/lib/file";
|
||||
|
||||
export let content: string;
|
||||
// If present, resolve all relative links with respect to this URL
|
||||
export let linkBaseUrl: string | undefined = undefined;
|
||||
export let path: string = "/";
|
||||
export let rawPath: string;
|
||||
// If present, means we are in a preview context,
|
||||
@@ -63,7 +62,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Do internal navigation on for clicks on anchor elements if possible
|
||||
* Do internal navigation for clicks on anchor elements if possible
|
||||
*/
|
||||
function navigateInternalOnAnchor(event: MouseEvent) {
|
||||
if (router.useDefaultNavigation(event)) {
|
||||
@@ -94,7 +93,9 @@
|
||||
function render(content: string): string {
|
||||
return dompurify.sanitize(
|
||||
markdown.parse(content, {
|
||||
renderer: new Renderer(linkBaseUrl, false),
|
||||
renderer: new Renderer($activeUnloadedRouteStore, {
|
||||
stripEmphasizedStyling: false,
|
||||
}),
|
||||
breaks,
|
||||
}) as string,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user