react-markdown-table-ts 0.3.10 → 0.3.11
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 +18 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +18 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -4086,12 +4086,24 @@ function calculateColumnWidths(inputDataRows, maxColumnCount, minWidth, canRepla
|
|
4086
4086
|
var cellValue = currentRow[columnIndex];
|
4087
4087
|
var cellString = cellValue !== null && cellValue !== undefined ? String(cellValue) : '';
|
4088
4088
|
// Replace newlines with the appropriate character based on canReplaceNewlines.
|
4089
|
-
|
4090
|
-
|
4091
|
-
|
4092
|
-
|
4093
|
-
|
4094
|
-
|
4089
|
+
if (canReplaceNewlines) {
|
4090
|
+
// If replacing newlines with <br>, account for its extra length (4 characters)
|
4091
|
+
var newlineCount = (cellString.match(/\n/g) || []).length;
|
4092
|
+
cellString = cellString.replace(/\n/g, '<br>');
|
4093
|
+
var additionalLength = newlineCount * ('<br>'.length - 1); // Add extra 3 characters for each newline
|
4094
|
+
var adjustedLength = cellString.length + additionalLength;
|
4095
|
+
// Update column width considering the extra length due to <br>
|
4096
|
+
if (adjustedLength > columnWidths[columnIndex]) {
|
4097
|
+
columnWidths[columnIndex] = adjustedLength;
|
4098
|
+
}
|
4099
|
+
}
|
4100
|
+
else {
|
4101
|
+
// Replace newlines with a space if not using <br>
|
4102
|
+
cellString = cellString.replace(/\n/g, ' ');
|
4103
|
+
// Update the column width if the current cell's length is greater.
|
4104
|
+
if (cellString.length > columnWidths[columnIndex]) {
|
4105
|
+
columnWidths[columnIndex] = cellString.length;
|
4106
|
+
}
|
4095
4107
|
}
|
4096
4108
|
}
|
4097
4109
|
}
|