Skip to content

Commit

Permalink
Rename pad option to alignDelimiters
Browse files Browse the repository at this point in the history
The previous name was very confusing.

Related to remarkjs/remark-lint#217.
  • Loading branch information
wooorm committed Jan 23, 2020
1 parent 40e7c79 commit 77ed1be
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -166,7 +166,7 @@ function markdownTable(table, options) {

index = -1

if (settings.pad !== false) {
if (settings.alignDelimiters !== false) {
while (++index < cellCount) {
value = cells[index]

Expand Down Expand Up @@ -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
Expand Down
21 changes: 17 additions & 4 deletions readme.md
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions test.js
Expand Up @@ -214,7 +214,7 @@ test('table()', function(t) {
['master', '0123456789abcdef'],
['staging', 'fedcba9876543210']
],
{pad: false}
{alignDelimiters: false}
),
[
'| Branch | Commit |',
Expand All @@ -233,7 +233,7 @@ test('table()', function(t) {
['staging', 'fedcba9876543210'],
['develop']
],
{pad: false}
{alignDelimiters: false}
),
[
'| A | |',
Expand Down

0 comments on commit 77ed1be

Please sign in to comment.