react-markdown-table-ts 0.3.13 → 0.3.15
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 +9 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -10
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -4086,18 +4086,16 @@ function calculateColumnWidths(inputDataRows, maxColumnCount, minWidth, canRepla
|
|
4086
4086
|
var cellValue = currentRow[columnIndex];
|
4087
4087
|
var cellString = cellValue !== null && cellValue !== undefined ? String(cellValue) : '';
|
4088
4088
|
if (canReplaceNewlines) {
|
4089
|
-
//
|
4090
|
-
var
|
4091
|
-
|
4092
|
-
//
|
4093
|
-
|
4094
|
-
|
4095
|
-
if (maxLineLength > columnWidths[columnIndex]) {
|
4096
|
-
columnWidths[columnIndex] = maxLineLength;
|
4089
|
+
// Replace newlines with <br>, which increases the length by 3 per newline.
|
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;
|
4097
4095
|
}
|
4098
4096
|
}
|
4099
4097
|
else {
|
4100
|
-
// Replace newlines with
|
4098
|
+
// Replace newlines with a space and calculate the length.
|
4101
4099
|
cellString = cellString.replace(/\n/g, ' ');
|
4102
4100
|
// Update the column width if the current cell's length is greater.
|
4103
4101
|
if (cellString.length > columnWidths[columnIndex]) {
|
@@ -4106,6 +4104,7 @@ function calculateColumnWidths(inputDataRows, maxColumnCount, minWidth, canRepla
|
|
4106
4104
|
}
|
4107
4105
|
}
|
4108
4106
|
}
|
4107
|
+
console.log('Calculated Column Widths:', columnWidths); // Debug log
|
4109
4108
|
return columnWidths;
|
4110
4109
|
}
|
4111
4110
|
/**
|
@@ -4203,7 +4202,7 @@ function generateMarkdownTableString(inputData, columnAlignments, canAdjustColum
|
|
4203
4202
|
var maxColumnCount = Math.max.apply(Math, __spreadArray([headerColumnCount], bodyColumnCounts, false));
|
4204
4203
|
var columnWidths = canAdjustColumnWidths
|
4205
4204
|
? calculateColumnWidths(__spreadArray([inputData.inputTableHeader], inputData.inputTableBody, true), maxColumnCount, 3, // minWidth (you can change this value as needed)
|
4206
|
-
|
4205
|
+
replaceNewlines // Pass replaceNewlines here
|
4207
4206
|
)
|
4208
4207
|
: undefined;
|
4209
4208
|
var markdownHeaderRow = formatMarkdownTableBody(maxColumnCount, inputData.inputTableHeader, columnAlignments, columnWidths, useTabs, replaceNewlines);
|