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.esm.js
CHANGED
@@ -4168,35 +4168,34 @@ function formatAlignmentRow(columnCount, columnAlignments, columnWidths, useTabs
|
|
4168
4168
|
}
|
4169
4169
|
return alignmentRow;
|
4170
4170
|
}
|
4171
|
-
|
4172
|
-
* Generates a complete Markdown table string from the provided data.
|
4173
|
-
* @param inputData - The table data including headers and rows.
|
4174
|
-
* @param columnAlignments - Alignment settings for each column.
|
4175
|
-
* @param canAdjustColumnWidths - Flag to adjust column widths based on content.
|
4176
|
-
* @param useTabs - Flag to use tabs between columns.
|
4177
|
-
* @param replaceNewlines - Flag to replace newlines with <br> tags.
|
4178
|
-
* @param hasPadding - Flag to add padding spaces around cell content.
|
4179
|
-
* @returns The complete Markdown table string.
|
4180
|
-
*/
|
4181
|
-
function generateMarkdownTableString(inputData, columnAlignments, canAdjustColumnWidths, useTabs, replaceNewlines, hasPadding) {
|
4182
|
-
if (canAdjustColumnWidths === void 0) { canAdjustColumnWidths = true; }
|
4183
|
-
if (useTabs === void 0) { useTabs = false; }
|
4184
|
-
if (replaceNewlines === void 0) { replaceNewlines = false; }
|
4185
|
-
if (hasPadding === void 0) { hasPadding = true; }
|
4171
|
+
function calculateMaxColumnCount(inputData) {
|
4186
4172
|
var headerColumnCount = inputData.inputDataHeader.length;
|
4187
4173
|
var bodyColumnCounts = inputData.inputDataBody.map(function (currentRow) { return currentRow.length; });
|
4188
|
-
|
4189
|
-
|
4174
|
+
return Math.max.apply(Math, __spreadArray([headerColumnCount], bodyColumnCounts, false));
|
4175
|
+
}
|
4176
|
+
function getColumnWidths(inputData, maxColumnCount, canAdjustColumnWidths) {
|
4177
|
+
return canAdjustColumnWidths
|
4190
4178
|
? calculateColumnWidths(__spreadArray([inputData.inputDataHeader], inputData.inputDataBody, true), maxColumnCount)
|
4191
4179
|
: undefined;
|
4192
|
-
|
4193
|
-
|
4194
|
-
var
|
4180
|
+
}
|
4181
|
+
function formatTableRows(inputData, maxColumnCount, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding) {
|
4182
|
+
var headerRow = formatMarkdownRow(maxColumnCount, inputData.inputDataHeader, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding);
|
4183
|
+
var alignmentRow = formatAlignmentRow(maxColumnCount, columnAlignments, columnWidths, useTabs, hasPadding);
|
4184
|
+
var bodyRows = inputData.inputDataBody
|
4195
4185
|
.map(function (currentRow) {
|
4196
4186
|
return formatMarkdownRow(maxColumnCount, currentRow, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding);
|
4197
4187
|
})
|
4198
4188
|
.join('\n');
|
4199
|
-
return "".concat(
|
4189
|
+
return "".concat(headerRow, "\n").concat(alignmentRow, "\n").concat(bodyRows);
|
4190
|
+
}
|
4191
|
+
function generateMarkdownTableString(inputData, columnAlignments, canAdjustColumnWidths, useTabs, replaceNewlines, hasPadding) {
|
4192
|
+
if (canAdjustColumnWidths === void 0) { canAdjustColumnWidths = true; }
|
4193
|
+
if (useTabs === void 0) { useTabs = false; }
|
4194
|
+
if (replaceNewlines === void 0) { replaceNewlines = false; }
|
4195
|
+
if (hasPadding === void 0) { hasPadding = true; }
|
4196
|
+
var maxColumnCount = calculateMaxColumnCount(inputData);
|
4197
|
+
var columnWidths = getColumnWidths(inputData, maxColumnCount, canAdjustColumnWidths);
|
4198
|
+
return formatTableRows(inputData, maxColumnCount, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding).trimEnd();
|
4200
4199
|
}
|
4201
4200
|
/**
|
4202
4201
|
* Replaces newline characters in a string with <br> tags.
|