This project is archived and is in readonly mode.
ActionView::Helpers::TextHelper#truncate should understand HTML encoding.
-
Peter Wagenet
- Tag changed from html, truncate, view to html, patch, tested, truncate, view
The problem here is a bit more complicated that it seems. First, what if the user doesn't plan to format as HTML? I know that's an odd case, but should it be supported? If so, how do we know if "…" should be counted as one character or seven? If we do assume that it will always be output as HTML then counting it as one character is simple, as you can see in my attached patch. However, my patch does nothing about the case where we have special characters in the string to be truncated. Even worse, we could end up truncating in the middle of a special character which would be far from desired. There's probably the need for some additional work to be done here.
-
Peter Wagenet
The ellipses in my comment should actually be the HTML string written out.
-
Pratik
- Assigned user set to Pratik
- State changed from new to incomplete
We could have used CGI::unescapeHTML here, except it doesn't seem to be working with …. So if there is a rack equivalent of that, it could work here.
Thanks.
-
Gaius Centus Novus
CGI::unescapeHTMLis completely borked. See my question on StackOverflow: http://stackoverflow.com/questio...
