From 77ed1be8e6b50957c9e4ac5832af1698fe4eb57e Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 23 Jan 2020 13:35:51 +0100 Subject: [PATCH] Rename `pad` option to `alignDelimiters` The previous name was very confusing. Related to remarkjs/remark-lint#217. --- index.js | 4 ++-- readme.md | 21 +++++++++++++++++---- test.js | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 9a94af5..0249ecc 100644 --- a/index.js +++ b/index.js @@ -166,7 +166,7 @@ function markdownTable(table, options) { index = -1 - if (settings.pad !== false) { + if (settings.alignDelimiters !== false) { while (++index < cellCount) { value = cells[index] @@ -204,7 +204,7 @@ function markdownTable(table, options) { while (++index < cellCount) { // When `pad` is false, make the rule the same size as the first row. - if (settings.pad === false) { + if (settings.alignDelimiters === false) { value = table[0][index] spacing = calculateStringLength(stringify(value)) spacing = spacing > minCellSize ? spacing : minCellSize diff --git a/readme.md b/readme.md index 7ff942a..be51f52 100644 --- a/readme.md +++ b/readme.md @@ -134,11 +134,24 @@ function stringLength(cell) { } ``` -###### `options.pad` +###### `options.alignDelimiters` -Whether to pad the markdown for table cells to make them the same width -(`boolean`, default: `true`). -Setting this to `false` will cause the table rows to remain staggered. +Whether to align the delimiters (`boolean`, default: `true`). +By default, they are aligned: + +```markdown +| Alpha | B | +| ----- | ----- | +| C | Delta | +``` + +Pass `false` to make them staggered: + +```markdown +| Alpha | B | +| - | - | +| C | Delta | +``` ## Inspiration diff --git a/test.js b/test.js index f467ecf..94bd1d7 100644 --- a/test.js +++ b/test.js @@ -214,7 +214,7 @@ test('table()', function(t) { ['master', '0123456789abcdef'], ['staging', 'fedcba9876543210'] ], - {pad: false} + {alignDelimiters: false} ), [ '| Branch | Commit |', @@ -233,7 +233,7 @@ test('table()', function(t) { ['staging', 'fedcba9876543210'], ['develop'] ], - {pad: false} + {alignDelimiters: false} ), [ '| A | |',