fix: csv
This commit is contained in:
parent
68d57ac049
commit
4839985154
|
|
@ -9,7 +9,7 @@ import type { MarkedExtension, Tokens } from "marked";
|
||||||
function tableToCSV(headers: string[], rows: string[][]): string {
|
function tableToCSV(headers: string[], rows: string[][]): string {
|
||||||
const escapeCell = (cell: string) => {
|
const escapeCell = (cell: string) => {
|
||||||
// 如果单元格包含逗号、换行或引号,需要转义
|
// 如果单元格包含逗号、换行或引号,需要转义
|
||||||
if (cell.includes(',') || cell.includes('\n') || cell.includes('"')) {
|
if (cell.includes(',') || cell.includes('\n') || cell.includes('"') || cell.includes("#")) {
|
||||||
return `"${cell.replace(/"/g, '""')}"`;
|
return `"${cell.replace(/"/g, '""')}"`;
|
||||||
}
|
}
|
||||||
return cell;
|
return cell;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue