-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
95 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
<script setup lang="ts"> | ||
defineProps<{ | ||
const props = defineProps<{ | ||
notes?: string[] | ||
}>() | ||
const html = computed(() => renderMarkdown(props.notes?.join('\n') || '')) | ||
</script> | ||
|
||
<template> | ||
<div | ||
v-if="notes?.length" | ||
flex="~ col gap-2 justify-end auto" | ||
of-auto text-xs text-hex-888 | ||
> | ||
<div border="t base" my1 h-1px w-30px /> | ||
<div v-if="notes?.length" break-words text-sm> | ||
<div v-for="line, idx of notes" :key="idx"> | ||
{{ line }} | ||
</div> | ||
</div> | ||
<div | ||
break-words text-sm class="markdown-content" | ||
v-html="html" | ||
/> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import MarkdownIt from 'markdown-it' | ||
import Sanitize from 'sanitize-html' | ||
|
||
let md: MarkdownIt | null = null | ||
|
||
export function renderMarkdown( | ||
text: string, | ||
) { | ||
if (!md) { | ||
md = new MarkdownIt({ | ||
// To be safe from XSS, we disable HTML tags | ||
xhtmlOut: false, | ||
html: false, | ||
linkify: true, | ||
breaks: true, | ||
typographer: true, | ||
}) | ||
} | ||
|
||
return Sanitize(md.render(text)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.