Skip to content

Commit

Permalink
fix spacing issue in SafeMarkdown.vue file
Browse files Browse the repository at this point in the history
  • Loading branch information
cnorteye committed Dec 6, 2024
1 parent 6193453 commit aa9cd51
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion frontend/components/global/SafeMarkdown.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<VueMarkdown :source="sanitizeMarkdown(source)"></VueMarkdown>
<!-- Pass the preporcessed and sanitized Markdown source to VueMarkdown -->
<VueMarkdown :source="sanitizeMarkdown(preprocessMarkdown(source))"></VueMarkdown>
</template>

<script lang="ts">
Expand All @@ -19,6 +20,15 @@ export default defineComponent({
},
},
setup() {
// Preprocess the Markdown source to handle single-line breaks
function preprocessMarkdown(rawMarkdown: string | null | undefined): string {
if(!rawMarkdown) {
return "";
}
return rawMarkdown.replace(/\n/g, " <br>");
}
function sanitizeMarkdown(rawHtml: string | null | undefined): string {
if (!rawHtml) {
return "";
Expand All @@ -43,6 +53,7 @@ export default defineComponent({
}
return {
preprocessMarkdown,
sanitizeMarkdown,
};
},
Expand Down

0 comments on commit aa9cd51

Please sign in to comment.