mirror of
https://github.com/discourse/discourse-table-builder.git
synced 2026-09-17 07:12:13 -04:00
FIX: Remove linebreaks from cell data (#48)
Pasting text with linebreaks into the table UI results in incorrectly generated table markdown. This fix strips linebreaks from text during table markdown generation.
This commit is contained in:
@@ -33,13 +33,14 @@ export function arrayToTable(array, cols, colPrefix = "col") {
|
||||
table +=
|
||||
cols
|
||||
.map(function (_key, index) {
|
||||
return String(item[`${colPrefix}${index}`] || "");
|
||||
return String(item[`${colPrefix}${index}`] || "").replace(
|
||||
/\r?\n|\r/g,
|
||||
" "
|
||||
);
|
||||
})
|
||||
.join(" | ") + "|\r\n";
|
||||
});
|
||||
|
||||
// Return table
|
||||
console.log(table);
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user