{"action":"created","comment":{"url":"https://api.github.com/repos/wagn/wagn/pulls/comments/47453131","id":47453131,"diff_hunk":"@@ -134,85 +152,99 @@ def parse_content content\n       ALLOWED_TAGS['table'] += %w[ cellpadding align border cellspacing ]\n     end\n \n-    ALLOWED_TAGS.each_key {|k|\n+    ALLOWED_TAGS.each_key do |k|\n       ALLOWED_TAGS[k] << 'class'\n       ALLOWED_TAGS[k] << 'style' if Card.config.allow_inline_styles\n       ALLOWED_TAGS[k]\n-    }\n+    end\n     ALLOWED_TAGS\n \n-    ATTR_VALUE_RE = [ /(?<=^')[^']+(?=')/, /(?<=^\")[^\"]+(?=\")/, /\\S+/ ]\n+    ATTR_VALUE_RE = [/(?<=^')[^']+(?=')/, /(?<=^\")[^\"]+(?=\")/, /\\S+/]\n \n     class << self\n-\n       ## Method that cleans the String of HTML tags\n       ## and attributes outside of the allowed list.\n \n       # this has been hacked for card to allow classes if\n       # the class begins with \"w-\"\n-      def clean!( string, tags = ALLOWED_TAGS )\n-        string.gsub( /<(\\/*)(\\w+)([^>]*)>/ ) do\n+      def clean!(string, tags=ALLOWED_TAGS)\n+        string.gsub(/<(\\/*)(\\w+)([^>]*)>/) do\n           raw = $~\n           tag = raw[2].downcase\n-          if attrs = tags[tag]\n-            \"<#{raw[1]}#{\n+          if (attrs = tags[tag])\n+            html_attribs =\n               attrs.inject([tag]) do |pcs, attr|\n-                q='\"'\n-                rest_value=nil\n+                q = '\"'\n+                rest_value = nil\n                 if raw[3] =~ /\\b#{attr}\\s*=\\s*(?=(.))/i\n                   rest_value = $'\n-                  idx = %w{' \"}.index($1) and q = $1\n-                  re = ATTR_VALUE_RE[ idx || 2 ]\n-                  if match = rest_value.match(re)\n+                  (idx = %w{' \"}.index($1)) && (q = $1)\n+                  re = ATTR_VALUE_RE[idx || 2]\n+                  if (match = rest_value.match(re))\n                     rest_value = match[0]\n                     if attr == 'class'\n-                      rest_value = rest_value.split(/\\s+/).find_all {|s| s=~/^w-/i}*' '\n+                      rest_value =\n+                        rest_value.split(/\\s+/).select do |s|\n+                          s =~ /^w-/i\n+                        end * ' '\n                     end\n                   end\n                 end\n                 pcs << \"#{attr}=#{q}#{rest_value}#{q}\" unless rest_value.blank?\n                 pcs\n               end * ' '\n-            }>\"\n+            \"<#{raw[1]}#{html_attribs}>\"\n           else\n-            \" \"\n+            ' '\n           end\n         end.gsub(/<\\!--.*?-->/, '')\n       end\n \n       if Card.config.space_last_in_multispace\n-        def clean_with_space_last! string, tags = ALLOWED_TAGS\n-          clean_without_space_last!(string, tags).gsub(/(?:^|\\b) ((?:&nbsp;)+)/, '\\1 ')\n+        def clean_with_space_last! string, tags=ALLOWED_TAGS\n+          cwo = clean_without_space_last!(string, tags)\n+          cwo.gsub(/(?:^|\\b) ((?:&nbsp;)+)/, '\\1 ')\n         end\n         alias_method_chain :clean!, :space_last\n       end\n-      def truncatewords_with_closing_tags(input, words = 25, truncate_string = \"...\")\n+\n+      def truncatewords_with_closing_tags input, words=25, truncate_string='...'\n         if input.nil? then return end\n         wordlist = input.to_s.split\n         l = words.to_i - 1\n         l = 0 if l < 0\n-        wordstring = wordlist.length > l ? wordlist[0..l].join(\" \") : input.to_s\n+        wordstring = wordlist.length > l ? wordlist[0..l].join(' ') : input.to_s\n         # nuke partial tags at end of snippet\n-        wordstring.gsub!(/(<[^\\>]+)$/,'')\n+        wordstring.gsub!(/(<[^\\>]+)$/, '')\n \n         tags = []\n \n         # match tags with or without self closing (ie. <foo />)\n-        wordstring.scan(/\\<([^\\>\\s\\/]+)[^\\>]*?\\>/).each { |t| tags.unshift(t[0]) }\n+        wordstring.scan(/\\<([^\\>\\s\\/]+)[^\\>]*?\\>/).each do |t|\n+          tags.unshift(t[0])\n+        end\n         # match tags with self closing and mark them as closed\n-        wordstring.scan(/\\<([^\\>\\s\\/]+)[^\\>]*?\\/\\>/).each { |t| if !(x=tags.index(t[0])).nil? then tags.slice!(x) end }\n+        wordstring.scan(/\\<([^\\>\\s\\/]+)[^\\>]*?\\/\\>/).each do |t|","path":"card/lib/card/content.rb","position":262,"original_position":262,"commit_id":"7e45f0b9b16780f52563a53dc54b8854f4da557f","original_commit_id":"7e45f0b9b16780f52563a53dc54b8854f4da557f","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Use `%r` around regular expression.","created_at":"2015-12-14T00:00:05Z","updated_at":"2015-12-14T00:00:05Z","html_url":"https://github.com/wagn/wagn/pull/548#discussion_r47453131","pull_request_url":"https://api.github.com/repos/wagn/wagn/pulls/548","_links":{"self":{"href":"https://api.github.com/repos/wagn/wagn/pulls/comments/47453131"},"html":{"href":"https://github.com/wagn/wagn/pull/548#discussion_r47453131"},"pull_request":{"href":"https://api.github.com/repos/wagn/wagn/pulls/548"}}},"pull_request":{"url":"https://api.github.com/repos/wagn/wagn/pulls/548","id":53514054,"html_url":"https://github.com/wagn/wagn/pull/548","diff_url":"https://github.com/wagn/wagn/pull/548.diff","patch_url":"https://github.com/wagn/wagn/pull/548.patch","issue_url":"https://api.github.com/repos/wagn/wagn/issues/548","number":548,"state":"open","locked":false,"title":"Hounding","user":{"login":"ethn","id":21904,"avatar_url":"https://avatars.githubusercontent.com/u/21904?v=3","gravatar_id":"","url":"https://api.github.com/users/ethn","html_url":"https://github.com/ethn","followers_url":"https://api.github.com/users/ethn/followers","following_url":"https://api.github.com/users/ethn/following{/other_user}","gists_url":"https://api.github.com/users/ethn/gists{/gist_id}","starred_url":"https://api.github.com/users/ethn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethn/subscriptions","organizations_url":"https://api.github.com/users/ethn/orgs","repos_url":"https://api.github.com/users/ethn/repos","events_url":"https://api.github.com/users/ethn/events{/privacy}","received_events_url":"https://api.github.com/users/ethn/received_events","type":"User","site_admin":false},"body":"more code cleanup","created_at":"2015-12-13T23:59:49Z","updated_at":"2015-12-14T00:00:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9ea757b0a09546997266b9c3abe0241e9e681921","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wagn/wagn/pulls/548/commits","review_comments_url":"https://api.github.com/repos/wagn/wagn/pulls/548/comments","review_comment_url":"https://api.github.com/repos/wagn/wagn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wagn/wagn/issues/548/comments","statuses_url":"https://api.github.com/repos/wagn/wagn/statuses/7e45f0b9b16780f52563a53dc54b8854f4da557f","head":{"label":"ethn:hounding","ref":"hounding","sha":"7e45f0b9b16780f52563a53dc54b8854f4da557f","user":{"login":"ethn","id":21904,"avatar_url":"https://avatars.githubusercontent.com/u/21904?v=3","gravatar_id":"","url":"https://api.github.com/users/ethn","html_url":"https://github.com/ethn","followers_url":"https://api.github.com/users/ethn/followers","following_url":"https://api.github.com/users/ethn/following{/other_user}","gists_url":"https://api.github.com/users/ethn/gists{/gist_id}","starred_url":"https://api.github.com/users/ethn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethn/subscriptions","organizations_url":"https://api.github.com/users/ethn/orgs","repos_url":"https://api.github.com/users/ethn/repos","events_url":"https://api.github.com/users/ethn/events{/privacy}","received_events_url":"https://api.github.com/users/ethn/received_events","type":"User","site_admin":false},"repo":{"id":379894,"name":"wagn","full_name":"ethn/wagn","owner":{"login":"ethn","id":21904,"avatar_url":"https://avatars.githubusercontent.com/u/21904?v=3","gravatar_id":"","url":"https://api.github.com/users/ethn","html_url":"https://github.com/ethn","followers_url":"https://api.github.com/users/ethn/followers","following_url":"https://api.github.com/users/ethn/following{/other_user}","gists_url":"https://api.github.com/users/ethn/gists{/gist_id}","starred_url":"https://api.github.com/users/ethn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethn/subscriptions","organizations_url":"https://api.github.com/users/ethn/orgs","repos_url":"https://api.github.com/users/ethn/repos","events_url":"https://api.github.com/users/ethn/events{/privacy}","received_events_url":"https://api.github.com/users/ethn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ethn/wagn","description":"the wiki on wheels: a Ruby on Rails app for building dynamic, structured websites out of wiki cards","fork":true,"url":"https://api.github.com/repos/ethn/wagn","forks_url":"https://api.github.com/repos/ethn/wagn/forks","keys_url":"https://api.github.com/repos/ethn/wagn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethn/wagn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethn/wagn/teams","hooks_url":"https://api.github.com/repos/ethn/wagn/hooks","issue_events_url":"https://api.github.com/repos/ethn/wagn/issues/events{/number}","events_url":"https://api.github.com/repos/ethn/wagn/events","assignees_url":"https://api.github.com/repos/ethn/wagn/assignees{/user}","branches_url":"https://api.github.com/repos/ethn/wagn/branches{/branch}","tags_url":"https://api.github.com/repos/ethn/wagn/tags","blobs_url":"https://api.github.com/repos/ethn/wagn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethn/wagn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethn/wagn/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethn/wagn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethn/wagn/statuses/{sha}","languages_url":"https://api.github.com/repos/ethn/wagn/languages","stargazers_url":"https://api.github.com/repos/ethn/wagn/stargazers","contributors_url":"https://api.github.com/repos/ethn/wagn/contributors","subscribers_url":"https://api.github.com/repos/ethn/wagn/subscribers","subscription_url":"https://api.github.com/repos/ethn/wagn/subscription","commits_url":"https://api.github.com/repos/ethn/wagn/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethn/wagn/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethn/wagn/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethn/wagn/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethn/wagn/contents/{+path}","compare_url":"https://api.github.com/repos/ethn/wagn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethn/wagn/merges","archive_url":"https://api.github.com/repos/ethn/wagn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethn/wagn/downloads","issues_url":"https://api.github.com/repos/ethn/wagn/issues{/number}","pulls_url":"https://api.github.com/repos/ethn/wagn/pulls{/number}","milestones_url":"https://api.github.com/repos/ethn/wagn/milestones{/number}","notifications_url":"https://api.github.com/repos/ethn/wagn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethn/wagn/labels{/name}","releases_url":"https://api.github.com/repos/ethn/wagn/releases{/id}","created_at":"2009-11-20T19:39:26Z","updated_at":"2015-05-08T05:27:33Z","pushed_at":"2015-12-13T23:59:32Z","git_url":"git://github.com/ethn/wagn.git","ssh_url":"git@github.com:ethn/wagn.git","clone_url":"https://github.com/ethn/wagn.git","svn_url":"https://github.com/ethn/wagn","homepage":"http://www.wagn.org","size":57399,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"wagn:master","ref":"master","sha":"d4736cd6c10a9a898503ba87c2ad0866c9e290e5","user":{"login":"wagn","id":20722,"avatar_url":"https://avatars.githubusercontent.com/u/20722?v=3","gravatar_id":"","url":"https://api.github.com/users/wagn","html_url":"https://github.com/wagn","followers_url":"https://api.github.com/users/wagn/followers","following_url":"https://api.github.com/users/wagn/following{/other_user}","gists_url":"https://api.github.com/users/wagn/gists{/gist_id}","starred_url":"https://api.github.com/users/wagn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wagn/subscriptions","organizations_url":"https://api.github.com/users/wagn/orgs","repos_url":"https://api.github.com/users/wagn/repos","events_url":"https://api.github.com/users/wagn/events{/privacy}","received_events_url":"https://api.github.com/users/wagn/received_events","type":"User","site_admin":false},"repo":{"id":44462,"name":"wagn","full_name":"wagn/wagn","owner":{"login":"wagn","id":20722,"avatar_url":"https://avatars.githubusercontent.com/u/20722?v=3","gravatar_id":"","url":"https://api.github.com/users/wagn","html_url":"https://github.com/wagn","followers_url":"https://api.github.com/users/wagn/followers","following_url":"https://api.github.com/users/wagn/following{/other_user}","gists_url":"https://api.github.com/users/wagn/gists{/gist_id}","starred_url":"https://api.github.com/users/wagn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wagn/subscriptions","organizations_url":"https://api.github.com/users/wagn/orgs","repos_url":"https://api.github.com/users/wagn/repos","events_url":"https://api.github.com/users/wagn/events{/privacy}","received_events_url":"https://api.github.com/users/wagn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wagn/wagn","description":"Ruby on rails wiki platform for collaborating to build custom web systems","fork":false,"url":"https://api.github.com/repos/wagn/wagn","forks_url":"https://api.github.com/repos/wagn/wagn/forks","keys_url":"https://api.github.com/repos/wagn/wagn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wagn/wagn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wagn/wagn/teams","hooks_url":"https://api.github.com/repos/wagn/wagn/hooks","issue_events_url":"https://api.github.com/repos/wagn/wagn/issues/events{/number}","events_url":"https://api.github.com/repos/wagn/wagn/events","assignees_url":"https://api.github.com/repos/wagn/wagn/assignees{/user}","branches_url":"https://api.github.com/repos/wagn/wagn/branches{/branch}","tags_url":"https://api.github.com/repos/wagn/wagn/tags","blobs_url":"https://api.github.com/repos/wagn/wagn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wagn/wagn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wagn/wagn/git/refs{/sha}","trees_url":"https://api.github.com/repos/wagn/wagn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wagn/wagn/statuses/{sha}","languages_url":"https://api.github.com/repos/wagn/wagn/languages","stargazers_url":"https://api.github.com/repos/wagn/wagn/stargazers","contributors_url":"https://api.github.com/repos/wagn/wagn/contributors","subscribers_url":"https://api.github.com/repos/wagn/wagn/subscribers","subscription_url":"https://api.github.com/repos/wagn/wagn/subscription","commits_url":"https://api.github.com/repos/wagn/wagn/commits{/sha}","git_commits_url":"https://api.github.com/repos/wagn/wagn/git/commits{/sha}","comments_url":"https://api.github.com/repos/wagn/wagn/comments{/number}","issue_comment_url":"https://api.github.com/repos/wagn/wagn/issues/comments{/number}","contents_url":"https://api.github.com/repos/wagn/wagn/contents/{+path}","compare_url":"https://api.github.com/repos/wagn/wagn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wagn/wagn/merges","archive_url":"https://api.github.com/repos/wagn/wagn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wagn/wagn/downloads","issues_url":"https://api.github.com/repos/wagn/wagn/issues{/number}","pulls_url":"https://api.github.com/repos/wagn/wagn/pulls{/number}","milestones_url":"https://api.github.com/repos/wagn/wagn/milestones{/number}","notifications_url":"https://api.github.com/repos/wagn/wagn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wagn/wagn/labels{/name}","releases_url":"https://api.github.com/repos/wagn/wagn/releases{/id}","created_at":"2008-08-21T00:36:11Z","updated_at":"2015-12-13T18:50:46Z","pushed_at":"2015-12-13T23:59:49Z","git_url":"git://github.com/wagn/wagn.git","ssh_url":"git@github.com:wagn/wagn.git","clone_url":"https://github.com/wagn/wagn.git","svn_url":"https://github.com/wagn/wagn","homepage":"http://www.wagn.org","size":58106,"stargazers_count":258,"watchers_count":258,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":54,"mirror_url":null,"open_issues_count":11,"forks":54,"open_issues":11,"watchers":258,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wagn/wagn/pulls/548"},"html":{"href":"https://github.com/wagn/wagn/pull/548"},"issue":{"href":"https://api.github.com/repos/wagn/wagn/issues/548"},"comments":{"href":"https://api.github.com/repos/wagn/wagn/issues/548/comments"},"review_comments":{"href":"https://api.github.com/repos/wagn/wagn/pulls/548/comments"},"review_comment":{"href":"https://api.github.com/repos/wagn/wagn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wagn/wagn/pulls/548/commits"},"statuses":{"href":"https://api.github.com/repos/wagn/wagn/statuses/7e45f0b9b16780f52563a53dc54b8854f4da557f"}}}}