Skip to content

Commit

Permalink
raw html should be allowed in description
Browse files Browse the repository at this point in the history
  • Loading branch information
mogorman committed Nov 25, 2024
1 parent 870f073 commit d49426a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/views/nodes/View.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<script lang="ts">
import type { BaseUrl, Node, NodeStats } from "@http-client";
import dompurify from "dompurify";
import * as router from "@app/lib/router";
import { baseUrlToString } from "@app/lib/utils";
import { fetchRepoInfos } from "@app/components/RepoCard";
import { handleError } from "@app/views/nodes/error";
import { Renderer, markdownWithExtensions } from "@app/lib/markdown";
import { activeUnloadedRouteStore } from "@app/lib/router";
import Settings from "@app/App/Settings.svelte";
Expand All @@ -29,6 +32,8 @@
export let baseUrl: BaseUrl;
export let stats: NodeStats;
export let node: Node;
// If true, add <br> on a single line break
export let breaks: boolean = false;
let scrollY: number;
let top: number;
Expand All @@ -42,6 +47,15 @@
$: background = node.bannerUrl
? `url("${node.bannerUrl}")`
: `url("/images/default-seed-header.png")`;
function render(content: string): string {
return dompurify.sanitize(
markdownWithExtensions.parse(content, {
renderer: new Renderer($activeUnloadedRouteStore),
breaks,
}) as string,
);
}
</script>

<style>
Expand Down Expand Up @@ -274,7 +288,7 @@
</div>
{#if node.description}
<div class="description txt-small">
{node.description}
{@html render(node.description)}
</div>
{:else}
<div
Expand Down Expand Up @@ -398,7 +412,7 @@
style:gap="0.25rem">
{#if node.description}
<div class="description txt-small">
{node.description}
{@html render(node.description)}
</div>
{/if}
</div>
Expand Down

0 comments on commit d49426a

Please sign in to comment.