File tree Expand file tree Collapse file tree
components/chat/Messages/Markdown Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 import fileSaver from ' file-saver' ;
77 const { saveAs } = fileSaver ;
88
9- import { marked , type Token } from ' marked' ;
9+ import { type Token } from ' marked' ;
1010 import { copyToClipboard , unescapeHtml } from ' $lib/utils' ;
1111
1212 import { WEBUI_BASE_URL } from ' $lib/constants' ;
398398 <div class =" mb-1.5" slot =" content" >
399399 <svelte:self
400400 id ={` ${id }-${tokenIdx }-${detailIdx }-d ` }
401- tokens ={marked . lexer ( decode ( detailToken .text )) }
401+ tokens ={detailToken .tokens ?? [] }
402402 attributes ={detailToken ?.attributes }
403403 {done }
404404 {editCodeBlock }
445445 <div class =" mb-1.5" slot =" content" >
446446 <svelte:self
447447 id ={` ${id }-${tokenIdx }-d ` }
448- tokens ={marked . lexer ( decode ( token .text )) }
448+ tokens ={token .tokens ?? [] }
449449 attributes ={token ?.attributes }
450450 {done }
451451 {editCodeBlock }
Original file line number Diff line number Diff line change 1+ import { decode } from 'html-entities' ;
2+
13// Helper function to find matching closing tag
24function findMatchingClosingTag ( src : string , openTag : string , closeTag : string ) : number {
35 let depth = 1 ;
@@ -26,7 +28,7 @@ function parseAttributes(tag: string): { [key: string]: string } {
2628 return attributes ;
2729}
2830
29- function detailsTokenizer ( src : string ) {
31+ function detailsTokenizer ( this : any , src : string ) {
3032 // Updated regex to capture attributes inside <details>
3133 const detailsRegex = / ^ < d e t a i l s ( \s + [ ^ > ] * ) ? > \n / ;
3234 const summaryRegex = / ^ < s u m m a r y > ( .* ?) < \/ s u m m a r y > \n / ;
@@ -49,11 +51,15 @@ function detailsTokenizer(src: string) {
4951 content = content . slice ( summaryMatch [ 0 ] . length ) . trim ( ) ;
5052 }
5153
54+ const tokens : any [ ] = [ ] ;
55+ this . lexer . blockTokens ( decode ( content ) , tokens ) ;
56+
5257 return {
5358 type : 'details' ,
5459 raw : fullMatch ,
5560 summary : summary ,
5661 text : content ,
62+ tokens,
5763 attributes : attributes // Include extracted attributes from <details>
5864 } ;
5965 }
@@ -89,6 +95,6 @@ function detailsExtension() {
8995
9096export default function ( options = { } ) {
9197 return {
92- extensions : [ detailsExtension ( options ) ]
98+ extensions : [ detailsExtension ( ) ]
9399 } ;
94100}
You can’t perform that action at this time.
0 commit comments