react-markdown-table-ts 0.3.10 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +16 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +16 -7
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
@@ -4093,13 +4093,22 @@ function calculateColumnWidths(inputDataRows, maxColumnCount, minWidth, canRepla
|
|
4093
4093
|
// Retrieve the cell value; default to an empty string if undefined or null.
|
4094
4094
|
var cellValue = currentRow[columnIndex];
|
4095
4095
|
var cellString = cellValue !== null && cellValue !== undefined ? String(cellValue) : '';
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
4100
|
-
|
4101
|
-
|
4102
|
-
|
4096
|
+
if (canReplaceNewlines) {
|
4097
|
+
// Replace newlines with <br> and adjust the length accordingly
|
4098
|
+
var replacedString = cellString.replace(/\n/g, '<br>');
|
4099
|
+
var adjustedLength = replacedString.length;
|
4100
|
+
// Update the column width if the adjusted length is greater
|
4101
|
+
if (adjustedLength > columnWidths[columnIndex]) {
|
4102
|
+
columnWidths[columnIndex] = adjustedLength;
|
4103
|
+
}
|
4104
|
+
}
|
4105
|
+
else {
|
4106
|
+
// Replace newlines with a space and calculate the length
|
4107
|
+
cellString = cellString.replace(/\n/g, ' ');
|
4108
|
+
// Update the column width if the current cell's length is greater.
|
4109
|
+
if (cellString.length > columnWidths[columnIndex]) {
|
4110
|
+
columnWidths[columnIndex] = cellString.length;
|
4111
|
+
}
|
4103
4112
|
}
|
4104
4113
|
}
|
4105
4114
|
}
|