dprint / dprint-plugin-markdown

Markdown code formatting plugin for dprint.
MIT License
25 stars 9 forks source link

lineWidth is ignored, lines are not broken up #103

Open SuperFluffy opened 5 months ago

SuperFluffy commented 5 months ago

It seems like the lineWidth setting is completely ignored. Very long lines exceeding it are not broken up, see the playground here: playground

dprint-plugin-markdown version: 0.16.4

Input Code

# Section

The number of characters of this line exceeeds the configured `"lineWidth": 80`. `dprint` should have inserted a newline after the dot, breaking it up.

Expected Output

# Section

The number of characters of this line exceeeds the configured `"lineWidth": 80`.
`dprint` should have inserted a newline after the dot, breaking it up.

Actual Output

# Section

The number of characters of this line exceeeds the configured `"lineWidth": 80`. `dprint` should have inserted a newline after the dot, breaking it up.
dsherret commented 5 months ago

Change "textWrap": "maintain" to "textWrap": "always":

https://dprint.dev/playground/#code/MQAgygpgxgLglgewHYCgUBUAWERIK4C2ARhAE4gIBmIUmAhqXbGQM4XUyZxsA2cSOCAA8oEMQBM2nHFGSU4AczykI4kAAMARHwEB1OOM6aAXCAAcABnUA6DeIAOpfjHUgWmBHh5r6ANxz8LGQwqiB0uBAA7jo4dJQh5NIg4ggwADQgRCp0ANb8CiBwMCB49tZAA/config/N4KABGBEA2CWB2BTA6rAJgFwBaQFxgA4AGAGnCiQHcAZBRAaQTTymgDNIyJINEAPDMgBOAQwAOLSCOiURATwDOncpEQBbMVhELYCxvGb5IAVwOIhCgMYB7IYiVcoCjEOvwA5vsNRtvIboBrBxVYd3hbRAARWDtLDFgAN0RJNDF-eAwAWlDwu2VuHIiAMVhoKJjEOMTko1T0rMK7TLZS5MdIRsQAZQwRIQxo2PiklLSEBrCIzOc+jHyoToBRA0HK4ZqoOvHsyabEA0gQAF8QIA/plugin/markdown

SuperFluffy commented 5 months ago

Thank you so much! How could I have discovered this by myself? Look through pulldown-cmark? Or would this have been documented anywhere on the dprint side?

SuperFluffy commented 5 months ago

Alright, I found it on this page: https://dprint.dev/plugins/markdown/config/

It looks like I have no way to configure dprint to 1. insert linebreaks in overflowing lines, while 2. keeping explicit linebreaks intact. See the following examples (the desired behavior at the bottom):

[original]
A very long line exceeding 80 characters. It goes all the way to 80 and stops. Then it goes past it.

A new paragraph.
Here the lines are shorter.
Like so.

[never]
A very long line exceeding 80 characters. It goes all the way to 80 and stops. Then it goes past it.

A new paragraph. Here the lines are shorter. Like so.

[maintain]
A very long line exceeding 80 characters. It goes all the way to 80 and stops. Then it goes past it.

A new paragraph.
Here the lines are shorter.
Like so.

[always]
A very long line exceeding 80 characters. It goes all the way to 80 and stops.
Then it goes past it.

A new paragraph. Here the lines are shorter. Like so.

[desired - maintain explicit newline but insert in overflowing]
A very long line exceeding 80 characters. It goes all the way to 80 and stops.
Then it goes past it.

A new paragraph.
Here the lines are shorter.
Like so.