Skip to content
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

TextHelper#word_wrap should not strip spaces from the left side of the wrapped string #34487

Closed
mullican opened this issue Nov 19, 2018 · 0 comments

Comments

@mullican
Copy link
Contributor

Steps to reproduce

Apply word_wrap to a block of text that contains some indented lines:

    This is a paragraph with an initial indent,
followed by additional lines that are not indented,
and finally terminated with a blockquote:
  "A pithy saying by a wise person"

Expected behavior

A line break should be inserted at the appropriate character limit, but the leading spaces should not be removed. For example, if str contains the example above, word_wrap(str, line_width: 25) should produce:

    This is a paragraph
with an initial indent,
followed by additional
lines that are not
indented,
and finally terminated
with a blockquote:
  "A pithy saying by a
wise person"

Actual behavior

For any line that exceeds the configured length, white space is stripped from the beginning as well as the end of the line, even though that leading white space was included in the character count that determined how long the line was:

This is a paragraph
with an initial indent,
followed by additional
lines that are not
indented,
and finally terminated
with a blockquote:
"A pithy saying by a
wise person"

System configuration

Rails version: All
Ruby version: All

@mullican mullican changed the title TextHelper#word_wrap should not strip spaces from the left side of the wrapped string TextHelper#word_wrap should not strip spaces from the left side of the wrapped string Nov 19, 2018
mullican added a commit to mullican/rails that referenced this issue Nov 19, 2018
rafaelfranca added a commit that referenced this issue Nov 19, 2018
…whitespace

Prevent TextHelper#word_wrap from stripping white space on the left side of long lines; Fixes #34487
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants