+
{{ message.content ?? '' }}
+ + diff --git a/resources/scripts/utils/markdown.ts b/resources/scripts/utils/markdown.ts new file mode 100644 index 00000000..374102da --- /dev/null +++ b/resources/scripts/utils/markdown.ts @@ -0,0 +1,42 @@ +import { marked } from 'marked' +import DOMPurify from 'dompurify' + +/** + * Render a markdown string to safe, sanitized HTML. + * + * Used by the AI chat drawer to render assistant responses. Even though + * the AI provider controls the immediate source of the content, the model + * can echo anything it's fed — including user input from earlier in the + * conversation or tool results from the database. We therefore parse + * markdown → HTML via marked and then sanitize the result with DOMPurify + * before handing it to Vue's v-html. + * + * Marked is configured with: + * - gfm: true — GitHub-flavored markdown (tables, fenced code, + * strikethrough, task lists). Matches what users + * already expect from any modern chat UI. + * - breaks: true — newlines become