Semantic Line Breaks #14828
Replies: 2 comments
-
Some thoughts on this: #9810 (comment) TLDR: Detecting an end of the sentence reliably is quite hard, so I would say that this is out of Prettier’s scope. However, if semantic line breaks are included in other linters like Markdownlint or ESLint, it is possible to run them alongside Prettier. AFAIU, Prettier won’t remove line breaks if another too has added them in markdown prose or JS comments. I’m using semantic line breaks too, so would be interested in seeing links to working tools that supplement Prettier! |
Beta Was this translation helpful? Give feedback.
-
Well, so far I'm using the aforementioned https://github.com/bobheadxi/readable which is based on regexp for sentence detection. Like you said, a true comprehensive solution doesn't seem to exists. I have worked in the past with sentence tokenization and for English there were tools that worked well for me, but there were all pretty "heavy" (such as nltk punkt tokenizers) and language specific. Seems most projects are using English for documentation it seems like something that works decently well for it would be "good enough". |
Beta Was this translation helpful? Give feedback.
-
How about enforcing Semantic Line Breaks as described by https://bobheadxi.dev/semantic-line-breaks/ with prettier?
Author of that already prepared an implementation based on remark, but it has multiple issues, and most importantly - only supports Markdown.
Seems like prettier would be a great choice to implement this.
Maybe it could be done through
--prose-wrap
option? I.e. by adding--prose-wrap sentence
? The default behavior could be changed to we wrap by both sentence and linewidth (in that order).Beta Was this translation helpful? Give feedback.
All reactions