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.
Hey! I've been doing some work on trying to add
text-wrap: "pretty"
into Satori. I must admit, this is a very naive implementation, but I still wanted to post it here to gain some traction and comments before proceeding with adding some tests.I initially tried to follow Google’s full spec, but fell face first before abandoning the approach.
The current solution checks if the last line of a paragraph is shorter than 30% of the paragraph’s width. If it is, the paragraph width is adjusted to 90%, before the content is passed back into
flow()
for a 2nd pass. This method works quite well in many cases, but of course it doesn’t cover all the edge cases the full spec would handle, such as advanced hyphen handling.Demo:
77c4a6d6b591fd95bd0963ac677f0574.mp4
Some other sources: