{"action":"created","comment":{"url":"https://api.github.com/repos/npm/marky-markdown/pulls/comments/53532504","id":53532504,"diff_hunk":"@@ -0,0 +1,55 @@\n+// github-style linkification for linkify-it\n+//\n+// Pass in a markdown-it parser instance and this will return a version fixed\n+// up for the kind of linkification we're after.\n+//\n+// As far as I can determine, the basic algorithm is to linkify anything\n+// starting with 'www.' and ending with a) a whitespace character, or b) a dot\n+// followed by a whitespace character (in other words, include internal dots,\n+// but exclude a trailing dot). There are plenty of cases where this results in\n+// invalid links, but that's how they do it, so that's how we'll do it.\n+//\n+module.exports = function (parser) {\n+  if (parser) {\n+    var linkify = parser.linkify\n+\n+    linkify.set({fuzzyLink: false}) // turn off auto-linking normal hostnames\n+    linkify.add('//', null) // turn off protocol-relative links\n+\n+    // linkify everything hostnamey starting with 'www.'\n+    parser.linkify.add('www.', {\n+      validate: function (text, pos, self) {\n+        var match = text.slice(pos).match(/^\\S*/)[0]\n+\n+        // there's probably a nice regex way of excluding a trailing dot from\n+        // these matches, but it's simple enough to just trim them off here\n+        if (match.slice(-1) === '.') match = match.slice(0, -1)\n+\n+        // if we have a zero-length match, i.e., if the original string was\n+        // literally 'www.' all by itself, we return -1 because linkify-it does\n+        // a boolean test on the result of the validator function (so we need a\n+        // non-zero result here to make it through that test) and adds the\n+        // returned value to an index it's using to point to the end of the\n+        // matched substring. In this case, that means we'll move backwards one\n+        // character and only link 'www' rather than the full 'www.' that was\n+        // originally matched\n+        return match.length || -1\n+      },\n+      normalize: function (match) {\n+        match.url = 'http://' + match.url\n+      }\n+    })\n+\n+    // linkify-it's default behavior is to create matches against the\n+    // registered schema prefixes when the character immediately preceding a\n+    // potential match is non-alphanumeric; however, we also need to skip\n+    // linkification when said character is punctuation. So here we rebuild the\n+    // internal regular expressions the LinkifyIt instance will use.\n+    var re = linkify.re","path":"lib/linkify.js","position":48,"original_position":48,"commit_id":"b6946124b3c2703768b950343d144038fd4dfd87","original_commit_id":"b6946124b3c2703768b950343d144038fd4dfd87","user":{"login":"ashleygwilliams","id":1163554,"avatar_url":"https://avatars.githubusercontent.com/u/1163554?v=3","gravatar_id":"","url":"https://api.github.com/users/ashleygwilliams","html_url":"https://github.com/ashleygwilliams","followers_url":"https://api.github.com/users/ashleygwilliams/followers","following_url":"https://api.github.com/users/ashleygwilliams/following{/other_user}","gists_url":"https://api.github.com/users/ashleygwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/ashleygwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashleygwilliams/subscriptions","organizations_url":"https://api.github.com/users/ashleygwilliams/orgs","repos_url":"https://api.github.com/users/ashleygwilliams/repos","events_url":"https://api.github.com/users/ashleygwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/ashleygwilliams/received_events","type":"User","site_admin":false},"body":"only comment is the `re` is really short and maybe it's more readable to say `regex` or something a bit more elaborate. don't really have strong feels tho. the comment is super helpful.","created_at":"2016-02-19T23:16:36Z","updated_at":"2016-02-19T23:16:36Z","html_url":"https://github.com/npm/marky-markdown/pull/151#discussion_r53532504","pull_request_url":"https://api.github.com/repos/npm/marky-markdown/pulls/151","_links":{"self":{"href":"https://api.github.com/repos/npm/marky-markdown/pulls/comments/53532504"},"html":{"href":"https://github.com/npm/marky-markdown/pull/151#discussion_r53532504"},"pull_request":{"href":"https://api.github.com/repos/npm/marky-markdown/pulls/151"}}},"pull_request":{"url":"https://api.github.com/repos/npm/marky-markdown/pulls/151","id":58954958,"html_url":"https://github.com/npm/marky-markdown/pull/151","diff_url":"https://github.com/npm/marky-markdown/pull/151.diff","patch_url":"https://github.com/npm/marky-markdown/pull/151.patch","issue_url":"https://api.github.com/repos/npm/marky-markdown/issues/151","number":151,"state":"open","locked":false,"title":"Github-style host/domain linkification","user":{"login":"revin","id":94850,"avatar_url":"https://avatars.githubusercontent.com/u/94850?v=3","gravatar_id":"","url":"https://api.github.com/users/revin","html_url":"https://github.com/revin","followers_url":"https://api.github.com/users/revin/followers","following_url":"https://api.github.com/users/revin/following{/other_user}","gists_url":"https://api.github.com/users/revin/gists{/gist_id}","starred_url":"https://api.github.com/users/revin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/revin/subscriptions","organizations_url":"https://api.github.com/users/revin/orgs","repos_url":"https://api.github.com/users/revin/repos","events_url":"https://api.github.com/users/revin/events{/privacy}","received_events_url":"https://api.github.com/users/revin/received_events","type":"User","site_admin":false},"body":"This change moves us toward parity with Github's linkification of raw domain/hostnames by disabling the `fuzzyLink` option in markdown-it's linkification code, which is the code responsible for creating links from domains/hostnames without a protocol specifier (i.e., *example.com*). It will still create normal links from fully-qualified URLs (*http://example.com/*) and `mailto:` from email addresses (*marky@example.com*). Since GH linkifies hostnames starting with `www.` (www.example.com), we need to add our own schema/rule covering this case.\r\n\r\n**Note:** This isn't done; I'll remove the WIP label when it's ready for review.","created_at":"2016-02-10T21:17:54Z","updated_at":"2016-02-19T23:16:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e368bc7f379b082ffc4889b7805d37fb92af9e99","assignee":{"login":"ashleygwilliams","id":1163554,"avatar_url":"https://avatars.githubusercontent.com/u/1163554?v=3","gravatar_id":"","url":"https://api.github.com/users/ashleygwilliams","html_url":"https://github.com/ashleygwilliams","followers_url":"https://api.github.com/users/ashleygwilliams/followers","following_url":"https://api.github.com/users/ashleygwilliams/following{/other_user}","gists_url":"https://api.github.com/users/ashleygwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/ashleygwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashleygwilliams/subscriptions","organizations_url":"https://api.github.com/users/ashleygwilliams/orgs","repos_url":"https://api.github.com/users/ashleygwilliams/repos","events_url":"https://api.github.com/users/ashleygwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/ashleygwilliams/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/npm/marky-markdown/pulls/151/commits","review_comments_url":"https://api.github.com/repos/npm/marky-markdown/pulls/151/comments","review_comment_url":"https://api.github.com/repos/npm/marky-markdown/pulls/comments{/number}","comments_url":"https://api.github.com/repos/npm/marky-markdown/issues/151/comments","statuses_url":"https://api.github.com/repos/npm/marky-markdown/statuses/b6946124b3c2703768b950343d144038fd4dfd87","head":{"label":"revin:linkification","ref":"linkification","sha":"b6946124b3c2703768b950343d144038fd4dfd87","user":{"login":"revin","id":94850,"avatar_url":"https://avatars.githubusercontent.com/u/94850?v=3","gravatar_id":"","url":"https://api.github.com/users/revin","html_url":"https://github.com/revin","followers_url":"https://api.github.com/users/revin/followers","following_url":"https://api.github.com/users/revin/following{/other_user}","gists_url":"https://api.github.com/users/revin/gists{/gist_id}","starred_url":"https://api.github.com/users/revin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/revin/subscriptions","organizations_url":"https://api.github.com/users/revin/orgs","repos_url":"https://api.github.com/users/revin/repos","events_url":"https://api.github.com/users/revin/events{/privacy}","received_events_url":"https://api.github.com/users/revin/received_events","type":"User","site_admin":false},"repo":{"id":48707032,"name":"marky-markdown","full_name":"revin/marky-markdown","owner":{"login":"revin","id":94850,"avatar_url":"https://avatars.githubusercontent.com/u/94850?v=3","gravatar_id":"","url":"https://api.github.com/users/revin","html_url":"https://github.com/revin","followers_url":"https://api.github.com/users/revin/followers","following_url":"https://api.github.com/users/revin/following{/other_user}","gists_url":"https://api.github.com/users/revin/gists{/gist_id}","starred_url":"https://api.github.com/users/revin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/revin/subscriptions","organizations_url":"https://api.github.com/users/revin/orgs","repos_url":"https://api.github.com/users/revin/repos","events_url":"https://api.github.com/users/revin/events{/privacy}","received_events_url":"https://api.github.com/users/revin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/revin/marky-markdown","description":"The thing npmjs.com uses to clean up READMEs and other markdown files","fork":true,"url":"https://api.github.com/repos/revin/marky-markdown","forks_url":"https://api.github.com/repos/revin/marky-markdown/forks","keys_url":"https://api.github.com/repos/revin/marky-markdown/keys{/key_id}","collaborators_url":"https://api.github.com/repos/revin/marky-markdown/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/revin/marky-markdown/teams","hooks_url":"https://api.github.com/repos/revin/marky-markdown/hooks","issue_events_url":"https://api.github.com/repos/revin/marky-markdown/issues/events{/number}","events_url":"https://api.github.com/repos/revin/marky-markdown/events","assignees_url":"https://api.github.com/repos/revin/marky-markdown/assignees{/user}","branches_url":"https://api.github.com/repos/revin/marky-markdown/branches{/branch}","tags_url":"https://api.github.com/repos/revin/marky-markdown/tags","blobs_url":"https://api.github.com/repos/revin/marky-markdown/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/revin/marky-markdown/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/revin/marky-markdown/git/refs{/sha}","trees_url":"https://api.github.com/repos/revin/marky-markdown/git/trees{/sha}","statuses_url":"https://api.github.com/repos/revin/marky-markdown/statuses/{sha}","languages_url":"https://api.github.com/repos/revin/marky-markdown/languages","stargazers_url":"https://api.github.com/repos/revin/marky-markdown/stargazers","contributors_url":"https://api.github.com/repos/revin/marky-markdown/contributors","subscribers_url":"https://api.github.com/repos/revin/marky-markdown/subscribers","subscription_url":"https://api.github.com/repos/revin/marky-markdown/subscription","commits_url":"https://api.github.com/repos/revin/marky-markdown/commits{/sha}","git_commits_url":"https://api.github.com/repos/revin/marky-markdown/git/commits{/sha}","comments_url":"https://api.github.com/repos/revin/marky-markdown/comments{/number}","issue_comment_url":"https://api.github.com/repos/revin/marky-markdown/issues/comments{/number}","contents_url":"https://api.github.com/repos/revin/marky-markdown/contents/{+path}","compare_url":"https://api.github.com/repos/revin/marky-markdown/compare/{base}...{head}","merges_url":"https://api.github.com/repos/revin/marky-markdown/merges","archive_url":"https://api.github.com/repos/revin/marky-markdown/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/revin/marky-markdown/downloads","issues_url":"https://api.github.com/repos/revin/marky-markdown/issues{/number}","pulls_url":"https://api.github.com/repos/revin/marky-markdown/pulls{/number}","milestones_url":"https://api.github.com/repos/revin/marky-markdown/milestones{/number}","notifications_url":"https://api.github.com/repos/revin/marky-markdown/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/revin/marky-markdown/labels{/name}","releases_url":"https://api.github.com/repos/revin/marky-markdown/releases{/id}","deployments_url":"https://api.github.com/repos/revin/marky-markdown/deployments","created_at":"2015-12-28T18:46:20Z","updated_at":"2016-01-12T15:07:08Z","pushed_at":"2016-02-19T23:12:06Z","git_url":"git://github.com/revin/marky-markdown.git","ssh_url":"git@github.com:revin/marky-markdown.git","clone_url":"https://github.com/revin/marky-markdown.git","svn_url":"https://github.com/revin/marky-markdown","homepage":"http://npm.im/marky-markdown","size":287,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"npm:master","ref":"master","sha":"06570a14cf1018e09eb02c0fd11be0ce32451737","user":{"login":"npm","id":6078720,"avatar_url":"https://avatars.githubusercontent.com/u/6078720?v=3","gravatar_id":"","url":"https://api.github.com/users/npm","html_url":"https://github.com/npm","followers_url":"https://api.github.com/users/npm/followers","following_url":"https://api.github.com/users/npm/following{/other_user}","gists_url":"https://api.github.com/users/npm/gists{/gist_id}","starred_url":"https://api.github.com/users/npm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npm/subscriptions","organizations_url":"https://api.github.com/users/npm/orgs","repos_url":"https://api.github.com/users/npm/repos","events_url":"https://api.github.com/users/npm/events{/privacy}","received_events_url":"https://api.github.com/users/npm/received_events","type":"Organization","site_admin":false},"repo":{"id":27984586,"name":"marky-markdown","full_name":"npm/marky-markdown","owner":{"login":"npm","id":6078720,"avatar_url":"https://avatars.githubusercontent.com/u/6078720?v=3","gravatar_id":"","url":"https://api.github.com/users/npm","html_url":"https://github.com/npm","followers_url":"https://api.github.com/users/npm/followers","following_url":"https://api.github.com/users/npm/following{/other_user}","gists_url":"https://api.github.com/users/npm/gists{/gist_id}","starred_url":"https://api.github.com/users/npm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/npm/subscriptions","organizations_url":"https://api.github.com/users/npm/orgs","repos_url":"https://api.github.com/users/npm/repos","events_url":"https://api.github.com/users/npm/events{/privacy}","received_events_url":"https://api.github.com/users/npm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/npm/marky-markdown","description":"npm's markdown parser","fork":false,"url":"https://api.github.com/repos/npm/marky-markdown","forks_url":"https://api.github.com/repos/npm/marky-markdown/forks","keys_url":"https://api.github.com/repos/npm/marky-markdown/keys{/key_id}","collaborators_url":"https://api.github.com/repos/npm/marky-markdown/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/npm/marky-markdown/teams","hooks_url":"https://api.github.com/repos/npm/marky-markdown/hooks","issue_events_url":"https://api.github.com/repos/npm/marky-markdown/issues/events{/number}","events_url":"https://api.github.com/repos/npm/marky-markdown/events","assignees_url":"https://api.github.com/repos/npm/marky-markdown/assignees{/user}","branches_url":"https://api.github.com/repos/npm/marky-markdown/branches{/branch}","tags_url":"https://api.github.com/repos/npm/marky-markdown/tags","blobs_url":"https://api.github.com/repos/npm/marky-markdown/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/npm/marky-markdown/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/npm/marky-markdown/git/refs{/sha}","trees_url":"https://api.github.com/repos/npm/marky-markdown/git/trees{/sha}","statuses_url":"https://api.github.com/repos/npm/marky-markdown/statuses/{sha}","languages_url":"https://api.github.com/repos/npm/marky-markdown/languages","stargazers_url":"https://api.github.com/repos/npm/marky-markdown/stargazers","contributors_url":"https://api.github.com/repos/npm/marky-markdown/contributors","subscribers_url":"https://api.github.com/repos/npm/marky-markdown/subscribers","subscription_url":"https://api.github.com/repos/npm/marky-markdown/subscription","commits_url":"https://api.github.com/repos/npm/marky-markdown/commits{/sha}","git_commits_url":"https://api.github.com/repos/npm/marky-markdown/git/commits{/sha}","comments_url":"https://api.github.com/repos/npm/marky-markdown/comments{/number}","issue_comment_url":"https://api.github.com/repos/npm/marky-markdown/issues/comments{/number}","contents_url":"https://api.github.com/repos/npm/marky-markdown/contents/{+path}","compare_url":"https://api.github.com/repos/npm/marky-markdown/compare/{base}...{head}","merges_url":"https://api.github.com/repos/npm/marky-markdown/merges","archive_url":"https://api.github.com/repos/npm/marky-markdown/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/npm/marky-markdown/downloads","issues_url":"https://api.github.com/repos/npm/marky-markdown/issues{/number}","pulls_url":"https://api.github.com/repos/npm/marky-markdown/pulls{/number}","milestones_url":"https://api.github.com/repos/npm/marky-markdown/milestones{/number}","notifications_url":"https://api.github.com/repos/npm/marky-markdown/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/npm/marky-markdown/labels{/name}","releases_url":"https://api.github.com/repos/npm/marky-markdown/releases{/id}","deployments_url":"https://api.github.com/repos/npm/marky-markdown/deployments","created_at":"2014-12-14T05:36:22Z","updated_at":"2016-02-19T12:39:58Z","pushed_at":"2016-02-19T22:57:59Z","git_url":"git://github.com/npm/marky-markdown.git","ssh_url":"git@github.com:npm/marky-markdown.git","clone_url":"https://github.com/npm/marky-markdown.git","svn_url":"https://github.com/npm/marky-markdown","homepage":"http://npm.im/marky-markdown","size":351,"stargazers_count":110,"watchers_count":110,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":10,"forks":21,"open_issues":10,"watchers":110,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/npm/marky-markdown/pulls/151"},"html":{"href":"https://github.com/npm/marky-markdown/pull/151"},"issue":{"href":"https://api.github.com/repos/npm/marky-markdown/issues/151"},"comments":{"href":"https://api.github.com/repos/npm/marky-markdown/issues/151/comments"},"review_comments":{"href":"https://api.github.com/repos/npm/marky-markdown/pulls/151/comments"},"review_comment":{"href":"https://api.github.com/repos/npm/marky-markdown/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/npm/marky-markdown/pulls/151/commits"},"statuses":{"href":"https://api.github.com/repos/npm/marky-markdown/statuses/b6946124b3c2703768b950343d144038fd4dfd87"}}}}