Files
radicle-explorer/desktop/src/components/InlineTitle.svelte
T
Rūdolfs Ošiņš 983fff9006 Move everything into desktop/
In preparation for merging radicle-desktop into radicle-gui. It's a pure rename, so git can follow every file across the move.
2026-10-12 08:41:12 +02:00

39 lines
1.0 KiB
Svelte

<script lang="ts">
import dompurify from "dompurify";
import escape from "lodash/escape";
import { sanitizeConfig } from "@app/lib/markdown";
interface Props {
content: string;
fontSize?: "tiny" | "small" | "regular" | "medium" | "large";
}
const { content, fontSize = "small" }: Props = $props();
function formatInlineTitle(input: string): string {
return input
.replaceAll(/`([^`]+)`/g, "<code>$1</code>")
.replaceAll(/~~([^~~]+)~~/g, "<del>$1</del>");
}
</script>
<style>
.content :global(code) {
font-family: monospace;
padding: 0.125rem 0.25rem;
background-color: var(--color-surface-subtle);
font-size: inherit;
}
</style>
<span
class="content"
class:txt-heading-l={fontSize === "large"}
class:txt-heading-m={fontSize === "medium"}
class:txt-body-l-regular={fontSize === "regular"}
class:txt-body-m-regular={fontSize === "small"}
class:txt-body-s-regular={fontSize === "tiny"}>
{@html dompurify.sanitize(formatInlineTitle(escape(content)), sanitizeConfig)}
</span>