- When I want wrapping:
`white-space: pre-wrap; overflow-wrap: break-word;``
- When I don't want wrapping:
`white-space: pre; overflow-x: auto; overscroll-behavior-x: none;``
From what I can tell there's not a way to suppress breaking at hyphens without breaking strings at another place. Using `line-breaks: anywhere;`` prevented breaking on the hyphens but broke wherever the string touched the boundary.
The primary recommendations I found for dealing with hyphens would be to wrap them in spans with nowrap or to change the character to something else that doesn't wrap. (but that would effect copy/paste). So, the wrap seems like the best option if it's important enough to put in the work to make that happen
An interesting play would be to update a syntax highligher to apply the nowrap along with the rest of the formatting
I'm not using `text-wrap`` in any of the examples as it' still experimental
There's also a 'word-break' property but it seems aimed at Chinese/Japanese/Korean (CJK) text. I don't know enough about that to include it here.