diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e2b1e43..4c8da142 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [5.0.42](https://github.com/cpcloud/compare-commits-action/compare/v5.0.41...v5.0.42) (2024-10-22) + + +### Bug Fixes + +* **deps:** update dependency markdown-table to v3.0.4 ([ee9030a](https://github.com/cpcloud/compare-commits-action/commit/ee9030a485610adc17707e71f89bd9900bdb5ea2)) + ## [5.0.41](https://github.com/cpcloud/compare-commits-action/compare/v5.0.40...v5.0.41) (2024-10-05) diff --git a/dist/index.js b/dist/index.js index f89dba70..1aefcd6c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31591,19 +31591,18 @@ __nccwpck_require__.r(__webpack_exports__); /* harmony export */ __nccwpck_require__.d(__webpack_exports__, { /* harmony export */ markdownTable: () => (/* binding */ markdownTable) /* harmony export */ }); +// To do: next major: remove. +/** + * @typedef {Options} MarkdownTableOptions + * Configuration. + */ + /** * @typedef Options - * Configuration (optional). - * @property {string|null|ReadonlyArray} [align] - * One style for all columns, or styles for their respective columns. - * Each style is either `'l'` (left), `'r'` (right), or `'c'` (center). - * Other values are treated as `''`, which doesn’t place the colon in the - * alignment row but does align left. - * *Only the lowercased first character is used, so `Right` is fine.* - * @property {boolean} [padding=true] - * Whether to add a space of padding between delimiters and cells. - * - * When `true`, there is padding: + * Configuration. + * @property {boolean | null | undefined} [alignDelimiters=true] + * Whether to align the delimiters (default: `true`); + * they are aligned by default: * * ```markdown * | Alpha | B | @@ -31611,20 +31610,27 @@ __nccwpck_require__.r(__webpack_exports__); * | C | Delta | * ``` * - * When `false`, there is no padding: + * Pass `false` to make them staggered: * * ```markdown - * |Alpha|B | - * |-----|-----| - * |C |Delta| + * | Alpha | B | + * | - | - | + * | C | Delta | * ``` - * @property {boolean} [delimiterStart=true] - * Whether to begin each row with the delimiter. + * @property {ReadonlyArray | string | null | undefined} [align] + * How to align columns (default: `''`); + * one style for all columns or styles for their respective columns; + * each style is either `'l'` (left), `'r'` (right), or `'c'` (center); + * other values are treated as `''`, which doesn’t place the colon in the + * alignment row but does align left; + * *only the lowercased first character is used, so `Right` is fine.* + * @property {boolean | null | undefined} [delimiterEnd=true] + * Whether to end each row with the delimiter (default: `true`). * * > 👉 **Note**: please don’t use this: it could create fragile structures * > that aren’t understandable to some markdown parsers. * - * When `true`, there are starting delimiters: + * When `true`, there are ending delimiters: * * ```markdown * | Alpha | B | @@ -31632,20 +31638,20 @@ __nccwpck_require__.r(__webpack_exports__); * | C | Delta | * ``` * - * When `false`, there are no starting delimiters: + * When `false`, there are no ending delimiters: * * ```markdown - * Alpha | B | - * ----- | ----- | - * C | Delta | + * | Alpha | B + * | ----- | ----- + * | C | Delta * ``` - * @property {boolean} [delimiterEnd=true] - * Whether to end each row with the delimiter. + * @property {boolean | null | undefined} [delimiterStart=true] + * Whether to begin each row with the delimiter (default: `true`). * * > 👉 **Note**: please don’t use this: it could create fragile structures * > that aren’t understandable to some markdown parsers. * - * When `true`, there are ending delimiters: + * When `true`, there are starting delimiters: * * ```markdown * | Alpha | B | @@ -31653,16 +31659,18 @@ __nccwpck_require__.r(__webpack_exports__); * | C | Delta | * ``` * - * When `false`, there are no ending delimiters: + * When `false`, there are no starting delimiters: * * ```markdown - * | Alpha | B - * | ----- | ----- - * | C | Delta + * Alpha | B | + * ----- | ----- | + * C | Delta | * ``` - * @property {boolean} [alignDelimiters=true] - * Whether to align the delimiters. - * By default, they are aligned: + * @property {boolean | null | undefined} [padding=true] + * Whether to add a space of padding between delimiters and cells + * (default: `true`). + * + * When `true`, there is padding: * * ```markdown * | Alpha | B | @@ -31670,21 +31678,21 @@ __nccwpck_require__.r(__webpack_exports__); * | C | Delta | * ``` * - * Pass `false` to make them staggered: + * When `false`, there is no padding: * * ```markdown - * | Alpha | B | - * | - | - | - * | C | Delta | + * |Alpha|B | + * |-----|-----| + * |C |Delta| * ``` - * @property {(value: string) => number} [stringLength] - * Function to detect the length of table cell content. - * This is used when aligning the delimiters (`|`) between table cells. - * Full-width characters and emoji mess up delimiter alignment when viewing - * the markdown source. - * To fix this, you can pass this function, which receives the cell content - * and returns its “visible” size. - * Note that what is and isn’t visible depends on where the text is displayed. + * @property {((value: string) => number) | null | undefined} [stringLength] + * Function to detect the length of table cell content (optional); + * this is used when aligning the delimiters (`|`) between table cells; + * full-width characters and emoji mess up delimiter alignment when viewing + * the markdown source; + * to fix this, you can pass this function, + * which receives the cell content and returns its “visible” size; + * note that what is and isn’t visible depends on where the text is displayed. * * Without such a function, the following: * @@ -31731,23 +31739,32 @@ __nccwpck_require__.r(__webpack_exports__); */ /** - * @typedef {Options} MarkdownTableOptions - * @todo - * Remove next major. + * @param {string} value + * Cell value. + * @returns {number} + * Cell size. */ +function defaultStringLength(value) { + return value.length +} /** - * Generate a markdown ([GFM](https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables)) table.. + * Generate a markdown + * ([GFM](https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/organizing-information-with-tables)) + * table. * - * @param {ReadonlyArray>} table + * @param {ReadonlyArray>} table * Table data (matrix of strings). - * @param {Options} [options] + * @param {Readonly | null | undefined} [options] * Configuration (optional). * @returns {string} + * Result. */ -function markdownTable(table, options = {}) { - const align = (options.align || []).concat() - const stringLength = options.stringLength || defaultStringLength +function markdownTable(table, options) { + const settings = options || {} + // To do: next major: change to spread. + const align = (settings.align || []).concat() + const stringLength = settings.stringLength || defaultStringLength /** @type {Array} Character codes as symbols for alignment per column. */ const alignments = [] /** @type {Array>} Cells per row. */ @@ -31775,7 +31792,7 @@ function markdownTable(table, options = {}) { while (++columnIndex < table[rowIndex].length) { const cell = serialize(table[rowIndex][columnIndex]) - if (options.alignDelimiters !== false) { + if (settings.alignDelimiters !== false) { const size = stringLength(cell) sizes[columnIndex] = size @@ -31832,7 +31849,7 @@ function markdownTable(table, options = {}) { // There *must* be at least one hyphen-minus in each alignment cell. let size = - options.alignDelimiters === false + settings.alignDelimiters === false ? 1 : Math.max( 1, @@ -31841,7 +31858,7 @@ function markdownTable(table, options = {}) { const cell = before + '-'.repeat(size) + after - if (options.alignDelimiters !== false) { + if (settings.alignDelimiters !== false) { size = before.length + size + after.length if (size > longestCellByColumn[columnIndex]) { @@ -31874,7 +31891,7 @@ function markdownTable(table, options = {}) { let before = '' let after = '' - if (options.alignDelimiters !== false) { + if (settings.alignDelimiters !== false) { const size = longestCellByColumn[columnIndex] - (sizes[columnIndex] || 0) const code = alignments[columnIndex] @@ -31894,36 +31911,36 @@ function markdownTable(table, options = {}) { } } - if (options.delimiterStart !== false && !columnIndex) { + if (settings.delimiterStart !== false && !columnIndex) { line.push('|') } if ( - options.padding !== false && + settings.padding !== false && // Don’t add the opening space if we’re not aligning and the cell is // empty: there will be a closing space. - !(options.alignDelimiters === false && cell === '') && - (options.delimiterStart !== false || columnIndex) + !(settings.alignDelimiters === false && cell === '') && + (settings.delimiterStart !== false || columnIndex) ) { line.push(' ') } - if (options.alignDelimiters !== false) { + if (settings.alignDelimiters !== false) { line.push(before) } line.push(cell) - if (options.alignDelimiters !== false) { + if (settings.alignDelimiters !== false) { line.push(after) } - if (options.padding !== false) { + if (settings.padding !== false) { line.push(' ') } if ( - options.delimiterEnd !== false || + settings.delimiterEnd !== false || columnIndex !== mostCellsPerRow - 1 ) { line.push('|') @@ -31931,7 +31948,7 @@ function markdownTable(table, options = {}) { } lines.push( - options.delimiterEnd === false + settings.delimiterEnd === false ? line.join('').replace(/ +$/, '') : line.join('') ) @@ -31941,24 +31958,20 @@ function markdownTable(table, options = {}) { } /** - * @param {string|null|undefined} [value] + * @param {string | null | undefined} [value] + * Value to serialize. * @returns {string} + * Result. */ function serialize(value) { return value === null || value === undefined ? '' : String(value) } /** - * @param {string} value - * @returns {number} - */ -function defaultStringLength(value) { - return value.length -} - -/** - * @param {string|null|undefined} value + * @param {string | null | undefined} value + * Value. * @returns {number} + * Alignment. */ function toAlignment(value) { const code = typeof value === 'string' ? value.codePointAt(0) : 0 @@ -31966,10 +31979,10 @@ function toAlignment(value) { return code === 67 /* `C` */ || code === 99 /* `c` */ ? 99 /* `c` */ : code === 76 /* `L` */ || code === 108 /* `l` */ - ? 108 /* `l` */ - : code === 82 /* `R` */ || code === 114 /* `r` */ - ? 114 /* `r` */ - : 0 + ? 108 /* `l` */ + : code === 82 /* `R` */ || code === 114 /* `r` */ + ? 114 /* `r` */ + : 0 } diff --git a/dist/licenses.txt b/dist/licenses.txt index ff1028d4..4651a9bd 100644 --- a/dist/licenses.txt +++ b/dist/licenses.txt @@ -518,7 +518,7 @@ markdown-table MIT (The MIT License) -Copyright (c) 2014 Titus Wormer +Copyright (c) Titus Wormer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the