markdownfmt
markdownfmt copied to clipboard
Feature: hard wrap lines to specified length
There was an issue for this, if I'm reading it correctly, but it was closed because the issue filer now uses an IDE to do this.
I'd like a flag like -wrap <int>
to set a maximum line length, with markdownfmt reflowing paragraphs automatically to fit the limit.
Something like the following logic should be appropriate:
- Never reflow literal environments (code blocks, tables, etc).
- Reflow quote environments to maintain the indentation of the first line at the current depth, and prefix continuing lines with "> ".
- Reflow bulleted / numbered environments by reflowing each item separately, maintaining the indentation of the opening text of the item on succeeding lines.
- Reflow all other environments, inserting a newline at a word boundary when adding the next word would exceed the character limit.
- Always insert at least one word (or URL, image, or other entity) on each new line, even if that would cause the line to exceed the character limit.
- Count characters using grapheme clustering, eg. with uniseg.