Skip to content

jspaezp/mdformat-sentencebreak

Repository files navigation

mdformat-sentencebreak

An mdformat plugin that adds line wrapping based on sentence completion marks.

Behavior

This input ....

> Long sentences are broken at punctuation marks,
> unless the generated sentence would be extremely small
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.

> And it will not break sentences if
> they are inside something else ... emphasis for example
**Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.**

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.
**Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.**
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.

> Sentences are kept separate if they end in punctuation

Some.
Very.
Small.
Series.
of.
Sentences.

> Sentences are combined if they do not end in punctuation.

a
very
sloppy
sentence

Will get this ....

Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna.

**Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.**

Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna.
**Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna.**
Lorem ipsum dolor sit amet,
consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna.

Some.
Very.
Small.
Series.
of.
Sentences.

a very sloppy sentence

Installation

pip install mdformat-sentencebreak

Or using pipx

pipx install mdformat
pipx inject mdformat mdformat-sentencebreak

Usage

After installing mdformat and mdformat-sentencebreak, you can format a markdown file by calling:

mdformat {NAME_OF_YOUR_MARKRDOWN_FILE.md}

TODO:

  • Support for ellipsis in a long line
    • (...) gets broken into . ..

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages