{"action":"created","comment":{"url":"https://api.github.com/repos/luuse/spock/pulls/comments/30587209","id":30587209,"diff_hunk":"@@ -0,0 +1,89 @@\n+package spock.traits;\n+\n+import com.fasterxml.jackson.databind.JsonNode;\n+import com.fasterxml.jackson.databind.ObjectMapper;\n+import com.fasterxml.jackson.databind.node.ObjectNode;\n+\n+import java.util.regex.Matcher;\n+import java.util.regex.Pattern;\n+\n+\n+public class InfoBoxTrait extends Trait {\n+\n+    private static final Pattern INFOBOX_START = Pattern.compile(\"\\\\{\\\\{Infobox.*\\n\");\n+    private static final Pattern INFOBOX_STOP = Pattern.compile(\"\\\\n\\\\}\\\\}\\\\n\");\n+\n+    @Override\n+    boolean applyThis(JsonNode article, ObjectNode output) {\n+\n+        String text = Utils.getTextAreaBetween(article, INFOBOX_START, INFOBOX_STOP);\n+        return applyText(text, output);\n+    }\n+\n+    public boolean applyText(String text, ObjectNode output) {\n+        ObjectMapper mapper = new ObjectMapper();\n+\n+\n+        output.put(\"name\", getTerm(text, \"name\"));\n+\n+        String heightText = getTerm(text, \"height\");\n+        if (heightText != null) {\n+            ObjectNode height = mapper.createObjectNode();\n+            heightText = removeRef(heightText);\n+\n+            height.put(\"value\", getFirstFloatValue(heightText));\n+            //TODO: Parse unit?\n+            height.put(\"unit\", \"\");\n+            output.set(\"height\", height);\n+        }\n+\n+\n+        ObjectNode birth = mapper.createObjectNode();\n+        birth.put(\"place\", clearBrackets(getTerm(text, \"birth_place\")));\n+        birth.put(\"name\", getTerm(text, \"birth_name\"));\n+        output.set(\"birth\", birth);\n+\n+\n+        return false;\n+    }\n+\n+    /**\n+     * |image         = President Barack Obama.jpg\n+     *\n+     * @param key\n+     * @return\n+     */\n+    private String getTerm(String text, String key) {\n+        Pattern pattern = Pattern.compile(\"\\\\|\\\\s?(\" + key + \")\\\\s*=\\\\s(.+?)\\\\n\");","path":"parser/src/main/java/spock/traits/InfoBoxTrait.java","position":57,"original_position":57,"commit_id":"2e77b08d65796f16142872fcfc2b966740eb3251","original_commit_id":"2e77b08d65796f16142872fcfc2b966740eb3251","user":{"login":"luuse","id":111528,"avatar_url":"https://avatars.githubusercontent.com/u/111528?v=3","gravatar_id":"","url":"https://api.github.com/users/luuse","html_url":"https://github.com/luuse","followers_url":"https://api.github.com/users/luuse/followers","following_url":"https://api.github.com/users/luuse/following{/other_user}","gists_url":"https://api.github.com/users/luuse/gists{/gist_id}","starred_url":"https://api.github.com/users/luuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luuse/subscriptions","organizations_url":"https://api.github.com/users/luuse/orgs","repos_url":"https://api.github.com/users/luuse/repos","events_url":"https://api.github.com/users/luuse/events{/privacy}","received_events_url":"https://api.github.com/users/luuse/received_events","type":"User","site_admin":false},"body":"Precompiling patterns once can be huge sometimes. Sometimes not so well... might not make a difference in this case.","created_at":"2015-05-19T10:39:26Z","updated_at":"2015-05-19T10:39:26Z","html_url":"https://github.com/luuse/spock/pull/6#discussion_r30587209","pull_request_url":"https://api.github.com/repos/luuse/spock/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/luuse/spock/pulls/comments/30587209"},"html":{"href":"https://github.com/luuse/spock/pull/6#discussion_r30587209"},"pull_request":{"href":"https://api.github.com/repos/luuse/spock/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/luuse/spock/pulls/6","id":35699557,"html_url":"https://github.com/luuse/spock/pull/6","diff_url":"https://github.com/luuse/spock/pull/6.diff","patch_url":"https://github.com/luuse/spock/pull/6.patch","issue_url":"https://api.github.com/repos/luuse/spock/issues/6","number":6,"state":"open","locked":false,"title":"Parser improvments","user":{"login":"brodin","id":2271316,"avatar_url":"https://avatars.githubusercontent.com/u/2271316?v=3","gravatar_id":"","url":"https://api.github.com/users/brodin","html_url":"https://github.com/brodin","followers_url":"https://api.github.com/users/brodin/followers","following_url":"https://api.github.com/users/brodin/following{/other_user}","gists_url":"https://api.github.com/users/brodin/gists{/gist_id}","starred_url":"https://api.github.com/users/brodin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brodin/subscriptions","organizations_url":"https://api.github.com/users/brodin/orgs","repos_url":"https://api.github.com/users/brodin/repos","events_url":"https://api.github.com/users/brodin/events{/privacy}","received_events_url":"https://api.github.com/users/brodin/received_events","type":"User","site_admin":false},"body":"Added some more values to the parser","created_at":"2015-05-19T06:30:18Z","updated_at":"2015-05-19T10:39:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c0695539b17c9438e8b50b9996dbb6c1f2239ebe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/luuse/spock/pulls/6/commits","review_comments_url":"https://api.github.com/repos/luuse/spock/pulls/6/comments","review_comment_url":"https://api.github.com/repos/luuse/spock/pulls/comments{/number}","comments_url":"https://api.github.com/repos/luuse/spock/issues/6/comments","statuses_url":"https://api.github.com/repos/luuse/spock/statuses/2e77b08d65796f16142872fcfc2b966740eb3251","head":{"label":"luuse:parser-improvments","ref":"parser-improvments","sha":"2e77b08d65796f16142872fcfc2b966740eb3251","user":{"login":"luuse","id":111528,"avatar_url":"https://avatars.githubusercontent.com/u/111528?v=3","gravatar_id":"","url":"https://api.github.com/users/luuse","html_url":"https://github.com/luuse","followers_url":"https://api.github.com/users/luuse/followers","following_url":"https://api.github.com/users/luuse/following{/other_user}","gists_url":"https://api.github.com/users/luuse/gists{/gist_id}","starred_url":"https://api.github.com/users/luuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luuse/subscriptions","organizations_url":"https://api.github.com/users/luuse/orgs","repos_url":"https://api.github.com/users/luuse/repos","events_url":"https://api.github.com/users/luuse/events{/privacy}","received_events_url":"https://api.github.com/users/luuse/received_events","type":"User","site_admin":false},"repo":{"id":35242844,"name":"spock","full_name":"luuse/spock","owner":{"login":"luuse","id":111528,"avatar_url":"https://avatars.githubusercontent.com/u/111528?v=3","gravatar_id":"","url":"https://api.github.com/users/luuse","html_url":"https://github.com/luuse","followers_url":"https://api.github.com/users/luuse/followers","following_url":"https://api.github.com/users/luuse/following{/other_user}","gists_url":"https://api.github.com/users/luuse/gists{/gist_id}","starred_url":"https://api.github.com/users/luuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luuse/subscriptions","organizations_url":"https://api.github.com/users/luuse/orgs","repos_url":"https://api.github.com/users/luuse/repos","events_url":"https://api.github.com/users/luuse/events{/privacy}","received_events_url":"https://api.github.com/users/luuse/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/luuse/spock","description":"","fork":false,"url":"https://api.github.com/repos/luuse/spock","forks_url":"https://api.github.com/repos/luuse/spock/forks","keys_url":"https://api.github.com/repos/luuse/spock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/luuse/spock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/luuse/spock/teams","hooks_url":"https://api.github.com/repos/luuse/spock/hooks","issue_events_url":"https://api.github.com/repos/luuse/spock/issues/events{/number}","events_url":"https://api.github.com/repos/luuse/spock/events","assignees_url":"https://api.github.com/repos/luuse/spock/assignees{/user}","branches_url":"https://api.github.com/repos/luuse/spock/branches{/branch}","tags_url":"https://api.github.com/repos/luuse/spock/tags","blobs_url":"https://api.github.com/repos/luuse/spock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/luuse/spock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/luuse/spock/git/refs{/sha}","trees_url":"https://api.github.com/repos/luuse/spock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/luuse/spock/statuses/{sha}","languages_url":"https://api.github.com/repos/luuse/spock/languages","stargazers_url":"https://api.github.com/repos/luuse/spock/stargazers","contributors_url":"https://api.github.com/repos/luuse/spock/contributors","subscribers_url":"https://api.github.com/repos/luuse/spock/subscribers","subscription_url":"https://api.github.com/repos/luuse/spock/subscription","commits_url":"https://api.github.com/repos/luuse/spock/commits{/sha}","git_commits_url":"https://api.github.com/repos/luuse/spock/git/commits{/sha}","comments_url":"https://api.github.com/repos/luuse/spock/comments{/number}","issue_comment_url":"https://api.github.com/repos/luuse/spock/issues/comments{/number}","contents_url":"https://api.github.com/repos/luuse/spock/contents/{+path}","compare_url":"https://api.github.com/repos/luuse/spock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/luuse/spock/merges","archive_url":"https://api.github.com/repos/luuse/spock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/luuse/spock/downloads","issues_url":"https://api.github.com/repos/luuse/spock/issues{/number}","pulls_url":"https://api.github.com/repos/luuse/spock/pulls{/number}","milestones_url":"https://api.github.com/repos/luuse/spock/milestones{/number}","notifications_url":"https://api.github.com/repos/luuse/spock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/luuse/spock/labels{/name}","releases_url":"https://api.github.com/repos/luuse/spock/releases{/id}","created_at":"2015-05-07T20:49:06Z","updated_at":"2015-05-07T21:40:41Z","pushed_at":"2015-05-19T10:22:15Z","git_url":"git://github.com/luuse/spock.git","ssh_url":"git@github.com:luuse/spock.git","clone_url":"https://github.com/luuse/spock.git","svn_url":"https://github.com/luuse/spock","homepage":null,"size":252,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"base":{"label":"luuse:master","ref":"master","sha":"c6877990206ef3caa8fc797236e67a52067c46d4","user":{"login":"luuse","id":111528,"avatar_url":"https://avatars.githubusercontent.com/u/111528?v=3","gravatar_id":"","url":"https://api.github.com/users/luuse","html_url":"https://github.com/luuse","followers_url":"https://api.github.com/users/luuse/followers","following_url":"https://api.github.com/users/luuse/following{/other_user}","gists_url":"https://api.github.com/users/luuse/gists{/gist_id}","starred_url":"https://api.github.com/users/luuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luuse/subscriptions","organizations_url":"https://api.github.com/users/luuse/orgs","repos_url":"https://api.github.com/users/luuse/repos","events_url":"https://api.github.com/users/luuse/events{/privacy}","received_events_url":"https://api.github.com/users/luuse/received_events","type":"User","site_admin":false},"repo":{"id":35242844,"name":"spock","full_name":"luuse/spock","owner":{"login":"luuse","id":111528,"avatar_url":"https://avatars.githubusercontent.com/u/111528?v=3","gravatar_id":"","url":"https://api.github.com/users/luuse","html_url":"https://github.com/luuse","followers_url":"https://api.github.com/users/luuse/followers","following_url":"https://api.github.com/users/luuse/following{/other_user}","gists_url":"https://api.github.com/users/luuse/gists{/gist_id}","starred_url":"https://api.github.com/users/luuse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luuse/subscriptions","organizations_url":"https://api.github.com/users/luuse/orgs","repos_url":"https://api.github.com/users/luuse/repos","events_url":"https://api.github.com/users/luuse/events{/privacy}","received_events_url":"https://api.github.com/users/luuse/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/luuse/spock","description":"","fork":false,"url":"https://api.github.com/repos/luuse/spock","forks_url":"https://api.github.com/repos/luuse/spock/forks","keys_url":"https://api.github.com/repos/luuse/spock/keys{/key_id}","collaborators_url":"https://api.github.com/repos/luuse/spock/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/luuse/spock/teams","hooks_url":"https://api.github.com/repos/luuse/spock/hooks","issue_events_url":"https://api.github.com/repos/luuse/spock/issues/events{/number}","events_url":"https://api.github.com/repos/luuse/spock/events","assignees_url":"https://api.github.com/repos/luuse/spock/assignees{/user}","branches_url":"https://api.github.com/repos/luuse/spock/branches{/branch}","tags_url":"https://api.github.com/repos/luuse/spock/tags","blobs_url":"https://api.github.com/repos/luuse/spock/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/luuse/spock/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/luuse/spock/git/refs{/sha}","trees_url":"https://api.github.com/repos/luuse/spock/git/trees{/sha}","statuses_url":"https://api.github.com/repos/luuse/spock/statuses/{sha}","languages_url":"https://api.github.com/repos/luuse/spock/languages","stargazers_url":"https://api.github.com/repos/luuse/spock/stargazers","contributors_url":"https://api.github.com/repos/luuse/spock/contributors","subscribers_url":"https://api.github.com/repos/luuse/spock/subscribers","subscription_url":"https://api.github.com/repos/luuse/spock/subscription","commits_url":"https://api.github.com/repos/luuse/spock/commits{/sha}","git_commits_url":"https://api.github.com/repos/luuse/spock/git/commits{/sha}","comments_url":"https://api.github.com/repos/luuse/spock/comments{/number}","issue_comment_url":"https://api.github.com/repos/luuse/spock/issues/comments{/number}","contents_url":"https://api.github.com/repos/luuse/spock/contents/{+path}","compare_url":"https://api.github.com/repos/luuse/spock/compare/{base}...{head}","merges_url":"https://api.github.com/repos/luuse/spock/merges","archive_url":"https://api.github.com/repos/luuse/spock/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/luuse/spock/downloads","issues_url":"https://api.github.com/repos/luuse/spock/issues{/number}","pulls_url":"https://api.github.com/repos/luuse/spock/pulls{/number}","milestones_url":"https://api.github.com/repos/luuse/spock/milestones{/number}","notifications_url":"https://api.github.com/repos/luuse/spock/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/luuse/spock/labels{/name}","releases_url":"https://api.github.com/repos/luuse/spock/releases{/id}","created_at":"2015-05-07T20:49:06Z","updated_at":"2015-05-07T21:40:41Z","pushed_at":"2015-05-19T10:22:15Z","git_url":"git://github.com/luuse/spock.git","ssh_url":"git@github.com:luuse/spock.git","clone_url":"https://github.com/luuse/spock.git","svn_url":"https://github.com/luuse/spock","homepage":null,"size":252,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":8,"forks":0,"open_issues":8,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/luuse/spock/pulls/6"},"html":{"href":"https://github.com/luuse/spock/pull/6"},"issue":{"href":"https://api.github.com/repos/luuse/spock/issues/6"},"comments":{"href":"https://api.github.com/repos/luuse/spock/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/luuse/spock/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/luuse/spock/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/luuse/spock/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/luuse/spock/statuses/2e77b08d65796f16142872fcfc2b966740eb3251"}}}}