{"action":"created","comment":{"url":"https://api.github.com/repos/bardsoftware/ace/pulls/comments/25950486","id":25950486,"diff_hunk":"@@ -1,30 +1,59 @@\n define(function(require, exports, module) {\n \"use strict\";\n \n-var WORD_PATTERN = \"[a-zA-Zа-яА-ЯёЁ]+\";\n-var WORD_REGEX = new RegExp(\"^\" + WORD_PATTERN);\n+var WORD_REGEX = /^[a-zа-яё]+/i,\n+    // % * <foo@bar.com> 2015-01-12T00:17:27.829Z:\n+    DISCUSSION_COMMENT_REGEXP = /^\\s*%\\s([\\*\\^])\\s<(.+)>(\\s(.+))?:$/,\n+    DISCUSSION_TEXT_ROW_REGEXP = /^\\s*%\\s*(.*)/;\n \n var LatexParser = exports.LatexParser = function(bgTokenizer) {\n     this.myErrors = [];\n+    this.myDiscussions = [];\n     this.myTokenizer = bgTokenizer;\n };\n \n (function(){\n+    this.setSpellingCheckDictionary = function(dictionary) {\n+        this.myDictionary = dictionary;\n+    };\n \n-    this.go = function(doc, dictionary){\n-        if (dictionary == null) {\n+    /**\n+     * Parse the document\n+     * @param doc              document object\n+     * @param doSpellcheck     true if we want spellcheck\n+     * @param doGetDiscussions true if we want get text comments\n+     */\n+    this.go = function(doc, doSpellcheck, doGetDiscussions) {\n+        if (doSpellcheck && this.myDictionary === null) {\n+            // can't spellcheck without dictionary\n+            doSpellcheck = false;\n+        }\n+        if (!doSpellcheck && !doGetDiscussions) {\n+            // there is nothing to do\n             return;\n         }\n+\n         var lines = doc.getAllLines();\n \n         this.myErrors = [];\n+        this.myDiscussions = [];\n+        this.myLastReadDiscussionComment = null;\n \n         for (var row = 0, linesLength = lines.length; row < linesLength; ++row) {\n             var line = lines[row];\n             var tokens = this.myTokenizer.getTokens(row);\n \n             var column = 0;\n-            for (var j = 0, tokenLength = tokens.length; j < tokenLength; ++j) {\n+            var tokenLength = tokens.length;\n+            // stop parse discussion on empty line\n+            // otherwise we will add a regular comment to the discussion:\n+            //     % DISCUSSION\n+            //     EMPTY_LINE\n+            //     % REGULAR COMMENT\n+            if (tokenLength === 0) {\n+              doGetDiscussions && saveLastReadDiscussionComment.call(this);\n+            }\n+            for (var j = 0; j < tokenLength; ++j) {","path":"lib/ace/mode/latex_parser.js","position":61,"original_position":61,"commit_id":"d85eefd0bf9499dac80f44897716ea3f07c89a8b","original_commit_id":"d85eefd0bf9499dac80f44897716ea3f07c89a8b","user":{"login":"agudulin","id":492261,"avatar_url":"https://avatars.githubusercontent.com/u/492261?v=3","gravatar_id":"","url":"https://api.github.com/users/agudulin","html_url":"https://github.com/agudulin","followers_url":"https://api.github.com/users/agudulin/followers","following_url":"https://api.github.com/users/agudulin/following{/other_user}","gists_url":"https://api.github.com/users/agudulin/gists{/gist_id}","starred_url":"https://api.github.com/users/agudulin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agudulin/subscriptions","organizations_url":"https://api.github.com/users/agudulin/orgs","repos_url":"https://api.github.com/users/agudulin/repos","events_url":"https://api.github.com/users/agudulin/events{/privacy}","received_events_url":"https://api.github.com/users/agudulin/received_events","type":"User","site_admin":false},"body":"Nothing special. If it causes questions, it's better to use `j++` :)","created_at":"2015-03-06T15:13:25Z","updated_at":"2015-03-06T15:13:25Z","html_url":"https://github.com/bardsoftware/ace/pull/11#discussion_r25950486","pull_request_url":"https://api.github.com/repos/bardsoftware/ace/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/bardsoftware/ace/pulls/comments/25950486"},"html":{"href":"https://github.com/bardsoftware/ace/pull/11#discussion_r25950486"},"pull_request":{"href":"https://api.github.com/repos/bardsoftware/ace/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/bardsoftware/ace/pulls/11","id":27198573,"html_url":"https://github.com/bardsoftware/ace/pull/11","diff_url":"https://github.com/bardsoftware/ace/pull/11.diff","patch_url":"https://github.com/bardsoftware/ace/pull/11.patch","issue_url":"https://api.github.com/repos/bardsoftware/ace/issues/11","number":11,"state":"open","locked":false,"title":"Text comments parser","user":{"login":"agudulin","id":492261,"avatar_url":"https://avatars.githubusercontent.com/u/492261?v=3","gravatar_id":"","url":"https://api.github.com/users/agudulin","html_url":"https://github.com/agudulin","followers_url":"https://api.github.com/users/agudulin/followers","following_url":"https://api.github.com/users/agudulin/following{/other_user}","gists_url":"https://api.github.com/users/agudulin/gists{/gist_id}","starred_url":"https://api.github.com/users/agudulin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agudulin/subscriptions","organizations_url":"https://api.github.com/users/agudulin/orgs","repos_url":"https://api.github.com/users/agudulin/repos","events_url":"https://api.github.com/users/agudulin/events{/privacy}","received_events_url":"https://api.github.com/users/agudulin/received_events","type":"User","site_admin":false},"body":"Now we can parse text comments in the following format:\r\n```latex\r\n% ...\r\n% * <foo@bar.com> 2015-01-11T00:17:27.829Z:\r\n% test comment 1\r\n% * <foo@bar.com> 2015-01-12T00:17:27.829Z:\r\n% test comment 2\r\n% ^ <bar@foo.com> 2015-01-14T00:19:27.829Z:\r\n% test reply\r\n% ...\r\n```","created_at":"2015-01-12T14:48:31Z","updated_at":"2015-03-06T15:13:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e67b5f77b1e1931904c3f70560b9edf6c621719f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bardsoftware/ace/pulls/11/commits","review_comments_url":"https://api.github.com/repos/bardsoftware/ace/pulls/11/comments","review_comment_url":"https://api.github.com/repos/bardsoftware/ace/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bardsoftware/ace/issues/11/comments","statuses_url":"https://api.github.com/repos/bardsoftware/ace/statuses/d85eefd0bf9499dac80f44897716ea3f07c89a8b","head":{"label":"bardsoftware:latex_spellchecking","ref":"latex_spellchecking","sha":"d85eefd0bf9499dac80f44897716ea3f07c89a8b","user":{"login":"bardsoftware","id":2625618,"avatar_url":"https://avatars.githubusercontent.com/u/2625618?v=3","gravatar_id":"","url":"https://api.github.com/users/bardsoftware","html_url":"https://github.com/bardsoftware","followers_url":"https://api.github.com/users/bardsoftware/followers","following_url":"https://api.github.com/users/bardsoftware/following{/other_user}","gists_url":"https://api.github.com/users/bardsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/bardsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bardsoftware/subscriptions","organizations_url":"https://api.github.com/users/bardsoftware/orgs","repos_url":"https://api.github.com/users/bardsoftware/repos","events_url":"https://api.github.com/users/bardsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/bardsoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":13590146,"name":"ace","full_name":"bardsoftware/ace","owner":{"login":"bardsoftware","id":2625618,"avatar_url":"https://avatars.githubusercontent.com/u/2625618?v=3","gravatar_id":"","url":"https://api.github.com/users/bardsoftware","html_url":"https://github.com/bardsoftware","followers_url":"https://api.github.com/users/bardsoftware/followers","following_url":"https://api.github.com/users/bardsoftware/following{/other_user}","gists_url":"https://api.github.com/users/bardsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/bardsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bardsoftware/subscriptions","organizations_url":"https://api.github.com/users/bardsoftware/orgs","repos_url":"https://api.github.com/users/bardsoftware/repos","events_url":"https://api.github.com/users/bardsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/bardsoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bardsoftware/ace","description":"Ace (Ajax.org Cloud9 Editor)","fork":true,"url":"https://api.github.com/repos/bardsoftware/ace","forks_url":"https://api.github.com/repos/bardsoftware/ace/forks","keys_url":"https://api.github.com/repos/bardsoftware/ace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bardsoftware/ace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bardsoftware/ace/teams","hooks_url":"https://api.github.com/repos/bardsoftware/ace/hooks","issue_events_url":"https://api.github.com/repos/bardsoftware/ace/issues/events{/number}","events_url":"https://api.github.com/repos/bardsoftware/ace/events","assignees_url":"https://api.github.com/repos/bardsoftware/ace/assignees{/user}","branches_url":"https://api.github.com/repos/bardsoftware/ace/branches{/branch}","tags_url":"https://api.github.com/repos/bardsoftware/ace/tags","blobs_url":"https://api.github.com/repos/bardsoftware/ace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bardsoftware/ace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bardsoftware/ace/git/refs{/sha}","trees_url":"https://api.github.com/repos/bardsoftware/ace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bardsoftware/ace/statuses/{sha}","languages_url":"https://api.github.com/repos/bardsoftware/ace/languages","stargazers_url":"https://api.github.com/repos/bardsoftware/ace/stargazers","contributors_url":"https://api.github.com/repos/bardsoftware/ace/contributors","subscribers_url":"https://api.github.com/repos/bardsoftware/ace/subscribers","subscription_url":"https://api.github.com/repos/bardsoftware/ace/subscription","commits_url":"https://api.github.com/repos/bardsoftware/ace/commits{/sha}","git_commits_url":"https://api.github.com/repos/bardsoftware/ace/git/commits{/sha}","comments_url":"https://api.github.com/repos/bardsoftware/ace/comments{/number}","issue_comment_url":"https://api.github.com/repos/bardsoftware/ace/issues/comments{/number}","contents_url":"https://api.github.com/repos/bardsoftware/ace/contents/{+path}","compare_url":"https://api.github.com/repos/bardsoftware/ace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bardsoftware/ace/merges","archive_url":"https://api.github.com/repos/bardsoftware/ace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bardsoftware/ace/downloads","issues_url":"https://api.github.com/repos/bardsoftware/ace/issues{/number}","pulls_url":"https://api.github.com/repos/bardsoftware/ace/pulls{/number}","milestones_url":"https://api.github.com/repos/bardsoftware/ace/milestones{/number}","notifications_url":"https://api.github.com/repos/bardsoftware/ace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bardsoftware/ace/labels{/name}","releases_url":"https://api.github.com/repos/bardsoftware/ace/releases{/id}","created_at":"2013-10-15T13:03:16Z","updated_at":"2015-01-01T15:01:29Z","pushed_at":"2015-03-05T16:26:42Z","git_url":"git://github.com/bardsoftware/ace.git","ssh_url":"git@github.com:bardsoftware/ace.git","clone_url":"https://github.com/bardsoftware/ace.git","svn_url":"https://github.com/bardsoftware/ace","homepage":"http://ace.c9.io","size":31128,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"base":{"label":"bardsoftware:master","ref":"master","sha":"50f0078c48d7c012525278ae79f84e81b45a3d1b","user":{"login":"bardsoftware","id":2625618,"avatar_url":"https://avatars.githubusercontent.com/u/2625618?v=3","gravatar_id":"","url":"https://api.github.com/users/bardsoftware","html_url":"https://github.com/bardsoftware","followers_url":"https://api.github.com/users/bardsoftware/followers","following_url":"https://api.github.com/users/bardsoftware/following{/other_user}","gists_url":"https://api.github.com/users/bardsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/bardsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bardsoftware/subscriptions","organizations_url":"https://api.github.com/users/bardsoftware/orgs","repos_url":"https://api.github.com/users/bardsoftware/repos","events_url":"https://api.github.com/users/bardsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/bardsoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":13590146,"name":"ace","full_name":"bardsoftware/ace","owner":{"login":"bardsoftware","id":2625618,"avatar_url":"https://avatars.githubusercontent.com/u/2625618?v=3","gravatar_id":"","url":"https://api.github.com/users/bardsoftware","html_url":"https://github.com/bardsoftware","followers_url":"https://api.github.com/users/bardsoftware/followers","following_url":"https://api.github.com/users/bardsoftware/following{/other_user}","gists_url":"https://api.github.com/users/bardsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/bardsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bardsoftware/subscriptions","organizations_url":"https://api.github.com/users/bardsoftware/orgs","repos_url":"https://api.github.com/users/bardsoftware/repos","events_url":"https://api.github.com/users/bardsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/bardsoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bardsoftware/ace","description":"Ace (Ajax.org Cloud9 Editor)","fork":true,"url":"https://api.github.com/repos/bardsoftware/ace","forks_url":"https://api.github.com/repos/bardsoftware/ace/forks","keys_url":"https://api.github.com/repos/bardsoftware/ace/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bardsoftware/ace/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bardsoftware/ace/teams","hooks_url":"https://api.github.com/repos/bardsoftware/ace/hooks","issue_events_url":"https://api.github.com/repos/bardsoftware/ace/issues/events{/number}","events_url":"https://api.github.com/repos/bardsoftware/ace/events","assignees_url":"https://api.github.com/repos/bardsoftware/ace/assignees{/user}","branches_url":"https://api.github.com/repos/bardsoftware/ace/branches{/branch}","tags_url":"https://api.github.com/repos/bardsoftware/ace/tags","blobs_url":"https://api.github.com/repos/bardsoftware/ace/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bardsoftware/ace/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bardsoftware/ace/git/refs{/sha}","trees_url":"https://api.github.com/repos/bardsoftware/ace/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bardsoftware/ace/statuses/{sha}","languages_url":"https://api.github.com/repos/bardsoftware/ace/languages","stargazers_url":"https://api.github.com/repos/bardsoftware/ace/stargazers","contributors_url":"https://api.github.com/repos/bardsoftware/ace/contributors","subscribers_url":"https://api.github.com/repos/bardsoftware/ace/subscribers","subscription_url":"https://api.github.com/repos/bardsoftware/ace/subscription","commits_url":"https://api.github.com/repos/bardsoftware/ace/commits{/sha}","git_commits_url":"https://api.github.com/repos/bardsoftware/ace/git/commits{/sha}","comments_url":"https://api.github.com/repos/bardsoftware/ace/comments{/number}","issue_comment_url":"https://api.github.com/repos/bardsoftware/ace/issues/comments{/number}","contents_url":"https://api.github.com/repos/bardsoftware/ace/contents/{+path}","compare_url":"https://api.github.com/repos/bardsoftware/ace/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bardsoftware/ace/merges","archive_url":"https://api.github.com/repos/bardsoftware/ace/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bardsoftware/ace/downloads","issues_url":"https://api.github.com/repos/bardsoftware/ace/issues{/number}","pulls_url":"https://api.github.com/repos/bardsoftware/ace/pulls{/number}","milestones_url":"https://api.github.com/repos/bardsoftware/ace/milestones{/number}","notifications_url":"https://api.github.com/repos/bardsoftware/ace/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bardsoftware/ace/labels{/name}","releases_url":"https://api.github.com/repos/bardsoftware/ace/releases{/id}","created_at":"2013-10-15T13:03:16Z","updated_at":"2015-01-01T15:01:29Z","pushed_at":"2015-03-05T16:26:42Z","git_url":"git://github.com/bardsoftware/ace.git","ssh_url":"git@github.com:bardsoftware/ace.git","clone_url":"https://github.com/bardsoftware/ace.git","svn_url":"https://github.com/bardsoftware/ace","homepage":"http://ace.c9.io","size":31128,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bardsoftware/ace/pulls/11"},"html":{"href":"https://github.com/bardsoftware/ace/pull/11"},"issue":{"href":"https://api.github.com/repos/bardsoftware/ace/issues/11"},"comments":{"href":"https://api.github.com/repos/bardsoftware/ace/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/bardsoftware/ace/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/bardsoftware/ace/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bardsoftware/ace/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/bardsoftware/ace/statuses/d85eefd0bf9499dac80f44897716ea3f07c89a8b"}}}}