Add better support for markdown (switch nano-markdown for markdown-it as the former doesn't support backtick-code-formatting), add Markdown element. See #1929

This commit is contained in:
Pieter Vander Vennet 2024-04-27 22:44:35 +02:00
parent 9ead113555
commit d2e7bac775
10 changed files with 120 additions and 32 deletions

View file

@ -0,0 +1,17 @@
<script lang="ts">
import markdownit from "markdown-it"
import { UIEventSource } from "../../Logic/UIEventSource"
const md = markdownit()
export let src: string
export let srcWritable: UIEventSource<string> = undefined
srcWritable?.addCallbackAndRunD(t => {
src = t
})
if(typeof src !== "string") {
throw "Markdown.svelte got a non-string object"
}
</script>
{#if src?.length > 0}
{@html md.render(src)}
{/if}