diff --git a/src/modules/chatbot/components/dialogue-phrase.vue b/src/modules/chatbot/components/dialogue-phrase.vue index 042117f..d196ae5 100644 --- a/src/modules/chatbot/components/dialogue-phrase.vue +++ b/src/modules/chatbot/components/dialogue-phrase.vue @@ -9,7 +9,7 @@ const props = defineProps<{ // Initialize Markdown parser const md = new MarkdownIt({ - breaks: true, // Support line breaks + breaks: false, // Support line breaks linkify: true, // Make URLs clickable html: false // Prevent raw HTML injection }) @@ -17,7 +17,11 @@ const md = new MarkdownIt({ // Removes all the h1,h2,h3 to make the Md more user friendly const cleanMarkdown = (markdown: string): string => { if (!markdown) return '' - return markdown.replace(/^#{1,3}\s(.*)$/gm, '#### $1') + return markdown + .replace(/\r\n/g, '\n') // normalize Windows line endings + .replace(/([.!?])(\s+)(?=[A-Z])/g, '$1\n') // insert line break after sentence-ending punctuation + .replace(/\n{3,}/g, '\n\n') // squash triple+ line breaks + .replace(/^#{1,3}\s(.*)$/gm, '#### $1') // downgrade headings } // Compute parsed content