executablebooks/mdformat

`--wrap n` should respect tables

gwpl opened this issue · 2 comments

gwpl commented

Describe the bug

Seems like --wrap is breaking table structure.

Suggestion: --wrap should ignore wrapping tables.

Reproduce the bug

$ cat t.md 
# Table Test

| xxxxx | xxxxxxxxxxx x | xxxxxxxxxxx x | xxxxxxxxxxx x | xxxxxxxxxxxx | xxxxxxxx xxxxxxx |
| --- | --- | --- | --- | --- | --- |
| xxxxxxx xxxxxxxx xxxxxxxxxxxx | xx x | xx x | xx x | xx x | xx xxx |
| x xxxxxxxxx xx xxx | x x | xx x | xx x | xx x | xx xxx |
| x xxxxxxxxx xx xxx | x x | xx x | xx x | xx x | xx xxx |
| xxxxxxxx xxxxx xx xxx xxx | - | - | - | - | xxx xxx |
| x xxx x xxx xxx xxxxxxxx | - | - | x xxx/x | x xxx/x | - |

$ cat t.md | mdformat -  # without --wrap 60 seems fine
# Table Test

| xxxxx | xxxxxxxxxxx x | xxxxxxxxxxx x | xxxxxxxxxxx x | xxxxxxxxxxxx | xxxxxxxx xxxxxxx |
| --- | --- | --- | --- | --- | --- |
| xxxxxxx xxxxxxxx xxxxxxxxxxxx | xx x | xx x | xx x | xx x | xx xxx |
| x xxxxxxxxx xx xxx | x x | xx x | xx x | xx x | xx xxx |
| x xxxxxxxxx xx xxx | x x | xx x | xx x | xx x | xx xxx |
| xxxxxxxx xxxxx xx xxx xxx | - | - | - | - | xxx xxx |
| x xxx x xxx xxx xxxxxxxx | - | - | x xxx/x | x xxx/x | - |
$ cat t.md | mdformat --wrap 60 -  # with --wrap seems wrong
# Table Test

| xxxxx | xxxxxxxxxxx x | xxxxxxxxxxx x | xxxxxxxxxxx x |
xxxxxxxxxxxx | xxxxxxxx xxxxxxx | | --- | --- | --- | --- |
--- | --- | | xxxxxxx xxxxxxxx xxxxxxxxxxxx | xx x | xx x |
xx x | xx x | xx xxx | | x xxxxxxxxx xx xxx | x x | xx x |
xx x | xx x | xx xxx | | x xxxxxxxxx xx xxx | x x | xx x |
xx x | xx x | xx xxx | | xxxxxxxx xxxxx xx xxx xxx | - | - |
\- | - | xxx xxx | | x xxx x xxx xxx xxxxxxxx | - | - | x
xxx/x | x xxx/x | - |

List your environment

$ python --version
Python 3.10.10

Closing as duplicate of #393