Hi Yan,
I stumbled upon this post while looking for a good way to do word wrapping.
Your method looks good, except it could break words inside tags. You might want to check this one out instead: it makes sure not to break words inside and in pre blocks.
I’d thought about tokenizing and making sure to wrap only words between tags, but in the end it was too much overhead for such a simple task, and I guess the above is good enough (actually, it’s perfect if are correctly escaped when not used to surround tags).
I hope this helps. :)



3 Comments