@@ -2,11 +2,10 @@ import { type HTMLTemplateResult, html } from 'lit';
22import { unsafeHTML } from 'lit/directives/unsafe-html.js' ;
33import { marked } from 'marked' ;
44import DOMPurify from 'dompurify' ;
5- import { AIChatMessage } from '@microsoft/ai-chat-protocol' ;
5+ import { type AIChatMessage } from '@microsoft/ai-chat-protocol' ;
66
77export type ParsedMessage = {
88 html : HTMLTemplateResult ;
9- citations : string [ ] ;
109 followupQuestions : string [ ] ;
1110 role : string ;
1211 context ?: object ;
@@ -16,14 +15,12 @@ export function parseMessageIntoHtml(message: AIChatMessage, enableMarkdown = tr
1615 if ( message . role === 'user' ) {
1716 return {
1817 html : html `${ message . content } ` ,
19- citations : [ ] ,
2018 followupQuestions : [ ] ,
2119 role : message . role ,
2220 context : message . context ,
2321 } ;
2422 }
2523
26- const citations : string [ ] = [ ] ;
2724 const followupQuestions : string [ ] = [ ] ;
2825
2926 // Extract any follow-up questions that might be in the message
@@ -37,6 +34,7 @@ export function parseMessageIntoHtml(message: AIChatMessage, enableMarkdown = tr
3734
3835 let result ;
3936 if ( enableMarkdown ) {
37+ // Render markdown after sanitizing
4038 const md = marked . parse ( text , { async : false } ) as string ;
4139 const safe = DOMPurify . sanitize ( md , { USE_PROFILES : { html : true } } ) ;
4240 result = html `${ unsafeHTML ( safe ) } ` ;
@@ -46,7 +44,6 @@ export function parseMessageIntoHtml(message: AIChatMessage, enableMarkdown = tr
4644
4745 return {
4846 html : result ,
49- citations,
5047 followupQuestions,
5148 role : message . role ,
5249 context : message . context ,
0 commit comments