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.cjs.js
CHANGED
@@ -4094,18 +4094,16 @@ function calculateColumnWidths(inputDataRows, maxColumnCount, minWidth, canRepla
|
|
4094
4094
|
var cellValue = currentRow[columnIndex];
|
4095
4095
|
var cellString = cellValue !== null && cellValue !== undefined ? String(cellValue) : '';
|
4096
4096
|
if (canReplaceNewlines) {
|
4097
|
-
//
|
4098
|
-
var
|
4099
|
-
|
4100
|
-
//
|
4101
|
-
|
4102
|
-
|
4103
|
-
if (maxLineLength > columnWidths[columnIndex]) {
|
4104
|
-
columnWidths[columnIndex] = maxLineLength;
|
4097
|
+
// Replace newlines with <br>, which increases the length by 3 per newline.
|
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;
|
4105
4103
|
}
|
4106
4104
|
}
|
4107
4105
|
else {
|
4108
|
-
// Replace newlines with
|
4106
|
+
// Replace newlines with a space and calculate the length.
|
4109
4107
|
cellString = cellString.replace(/\n/g, ' ');
|
4110
4108
|
// Update the column width if the current cell's length is greater.
|
4111
4109
|
if (cellString.length > columnWidths[columnIndex]) {
|
@@ -4114,6 +4112,7 @@ function calculateColumnWidths(inputDataRows, maxColumnCount, minWidth, canRepla
|
|
4114
4112
|
}
|
4115
4113
|
}
|
4116
4114
|
}
|
4115
|
+
console.log('Calculated Column Widths:', columnWidths); // Debug log
|
4117
4116
|
return columnWidths;
|
4118
4117
|
}
|
4119
4118
|
/**
|
@@ -4211,7 +4210,7 @@ function generateMarkdownTableString(inputData, columnAlignments, canAdjustColum
|
|
4211
4210
|
var maxColumnCount = Math.max.apply(Math, __spreadArray([headerColumnCount], bodyColumnCounts, false));
|
4212
4211
|
var columnWidths = canAdjustColumnWidths
|
4213
4212
|
? calculateColumnWidths(__spreadArray([inputData.inputTableHeader], inputData.inputTableBody, true), maxColumnCount, 3, // minWidth (you can change this value as needed)
|
4214
|
-
|
4213
|
+
replaceNewlines // Pass replaceNewlines here
|
4215
4214
|
)
|
4216
4215
|
: undefined;
|
4217
4216
|
var markdownHeaderRow = formatMarkdownTableBody(maxColumnCount, inputData.inputTableHeader, columnAlignments, columnWidths, useTabs, replaceNewlines);
|