Ok I guess I found a solution, using a truncate
over html_safe
that includes special characters was producing problems, when the entire text including the nbsp;
and inline styling was cut short due to truncate.
Switching the order of html_safe
and truncate
somewhat solved the issue. Now it would truncate first and then apply html_safe
. But still was producing undesirable results when total length including all special characters increased my truncate limit. A little effort produced a result which was almost correct.
html_safe(job_profile.description.truncate(100) +' <font color="#999">[ '+ truncate(list.join(', '), length: 100-(job_profile.description.length)) +' ]</font>')
Little more customisation, taking into accounts the three dots ...
every truncate produces, and one would get the exact result as needed.