-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple space → nbsp translation has poor line wrapping behavior #748
Comments
I believe this was fixed somewhere along the way. Can't reproduce in the demo. |
This was not fixed. It still reproduces in the demo: And the incorrect code is still here:
and in other repositories: https://github.com/bustle/mobiledoc-apple-news-renderer/blob/357dd068e45f218983cdbc55d73b420ceeedced8/lib/utils/dom.js#L3 Please reopen. |
Yeah, looks like WebKit handles the wrapping differently. Try it in Chromium or Firefox. |
mobiledoc-kit currently renders multiple consecutive spaces by replacing each space-space pair with space-nbsp (#209). Depending on the text width, this results in the left margin being misaligned when a line is wrapped at that point. Emphasizing nbsp with
_
to illustrate the problem:To fix this, it would be better to replace each sequence of n spaces with n − 1 nbsps followed by 1 space. This can be done with regexp lookahead:
It might be better to disable the nbsp translation entirely and rely on CSS
white-space: pre-wrap
, but that’d be a bigger change.(The same issue is present in other repositories like mobiledoc-dom-renderer, mobiledoc-html-renderer, mobiledoc-apple-news-renderer; I assume I don’t need to file separate issues for each one.)
The text was updated successfully, but these errors were encountered: