Add "semantic line break" support (alternative to proseWrap: always
)
#16189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Hello, I am aware of the "no new options" philosophy and thus understand that you might wish to reject this PR, as such I have only invested an hour into stubbing it out. Please, however, hear me out.
I use
prettier
heavily in my day to day work, across many languages. I think it's a fantastic piece of software, so much so that I spearheaded the work to format the GraphQL Specification usingprettier
and the work required for the underlying tool, spec-md, to support prettier's flavour of Markdown formatting. This enabled us to spend less time concerned with the formatting of someone's spec pull request since it was already enforced, and the line wrapping (proseWrap: always
) was essential for this.However, small changes in specification text can cause significant re-wrapping, which makes review harder. For example, here's a recent pull request where I italicised some keywords (
selection set
->_selection set_
) and in may places that has caused entire paragraphs to re-wrap, causing reviewers to have to check the changes more carefully:As previously mentioned, wrapping prose is essential to us for line-length reasons; however this re-wrapping is problematic.
This issue isn't limited to the GraphQL specification of course, anyone who writes large amounts of prose in Markdown will likely have felt this pain - documentation website and READMEs in particular are heavily hit by it.
I recently became aware of the Semantic Line Breaks Specification (SemBr) and thought that this would make a good alternative to
proseWrap: always
. This PR is a "proof of concept" to explore this idea and see if it's something that you might consider adding to Prettier. Arguably it's not a new option, it's just an alternative value for an existing option 😉In Semantic Line Break mode, the rewrapping of the text is limited to the sentence (or parts thereof), rather than the paragraph, thus the above diff would have looked like:
This is a draft PR, so I have not yet added documentation or changelog changes. There's no point doing so if you are not interested in the option.
Checklist
docs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨