fix-csv-export (#20688)
This commit is contained in:
@@ -53,16 +53,16 @@
|
|||||||
const exportTableToCSVHandler = (token, tokenIdx = 0) => {
|
const exportTableToCSVHandler = (token, tokenIdx = 0) => {
|
||||||
console.log('Exporting table to CSV');
|
console.log('Exporting table to CSV');
|
||||||
|
|
||||||
// Extract header row text and escape for CSV.
|
// Extract header row text, decode HTML entities, and escape for CSV.
|
||||||
const header = token.header.map((headerCell) => `"${headerCell.text.replace(/"/g, '""')}"`);
|
const header = token.header.map((headerCell) => `"${decode(headerCell.text).replace(/"/g, '""')}"`);
|
||||||
|
|
||||||
// Create an array for rows that will hold the mapped cell text.
|
// Create an array for rows that will hold the mapped cell text.
|
||||||
const rows = token.rows.map((row) =>
|
const rows = token.rows.map((row) =>
|
||||||
row.map((cell) => {
|
row.map((cell) => {
|
||||||
// Map tokens into a single text
|
// Map tokens into a single text
|
||||||
const cellContent = cell.tokens.map((token) => token.text).join('');
|
const cellContent = cell.tokens.map((token) => token.text).join('');
|
||||||
// Escape double quotes and wrap the content in double quotes
|
// Decode HTML entities and escape double quotes, wrap in double quotes
|
||||||
return `"${cellContent.replace(/"/g, '""')}"`;
|
return `"${decode(cellContent).replace(/"/g, '""')}"`;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user