mdox icon indicating copy to clipboard operation
mdox copied to clipboard

Define a maximum number of characters per line

Open Nexucis opened this issue 2 years ago • 5 comments

Hi,

It would be nice to be able to define the number of characters per line for the command mdox fmt. Like that every paragraphs are not inline anymore and it's easier to read in IntelliJ for example.

Because then you don't need to scroll horizontally which is a pain to do it regardless how much your UI is awesome :).

If you find it interesting, I would probably take some time to implement it.

Nexucis avatar Jan 16 '23 15:01 Nexucis

Hi! So we already had this request previously here and added option in mdox to preserve soft line breaks in markdown (--soft-wraps), which essentially preserves any soft line breaks. For example, if you have the following markdown,

Path to directory where metrics are saved in
OpenMetrics format; If empty, no metrics will
be saved.

with mdox fmt file.md you'd get,

Path to directory where metrics are saved in OpenMetrics format; If empty, no metrics will be saved.

but with mdox fmt --soft-wraps file.md you'd get,

Path to directory where metrics are saved in
OpenMetrics format; If empty, no metrics will
be saved.

This option is already being used in prometheus-operator. Maybe this addresses your use case better? 🙂

saswatamcode avatar Jan 16 '23 15:01 saswatamcode

Oh yeah that's already cool to have this option ! Thank you for pointing it, I didn't pay enough attention to the documentation.

I still think it would be cool to enforce a maximum length per line. So it's the breaks-line logic for everyone :).

Nexucis avatar Jan 16 '23 15:01 Nexucis

I see! I'm not opposed to line limits, and would be interested in a PR if you have some time. 🙂 But it might be difficult to implement as I expect there'll be some edge cases (uneven spacing, words, bullets etc.).

mdox internally uses https://github.com/Kunde21/markdownfmt for markdown formatting, so that might be a good place to start!

saswatamcode avatar Jan 16 '23 16:01 saswatamcode

ah nice, thanks for the pointer ! I will look there then :).

Nexucis avatar Jan 16 '23 16:01 Nexucis

Still, it would be amazing to have auto-wrap with given width option e.g. --auto-wrap-max-chars=<num>. Help wanted!

bwplotka avatar Jul 05 '23 19:07 bwplotka