Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformulate wrapping in terms of boxes, glue, and penalties
This is a complete rewrite of the core word wrapping functionality. Before, we would step though the input string and (attempt to) keep track of all aspects of the state. This didn't always work (see at least #122, #158, #158, and #193) and it's inflexible. This commit replaces the old algorithm with a new one which works on a more abstract level. We now first 1. First split the input string into "words". A word is a substring of the original string, including any trailing whitespace. 2. We split each word according to the `WordSplitter`. 3. We then simply put the words into lines based on the display width. This is slower than the previous algorithm. The `fill/1600` benchmark shows that is now takes ~18 microseconds to wrap a 1600 character long string. That is around 8 microseconds longer than before.
- Loading branch information