{"_id":"autolinker.js","_rev":"4-20a66660cc6427934e3c2f4517d8ef1a","name":"autolinker.js","description":"Simple utility to automatically link the URLs, email addresses, and Twitter handles in a given block of text/HTML","dist-tags":{"latest":"0.7.0"},"versions":{"0.7.0":{"name":"autolinker.js","version":"0.7.0","description":"Simple utility to automatically link the URLs, email addresses, and Twitter handles in a given block of text/HTML","main":"src/Autolinker.js","directories":{"test":"tests"},"scripts":{"test":"grunt test"},"repository":{"type":"git","url":"git://github.com/gregjacobs/Autolinker.js.git"},"keywords":["auto","link","autolink","url","urls","anchor"],"author":{"name":"Gregory Jacobs","email":"greg@greg-jacobs.com"},"license":"MIT Licensed. http://www.opensource.org/licenses/mit-license.php","bugs":{"url":"https://github.com/gregjacobs/Autolinker.js/issues"},"homepage":"https://github.com/gregjacobs/Autolinker.js","devDependencies":{"grunt":"^0.4.4","grunt-contrib-jasmine":"^0.6.4","grunt-contrib-connect":"^0.7.1","requirejs":"^2.1.11","grunt-contrib-uglify":"^0.4.0","grunt-contrib-concat":"^0.4.0"},"_id":"autolinker.js@0.7.0","dist":{"shasum":"f0fccb28731a7ff48112f86263f2572bff913336","tarball":"https://registry.npmjs.org/autolinker.js/-/autolinker.js-0.7.0.tgz","integrity":"sha512-krQ+yad5w2cO6TpEw7UDnt1ZTMIAZTZPy9jMB5+p+IycnGo90iNXprb8AVShrA3efdO+HqsPOSgN+v/FalHIPw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCSb9ou7sEUnWTrkCk9jmIU0HKP/uOEobhdVru3ux/bGgIhALXOw2nn5dZaARPR05KUfMpXNCIajWzy7kfQTYqSrlfQ"}]},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"gregjacobs","email":"greg@greg-jacobs.com"},"maintainers":[{"name":"gregjacobs","email":"greg@greg-jacobs.com"}]}},"readme":"# Autolinker.js\r\n\r\nBecause I had so much trouble finding a good autolinking implementation out in the wild, I decided to roll my own. It \r\nseemed that everything I found out there was either an implementation that didn't cover every case, or was just limited \r\nin one way or another. \r\n\r\nSo, this utility attempts to handle everything. It:\r\n\r\n- Autolinks URLs, whether or not they start with the protocol (i.e. 'http://'). In other words, it will automatically link the \r\n  text \"google.com\", as well as \"http://google.com\".\r\n- Will properly handle URLs with special characters\r\n- Will properly handle URLs with query parameters or a named anchor (i.e. hash)\r\n- Will autolink email addresses.\r\n- Will autolink Twitter handles.\r\n- Will properly handle HTML input. The utility will not change the `href` attribute inside anchor (&lt;a&gt;) tags (or any other \r\n  tag/attribute for that matter), and will not accidentally wrap the inner text of an anchor tag with a new one (which would cause \r\n  doubly-nested anchor tags).\r\n\r\nHope that this utility helps you as well!\r\n\r\n\r\n## Installation\r\n\r\nSimply clone or download the zip of the project, and link to either `dist/Autolinker.js` or `dist/Autolinker.min.js` with a script tag:\r\n\r\n```html\r\n<script src=\"path/to/Autolinker.min.js\"></script>\r\n```\r\n\r\nCan also download via [Bower](http://bower.io):\r\n\r\n```shell\r\nbower install Autolinker.js --save\r\n```\r\n\r\n## Usage\r\n\r\n```javascript\r\nvar linkedText = Autolinker.link( textToAutolink[, options] );\r\n```\r\n\t\r\nExample:\r\n\r\n```javascript\r\nvar linkedText = Autolinker.link( \"Check out google.com\" );\r\n// Produces: \"Check out <a href=\"http://google.com\" target=\"_blank\">google.com</a>\"\r\n```\r\n\t\r\n### Options\r\nThere are options which may be specified for the linking. These are specified by providing an Object as the second parameter to `Autolinker.link()`. Options include:\r\n\r\n- **newWindow** : Boolean<br />\r\n  `true` to have the links should open in a new window when clicked, `false` otherwise. Defaults to `true`.\r\n- **stripPrefix** : Boolean<br />\r\n  `true` to have the 'http://' or 'https://' and/or the 'www.' stripped from the beginning of links, `false` otherwise. Defaults to `true`.\r\n- **truncate** : Number<br />\r\n  A number for how many characters long URLs/emails/twitter handles should be truncated to inside the text of a link. If the URL/email/twitter is over the number of characters, it will be truncated to this length by replacing the end of the string with a two period ellipsis ('..').\r\n  Ex: a url like 'http://www.yahoo.com/some/long/path/to/a/file' truncated to 25 characters may look like this: 'yahoo.com/some/long/pat..'\r\n- **urls** : Boolean<br />\r\n  `true` to have URLs auto-linked, `false` to skip auto-linking of URLs. Defaults to `true`.\r\n- **email** : Boolean<br />\r\n  `true` to have email addresses auto-linked, `false` to skip auto-linking of email addresses. Defaults to `true`.\r\n- **twitter** : Boolean<br />\r\n  `true` to have Twitter handles auto-linked, `false` to skip auto-linking of Twitter handles. Defaults to `true`.\r\n\r\nFor example, if you wanted to disable links from opening in new windows, you could do:\r\n\r\n```javascript\r\nvar linkedText = Autolinker.link( \"Check out google.com\", { newWindow: false } );\r\n// Produces: \"Check out <a href=\"http://google.com\">google.com</a>\"\r\n```\r\n\r\nAnd if you wanted to truncate the length of URLs (while also not opening in a new window), you could do:\r\n\r\n```javascript\r\nvar linkedText = Autolinker.link( \"http://www.yahoo.com/some/long/path/to/a/file\", { truncate: 25, newWindow: false } );\r\n// Produces: \"<a href=\"http://www.yahoo.com/some/long/path/to/a/file\">yahoo.com/some/long/pat..</a>\"\r\n```\r\n\r\n### More Examples\r\nOne could update an entire DOM element that has unlinked text to auto-link them as such:\r\n\r\n```javascript\r\nvar myTextEl = document.getElementById( 'text' );\r\nmyTextEl.innerHTML = Autolinker.link( myTextEl.innerHTML );\r\n```\r\n\r\n## Changelog:\r\n\r\n### 0.7.0\r\n\r\n- Changed build system to Grunt.\r\n- Added AMD and CommonJS module loading support (ex: RequireJS, and Node.js's module loader).\r\n- Added command line Jasmine test runner (`grunt test`)\r\n- Upgraded Jasmine from 1.3.1 to 2.0\r\n- Added license header to dist files.\r\n\r\n(Thanks to [busticated](https://github.com/busticated)!)\r\n\r\n### 0.6.1\r\n\r\n- Added LICENSE file to repository.\r\n\r\n### 0.6.0\r\n\r\n- Added options for granular control of which types are linked (urls, email addresses, and/or twitter handles). \r\n  (thanks [@aziraphale](https://github.com/aziraphale))\r\n\r\n### 0.5.0\r\n\r\n- Simplified the path / query string / hash processing into a single regular expression instead of 3 separate ones.\r\n- Added support for parenthesis in URLs, such as: `en.wikipedia.org/wiki/IANA_(disambiguation)` (thanks [@dandv](https://github.com/dandv))\r\n- Add all known top-level domains (TLDs) (thanks [@wouter0100](https://github.com/wouter0100))\r\n\r\n### 0.4.0\r\n\r\nMerged pull requests from [@afeld](https://github.com/afeld):\r\n\r\n- strip protocol and 'www.' by default - fixes #1\r\n- truncate URLs from the end\r\n- make simpler regex for detecting prefix\r\n- remove trailing slashes from URLs, and handle periods at the end of paths\r\n- re-use domain+TLD regexes for email matching\r\n- add .me and .io to list of TLDs\r\n\r\nThanks Aidan :)\r\n\r\n### 0.3.1\r\n\r\n- Fixed an issue with handling nested HTML tags within anchor tags.\r\n\r\n### 0.3\r\n\r\n- Implemented the `truncate` option.\r\n\r\n### 0.2\r\n\r\n- Implemented autolinking Twitter handles.\r\n\r\n### 0.1\r\n\r\n* Initial implementation, which autolinks URLs and email addresses. Working on linking Twitter handles.\r\n","maintainers":[{"name":"gregjacobs","email":"greg@greg-jacobs.com"}],"time":{"modified":"2022-06-13T03:50:12.228Z","created":"2014-05-04T02:55:22.669Z","0.7.0":"2014-05-04T02:55:22.669Z"},"homepage":"https://github.com/gregjacobs/Autolinker.js","keywords":["auto","link","autolink","url","urls","anchor"],"repository":{"type":"git","url":"git://github.com/gregjacobs/Autolinker.js.git"},"author":{"name":"Gregory Jacobs","email":"greg@greg-jacobs.com"},"bugs":{"url":"https://github.com/gregjacobs/Autolinker.js/issues"},"license":"MIT Licensed. http://www.opensource.org/licenses/mit-license.php","readmeFilename":"README.md"}