Initial import from my gist: https://gist.github.com/lovasoa/1918801
Add support for line breaks.
Thanks to @thephpjo