File tree Expand file tree Collapse file tree
src/lib/components/chat/Messages/Markdown Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5353 const exportTableToCSVHandler = (token , tokenIdx = 0 ) => {
5454 console .log (' Exporting table to CSV' );
5555
56- // Extract header row text and escape for CSV.
57- const header = token .header .map ((headerCell ) => ` "${headerCell .text .replace (/ "/ g , ' ""' )}" ` );
56+ // Extract header row text, decode HTML entities, and escape for CSV.
57+ const header = token .header .map ((headerCell ) => ` "${decode ( headerCell .text ) .replace (/ "/ g , ' ""' )}" ` );
5858
5959 // Create an array for rows that will hold the mapped cell text.
6060 const rows = token .rows .map ((row ) =>
6161 row .map ((cell ) => {
6262 // Map tokens into a single text
6363 const cellContent = cell .tokens .map ((token ) => token .text ).join (' ' );
64- // Escape double quotes and wrap the content in double quotes
65- return ` "${cellContent .replace (/ "/ g , ' ""' )}" ` ;
64+ // Decode HTML entities and escape double quotes, wrap in double quotes
65+ return ` "${decode ( cellContent ) .replace (/ "/ g , ' ""' )}" ` ;
6666 })
6767 );
6868
You can’t perform that action at this time.
0 commit comments