@@ -76,15 +76,41 @@ function streamMessage(cssClass, text) {
7676 msg . classList . add ( "message" , cssClass ) ;
7777 chat . appendChild ( msg ) ;
7878
79- // Vervang **...** door <strong>...</strong>
80- const formattedText = text . replace ( / \* \* ( .* ?) \* \* / g, "<strong>$1</strong>" ) ;
79+ // **...** omzetten naar <strong>...</strong>
80+ let formattedText = text . replace ( / \* \* ( .* ?) \* \* / g, "<strong>$1</strong>" ) ;
81+
82+ // Inline bullets detecteren en splitsen
83+ if ( / (?: ^ | \s ) [ \- • * ] \s / . test ( formattedText ) ) {
84+ // Probeer bulletlijst uit inline te extraheren
85+ const parts = formattedText . split ( / (? = [ \- • * ] \s ) / g) ;
86+ if ( parts . length >= 2 ) {
87+ const intro = parts [ 0 ] . trim ( ) ;
88+ if ( intro ) {
89+ const p = document . createElement ( "p" ) ;
90+ p . innerHTML = intro ;
91+ msg . appendChild ( p ) ;
92+ }
93+
94+ const ul = document . createElement ( "ul" ) ;
95+ parts . slice ( 1 ) . forEach ( part => {
96+ const clean = part . replace ( / ^ [ - • * ] \s * / , "" ) . trim ( ) ;
97+ if ( clean ) {
98+ const li = document . createElement ( "li" ) ;
99+ li . innerHTML = clean ;
100+ ul . appendChild ( li ) ;
101+ }
102+ } ) ;
103+ msg . appendChild ( ul ) ;
104+ chat . scrollTop = chat . scrollHeight ;
105+ return ;
106+ }
107+ }
81108
82- // Detecteer inline genummerde lijst: "1. ..., 2. ..., 3. ..."
109+ // Inline genummerde lijst detecteren
83110 const listPattern = / (?: ^ | \s ) ( \d + \. \s .* ?) (? = \s \d + \. \s | $ ) / gs;
84111 const matches = [ ...formattedText . matchAll ( listPattern ) ] ;
85112
86113 if ( matches . length >= 2 ) {
87- // Introductietekst vóór de eerste lijst
88114 const introText = formattedText . split ( matches [ 0 ] [ 0 ] ) [ 0 ] . trim ( ) ;
89115 if ( introText ) {
90116 const p = document . createElement ( "p" ) ;
@@ -101,7 +127,7 @@ function streamMessage(cssClass, text) {
101127 } ) ;
102128 msg . appendChild ( ol ) ;
103129 } else {
104- // Geen inline genummerde lijst → toon tekst met stream effect
130+ // Geen lijst – gewoon streamen
105131 let index = 0 ;
106132 const interval = setInterval ( ( ) => {
107133 if ( index < formattedText . length ) {
0 commit comments