Word wrap?

Hi,

I have long lines of text stored in a DB without line breaks. Now I
need to present it in
fixed width with word wrap. I tried everything css (word-wrap:
break-word;), the rails actionview helper (word_wrap), specifying
width of the div etc. But nothing works. The reason I’m
asking the question here because to me word_wrap was created to solve
this exact problem
but it is failing to do so. Correct me if i’m wrong.

Regards
Manu

Maybe this approach could work…

<%= @quote.statement %>

DAN

Do they have white space between the words?
Silly question, but it sounds strange that what you’re doing already
doesn’t work.

The following post shows how to split long words (Gregory’s code is
much nicer then mine)
http://groups.google.com/group/rubyonrails-talk/browse_frm/thread/c67dd3750aaca3cc/f2e280d1e2f6cd19?lnk=st&q=&rnum=19#f2e280d1e2f6cd19

Bart

have you tried simple_format()?

Carl J. wrote:

have you tried simple_format()?

or simply word_wrap(text, line_length) ?

This is strange indeed. Can you give an example of text which doesn’t
wrap. It’s really a basic thing in a browser. How is your text field
defined, how is it pulled and presented via Rails? Do you have it
online we can see? I feel there’s something else that’s screwing it
up.

Bart

http://groups.google.com/group/rubyonrails-talk/browse_frm/thread/c67dd3750aaca3cc/f2e280d1e2f6cd19?lnk=st&q=&rnum=19#f2e280d1e2f6cd19

Unfortunately that did not solve the problem :(. That code splits
strings. In my case I have a paragraph on a single line without line
breaks. Yes the words have white spaces between them :).

Regards
Manu

Glad you got it working…
Bart

Solved :slight_smile:

I was putting together a simple app to demonstrate this and the bug
disappeared.
Then I went and dug deeper. One of the parent elements was setting
white-space: nowrap.
I was not familiar with the css and was certainly not aware of the
white-space attribute.
Sorry for wasting your time.

Regards
Manu