In my rails project I have the following code
auto_link( h( wrap_long_string(post.text,50) )).gsub(/\n/,"<br />")
wrap_long_string
is defined as:
def wrap_long_string(txt,col = 20)
txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/,
"\\1\\3\n")
end
This code is meant to display user entered text while preventing users from messing up the layout of the page (by entering a very long non-breaking string for example).
However, the act of breaking up long non-breaking strings also prevents the auto_link helper from working.
What I would like to do is to have the following text:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=ZGF&q=example&btnG=Search
Be turned into something like:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<br/>aaaaaaaaaa <a href='http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=ZGF&q=example&btnG=Search'>http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&hs=ZGF&q=example&btnG=Search</a>