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.esm.js CHANGED
@@ -4085,13 +4085,22 @@ function calculateColumnWidths(inputDataRows, maxColumnCount, minWidth, canRepla
4085
4085
  // Retrieve the cell value; default to an empty string if undefined or null.
4086
4086
  var cellValue = currentRow[columnIndex];
4087
4087
  var cellString = cellValue !== null && cellValue !== undefined ? String(cellValue) : '';
4088
- // Replace newlines with the appropriate character based on canReplaceNewlines.
4089
- cellString = canReplaceNewlines
4090
- ? cellString.replace(/\n/g, '<br>')
4091
- : cellString.replace(/\n/g, ' ');
4092
- // Update the column width if the current cell's length is greater.
4093
- if (cellString.length > columnWidths[columnIndex]) {
4094
- columnWidths[columnIndex] = cellString.length;
4088
+ if (canReplaceNewlines) {
4089
+ // Replace newlines with <br> and adjust the length accordingly
4090
+ var replacedString = cellString.replace(/\n/g, '<br>');
4091
+ var adjustedLength = replacedString.length;
4092
+ // Update the column width if the adjusted length is greater
4093
+ if (adjustedLength > columnWidths[columnIndex]) {
4094
+ columnWidths[columnIndex] = adjustedLength;
4095
+ }
4096
+ }
4097
+ else {
4098
+ // Replace newlines with a space and calculate the length
4099
+ cellString = cellString.replace(/\n/g, ' ');
4100
+ // Update the column width if the current cell's length is greater.
4101
+ if (cellString.length > columnWidths[columnIndex]) {
4102
+ columnWidths[columnIndex] = cellString.length;
4103
+ }
4095
4104
  }
4096
4105
  }
4097
4106
  }