gregjacobs / Autolinker.js

Utility to Automatically Link URLs, Email Addresses, Phone Numbers, Twitter handles, and Hashtags in a given block of text/HTML
MIT License
1.48k stars 238 forks source link

Please allow text to contain newline characters #93

Closed ghost closed 9 years ago

ghost commented 9 years ago

We linkify links embedded in 80-columns pre-formatted text (ie. text with newlines to signal a new line, which is embeed in the page with a

 tag) and sometimes links are so long that they are split in the middle with a newline character to keep the 80-columns limit.

Could newline characters \n and \r be added to the regexp recognizing links (only if they are in the middle) and filtered out when creating the href attribute? I don't think this would impact badly many applications as most of the times in standard HTML links are output with with no newlines chars in the middle.

gregjacobs commented 9 years ago

Hey, so someone brought this up little while ago actually, and unfortunately we can't really do that without being unsafe about what is linked. Short discussion in #34.

Perhaps instead though, you could pre-process the text to remove line breaks before sending to autolinker, and then use CSS or even a disabled textarea with the 'cols' attribute to limit the output to 80 characters?