react-markdown-table-ts 0.6.0 → 0.6.1
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 +20 -21
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +20 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/utils.d.ts +0 -10
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
@@ -4195,35 +4195,34 @@ function formatAlignmentRow(columnCount, columnAlignments, columnWidths, useTabs
|
|
4195
4195
|
}
|
4196
4196
|
return alignmentRow;
|
4197
4197
|
}
|
4198
|
-
|
4199
|
-
* Generates a complete Markdown table string from the provided data.
|
4200
|
-
* @param inputData - The table data including headers and rows.
|
4201
|
-
* @param columnAlignments - Alignment settings for each column.
|
4202
|
-
* @param canAdjustColumnWidths - Flag to adjust column widths based on content.
|
4203
|
-
* @param useTabs - Flag to use tabs between columns.
|
4204
|
-
* @param replaceNewlines - Flag to replace newlines with <br> tags.
|
4205
|
-
* @param hasPadding - Flag to add padding spaces around cell content.
|
4206
|
-
* @returns The complete Markdown table string.
|
4207
|
-
*/
|
4208
|
-
function generateMarkdownTableString(inputData, columnAlignments, canAdjustColumnWidths, useTabs, replaceNewlines, hasPadding) {
|
4209
|
-
if (canAdjustColumnWidths === void 0) { canAdjustColumnWidths = true; }
|
4210
|
-
if (useTabs === void 0) { useTabs = false; }
|
4211
|
-
if (replaceNewlines === void 0) { replaceNewlines = false; }
|
4212
|
-
if (hasPadding === void 0) { hasPadding = true; }
|
4198
|
+
function calculateMaxColumnCount(inputData) {
|
4213
4199
|
var headerColumnCount = inputData.inputDataHeader.length;
|
4214
4200
|
var bodyColumnCounts = inputData.inputDataBody.map(function (currentRow) { return currentRow.length; });
|
4215
|
-
|
4216
|
-
|
4201
|
+
return Math.max.apply(Math, __spreadArray([headerColumnCount], bodyColumnCounts, false));
|
4202
|
+
}
|
4203
|
+
function getColumnWidths(inputData, maxColumnCount, canAdjustColumnWidths) {
|
4204
|
+
return canAdjustColumnWidths
|
4217
4205
|
? calculateColumnWidths(__spreadArray([inputData.inputDataHeader], inputData.inputDataBody, true), maxColumnCount)
|
4218
4206
|
: undefined;
|
4219
|
-
|
4220
|
-
|
4221
|
-
var
|
4207
|
+
}
|
4208
|
+
function formatTableRows(inputData, maxColumnCount, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding) {
|
4209
|
+
var headerRow = formatMarkdownRow(maxColumnCount, inputData.inputDataHeader, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding);
|
4210
|
+
var alignmentRow = formatAlignmentRow(maxColumnCount, columnAlignments, columnWidths, useTabs, hasPadding);
|
4211
|
+
var bodyRows = inputData.inputDataBody
|
4222
4212
|
.map(function (currentRow) {
|
4223
4213
|
return formatMarkdownRow(maxColumnCount, currentRow, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding);
|
4224
4214
|
})
|
4225
4215
|
.join('\n');
|
4226
|
-
return "".concat(
|
4216
|
+
return "".concat(headerRow, "\n").concat(alignmentRow, "\n").concat(bodyRows);
|
4217
|
+
}
|
4218
|
+
function generateMarkdownTableString(inputData, columnAlignments, canAdjustColumnWidths, useTabs, replaceNewlines, hasPadding) {
|
4219
|
+
if (canAdjustColumnWidths === void 0) { canAdjustColumnWidths = true; }
|
4220
|
+
if (useTabs === void 0) { useTabs = false; }
|
4221
|
+
if (replaceNewlines === void 0) { replaceNewlines = false; }
|
4222
|
+
if (hasPadding === void 0) { hasPadding = true; }
|
4223
|
+
var maxColumnCount = calculateMaxColumnCount(inputData);
|
4224
|
+
var columnWidths = getColumnWidths(inputData, maxColumnCount, canAdjustColumnWidths);
|
4225
|
+
return formatTableRows(inputData, maxColumnCount, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding).trimEnd();
|
4227
4226
|
}
|
4228
4227
|
/**
|
4229
4228
|
* Replaces newline characters in a string with <br> tags.
|