{"action":"created","comment":{"url":"https://api.github.com/repos/Khan/KaTeX/pulls/comments/89702855","pull_request_review_id":10240976,"id":89702855,"diff_hunk":"@@ -17,18 +17,60 @@ var utils = require(\"./utils\");\n \n var makeSpan = buildCommon.makeSpan;\n \n+var isSpace = function(node) {\n+    return node instanceof domTree.span && node.classes[0] === \"mspace\";\n+};\n+\n /**\n  * Take a list of nodes, build them in order, and return a list of the built\n  * nodes. This function handles the `prev` node correctly, and passes the\n- * previous element from the list as the prev of the next element.\n+ * previous element from the list as the prev of the next element, ignoring\n+ * spaces. documentFragments are flattened into their contents, so the\n+ * returned list contains no fragments.\n  */\n var buildExpression = function(expression, options, prev) {\n+    // Parse expressions into `groups`.\n     var groups = [];\n     for (var i = 0; i < expression.length; i++) {\n         var group = expression[i];\n-        groups.push(buildGroup(group, options, prev));\n-        prev = group;\n+        var output = buildGroup(group, options, prev);\n+        if (output instanceof domTree.documentFragment) {\n+            Array.prototype.push.apply(groups, output.children);\n+        } else {\n+            groups.push(output);\n+        }\n+        if (!isSpace(output)) {\n+            prev = group;\n+        }\n+    }\n+    // At this point `groups` consists entirely of `symbolNode`s and `span`s.\n+\n+    // Explicit spaces (e.g., \\;, \\,) should be ignored with respect to atom\n+    // spacing (e.g., \"add thick space between mord and mrel\"). Since CSS\n+    // adjacency rules implement atom spacing, spaces should be invisible to\n+    // CSS. So we shift them into the atoms themselves.\n+    for (i = 0; i < groups.length; i++) {\n+        if (isSpace(groups[i])) {\n+            // Find next non-space group\n+            for (var j = i + 1; j < groups.length; j++) {\n+                if (!isSpace(groups[j])) {\n+                    break;\n+                }\n+            }\n+            // If non-space group exists, ensure that group is a span and tuck\n+            // the spaces---nodes [i, j)---into the span as its first children\n+            if (j < groups.length) {\n+                group = groups[j];\n+                if (group instanceof domTree.symbolNode) {\n+                    group = groups[j] = makeSpan(group.classes, [group]);\n+                }\n+                buildCommon.prependChildren(group, groups.splice(i, j - i));\n+            } else {\n+                i = j;\n+            }\n+        }","path":"src/buildHTML.js","position":58,"original_position":58,"commit_id":"45d6f6f898dff7325da16ed0916369d67296ffd0","original_commit_id":"45d6f6f898dff7325da16ed0916369d67296ffd0","user":{"login":"kohler","id":410647,"avatar_url":"https://avatars.githubusercontent.com/u/410647?v=3","gravatar_id":"","url":"https://api.github.com/users/kohler","html_url":"https://github.com/kohler","followers_url":"https://api.github.com/users/kohler/followers","following_url":"https://api.github.com/users/kohler/following{/other_user}","gists_url":"https://api.github.com/users/kohler/gists{/gist_id}","starred_url":"https://api.github.com/users/kohler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohler/subscriptions","organizations_url":"https://api.github.com/users/kohler/orgs","repos_url":"https://api.github.com/users/kohler/repos","events_url":"https://api.github.com/users/kohler/events{/privacy}","received_events_url":"https://api.github.com/users/kohler/received_events","type":"User","site_admin":false},"body":"The following code should work but is longer. If you really won't take the `splice` solution i'll do this.\r\n\r\n```\r\n    var spaces = [];\r\n    var nextGroups = [];\r\n    for (i = 0; i < groups.length; i++) {\r\n        group = groups[i];\r\n        if (isSpace(group)) {\r\n            spaces.push(group);\r\n        } else {\r\n            if (spaces.length > 0) {\r\n                if (group instanceof domTree.symbolNode) {\r\n                    group = makeSpan(group.classes, [group]);\r\n                }\r\n                buildCommon.prependChildren(group, spaces);\r\n                spaces = [];\r\n            }\r\n            nextGroups.push(group);\r\n        }\r\n    }\r\n    if (spaces.length > 0) {\r\n        Array.prototype.push.apply(nextGroups, spaces);\r\n    }\r\n```","created_at":"2016-11-27T23:12:15Z","updated_at":"2016-11-27T23:12:15Z","html_url":"https://github.com/Khan/KaTeX/pull/567#discussion_r89702855","pull_request_url":"https://api.github.com/repos/Khan/KaTeX/pulls/567","_links":{"self":{"href":"https://api.github.com/repos/Khan/KaTeX/pulls/comments/89702855"},"html":{"href":"https://github.com/Khan/KaTeX/pull/567#discussion_r89702855"},"pull_request":{"href":"https://api.github.com/repos/Khan/KaTeX/pulls/567"}}},"pull_request":{"url":"https://api.github.com/repos/Khan/KaTeX/pulls/567","id":94668229,"html_url":"https://github.com/Khan/KaTeX/pull/567","diff_url":"https://github.com/Khan/KaTeX/pull/567.diff","patch_url":"https://github.com/Khan/KaTeX/pull/567.patch","issue_url":"https://api.github.com/repos/Khan/KaTeX/issues/567","number":567,"state":"open","locked":false,"title":"Fix #533, #534, #541.","user":{"login":"kohler","id":410647,"avatar_url":"https://avatars.githubusercontent.com/u/410647?v=3","gravatar_id":"","url":"https://api.github.com/users/kohler","html_url":"https://github.com/kohler","followers_url":"https://api.github.com/users/kohler/followers","following_url":"https://api.github.com/users/kohler/following{/other_user}","gists_url":"https://api.github.com/users/kohler/gists{/gist_id}","starred_url":"https://api.github.com/users/kohler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohler/subscriptions","organizations_url":"https://api.github.com/users/kohler/orgs","repos_url":"https://api.github.com/users/kohler/repos","events_url":"https://api.github.com/users/kohler/events{/privacy}","received_events_url":"https://api.github.com/users/kohler/received_events","type":"User","site_admin":false},"body":"- #534: Implement getTypeOfGroup for font groups.\r\n- #533, #541: Improve the ways spaces are applied to lists. Since\r\n  CSS adjacency implements mathematical spacing, it's incorrect to\r\n  introduce \"convenience spans\" for spaces and display changes into\r\n  the generated HTML -- those spans break adjacency. Apply display\r\n  changes directly, and shift space spans into adjacent atoms.\r\n\r\nRequires updates to two screenshotter tests, LimitControls and\r\nSupSubLeftAlignReset. The new results for these tests are closer\r\nto TeX output than the old results.\r\n\r\nAlso requires updates to Jasmine tests, since those assumed output\r\nstructures that have changed.","created_at":"2016-11-21T18:16:20Z","updated_at":"2016-11-27T23:12:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1ba2d5bf4c6be713b39b38809819227c98394c0a","assignee":{"login":"kevinbarabash","id":1044413,"avatar_url":"https://avatars.githubusercontent.com/u/1044413?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinbarabash","html_url":"https://github.com/kevinbarabash","followers_url":"https://api.github.com/users/kevinbarabash/followers","following_url":"https://api.github.com/users/kevinbarabash/following{/other_user}","gists_url":"https://api.github.com/users/kevinbarabash/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinbarabash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinbarabash/subscriptions","organizations_url":"https://api.github.com/users/kevinbarabash/orgs","repos_url":"https://api.github.com/users/kevinbarabash/repos","events_url":"https://api.github.com/users/kevinbarabash/events{/privacy}","received_events_url":"https://api.github.com/users/kevinbarabash/received_events","type":"User","site_admin":false},"assignees":[{"login":"kevinbarabash","id":1044413,"avatar_url":"https://avatars.githubusercontent.com/u/1044413?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinbarabash","html_url":"https://github.com/kevinbarabash","followers_url":"https://api.github.com/users/kevinbarabash/followers","following_url":"https://api.github.com/users/kevinbarabash/following{/other_user}","gists_url":"https://api.github.com/users/kevinbarabash/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinbarabash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinbarabash/subscriptions","organizations_url":"https://api.github.com/users/kevinbarabash/orgs","repos_url":"https://api.github.com/users/kevinbarabash/repos","events_url":"https://api.github.com/users/kevinbarabash/events{/privacy}","received_events_url":"https://api.github.com/users/kevinbarabash/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/Khan/KaTeX/pulls/567/commits","review_comments_url":"https://api.github.com/repos/Khan/KaTeX/pulls/567/comments","review_comment_url":"https://api.github.com/repos/Khan/KaTeX/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Khan/KaTeX/issues/567/comments","statuses_url":"https://api.github.com/repos/Khan/KaTeX/statuses/45d6f6f898dff7325da16ed0916369d67296ffd0","head":{"label":"kohler:styling-spacing-atoms","ref":"styling-spacing-atoms","sha":"45d6f6f898dff7325da16ed0916369d67296ffd0","user":{"login":"kohler","id":410647,"avatar_url":"https://avatars.githubusercontent.com/u/410647?v=3","gravatar_id":"","url":"https://api.github.com/users/kohler","html_url":"https://github.com/kohler","followers_url":"https://api.github.com/users/kohler/followers","following_url":"https://api.github.com/users/kohler/following{/other_user}","gists_url":"https://api.github.com/users/kohler/gists{/gist_id}","starred_url":"https://api.github.com/users/kohler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohler/subscriptions","organizations_url":"https://api.github.com/users/kohler/orgs","repos_url":"https://api.github.com/users/kohler/repos","events_url":"https://api.github.com/users/kohler/events{/privacy}","received_events_url":"https://api.github.com/users/kohler/received_events","type":"User","site_admin":false},"repo":{"id":74285458,"name":"KaTeX","full_name":"kohler/KaTeX","owner":{"login":"kohler","id":410647,"avatar_url":"https://avatars.githubusercontent.com/u/410647?v=3","gravatar_id":"","url":"https://api.github.com/users/kohler","html_url":"https://github.com/kohler","followers_url":"https://api.github.com/users/kohler/followers","following_url":"https://api.github.com/users/kohler/following{/other_user}","gists_url":"https://api.github.com/users/kohler/gists{/gist_id}","starred_url":"https://api.github.com/users/kohler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohler/subscriptions","organizations_url":"https://api.github.com/users/kohler/orgs","repos_url":"https://api.github.com/users/kohler/repos","events_url":"https://api.github.com/users/kohler/events{/privacy}","received_events_url":"https://api.github.com/users/kohler/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kohler/KaTeX","description":"Fast math typesetting for the web.","fork":true,"url":"https://api.github.com/repos/kohler/KaTeX","forks_url":"https://api.github.com/repos/kohler/KaTeX/forks","keys_url":"https://api.github.com/repos/kohler/KaTeX/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kohler/KaTeX/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kohler/KaTeX/teams","hooks_url":"https://api.github.com/repos/kohler/KaTeX/hooks","issue_events_url":"https://api.github.com/repos/kohler/KaTeX/issues/events{/number}","events_url":"https://api.github.com/repos/kohler/KaTeX/events","assignees_url":"https://api.github.com/repos/kohler/KaTeX/assignees{/user}","branches_url":"https://api.github.com/repos/kohler/KaTeX/branches{/branch}","tags_url":"https://api.github.com/repos/kohler/KaTeX/tags","blobs_url":"https://api.github.com/repos/kohler/KaTeX/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kohler/KaTeX/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kohler/KaTeX/git/refs{/sha}","trees_url":"https://api.github.com/repos/kohler/KaTeX/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kohler/KaTeX/statuses/{sha}","languages_url":"https://api.github.com/repos/kohler/KaTeX/languages","stargazers_url":"https://api.github.com/repos/kohler/KaTeX/stargazers","contributors_url":"https://api.github.com/repos/kohler/KaTeX/contributors","subscribers_url":"https://api.github.com/repos/kohler/KaTeX/subscribers","subscription_url":"https://api.github.com/repos/kohler/KaTeX/subscription","commits_url":"https://api.github.com/repos/kohler/KaTeX/commits{/sha}","git_commits_url":"https://api.github.com/repos/kohler/KaTeX/git/commits{/sha}","comments_url":"https://api.github.com/repos/kohler/KaTeX/comments{/number}","issue_comment_url":"https://api.github.com/repos/kohler/KaTeX/issues/comments{/number}","contents_url":"https://api.github.com/repos/kohler/KaTeX/contents/{+path}","compare_url":"https://api.github.com/repos/kohler/KaTeX/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kohler/KaTeX/merges","archive_url":"https://api.github.com/repos/kohler/KaTeX/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kohler/KaTeX/downloads","issues_url":"https://api.github.com/repos/kohler/KaTeX/issues{/number}","pulls_url":"https://api.github.com/repos/kohler/KaTeX/pulls{/number}","milestones_url":"https://api.github.com/repos/kohler/KaTeX/milestones{/number}","notifications_url":"https://api.github.com/repos/kohler/KaTeX/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kohler/KaTeX/labels{/name}","releases_url":"https://api.github.com/repos/kohler/KaTeX/releases{/id}","deployments_url":"https://api.github.com/repos/kohler/KaTeX/deployments","created_at":"2016-11-20T15:57:49Z","updated_at":"2016-11-20T15:57:50Z","pushed_at":"2016-11-27T16:39:38Z","git_url":"git://github.com/kohler/KaTeX.git","ssh_url":"git@github.com:kohler/KaTeX.git","clone_url":"https://github.com/kohler/KaTeX.git","svn_url":"https://github.com/kohler/KaTeX","homepage":"https://khan.github.io/KaTeX/","size":14241,"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":"Khan:master","ref":"master","sha":"94dad8029d94833f043412dfdb0382bf76fbcf14","user":{"login":"Khan","id":15455,"avatar_url":"https://avatars.githubusercontent.com/u/15455?v=3","gravatar_id":"","url":"https://api.github.com/users/Khan","html_url":"https://github.com/Khan","followers_url":"https://api.github.com/users/Khan/followers","following_url":"https://api.github.com/users/Khan/following{/other_user}","gists_url":"https://api.github.com/users/Khan/gists{/gist_id}","starred_url":"https://api.github.com/users/Khan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Khan/subscriptions","organizations_url":"https://api.github.com/users/Khan/orgs","repos_url":"https://api.github.com/users/Khan/repos","events_url":"https://api.github.com/users/Khan/events{/privacy}","received_events_url":"https://api.github.com/users/Khan/received_events","type":"Organization","site_admin":false},"repo":{"id":11195700,"name":"KaTeX","full_name":"Khan/KaTeX","owner":{"login":"Khan","id":15455,"avatar_url":"https://avatars.githubusercontent.com/u/15455?v=3","gravatar_id":"","url":"https://api.github.com/users/Khan","html_url":"https://github.com/Khan","followers_url":"https://api.github.com/users/Khan/followers","following_url":"https://api.github.com/users/Khan/following{/other_user}","gists_url":"https://api.github.com/users/Khan/gists{/gist_id}","starred_url":"https://api.github.com/users/Khan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Khan/subscriptions","organizations_url":"https://api.github.com/users/Khan/orgs","repos_url":"https://api.github.com/users/Khan/repos","events_url":"https://api.github.com/users/Khan/events{/privacy}","received_events_url":"https://api.github.com/users/Khan/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Khan/KaTeX","description":"Fast math typesetting for the web.","fork":false,"url":"https://api.github.com/repos/Khan/KaTeX","forks_url":"https://api.github.com/repos/Khan/KaTeX/forks","keys_url":"https://api.github.com/repos/Khan/KaTeX/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Khan/KaTeX/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Khan/KaTeX/teams","hooks_url":"https://api.github.com/repos/Khan/KaTeX/hooks","issue_events_url":"https://api.github.com/repos/Khan/KaTeX/issues/events{/number}","events_url":"https://api.github.com/repos/Khan/KaTeX/events","assignees_url":"https://api.github.com/repos/Khan/KaTeX/assignees{/user}","branches_url":"https://api.github.com/repos/Khan/KaTeX/branches{/branch}","tags_url":"https://api.github.com/repos/Khan/KaTeX/tags","blobs_url":"https://api.github.com/repos/Khan/KaTeX/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Khan/KaTeX/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Khan/KaTeX/git/refs{/sha}","trees_url":"https://api.github.com/repos/Khan/KaTeX/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Khan/KaTeX/statuses/{sha}","languages_url":"https://api.github.com/repos/Khan/KaTeX/languages","stargazers_url":"https://api.github.com/repos/Khan/KaTeX/stargazers","contributors_url":"https://api.github.com/repos/Khan/KaTeX/contributors","subscribers_url":"https://api.github.com/repos/Khan/KaTeX/subscribers","subscription_url":"https://api.github.com/repos/Khan/KaTeX/subscription","commits_url":"https://api.github.com/repos/Khan/KaTeX/commits{/sha}","git_commits_url":"https://api.github.com/repos/Khan/KaTeX/git/commits{/sha}","comments_url":"https://api.github.com/repos/Khan/KaTeX/comments{/number}","issue_comment_url":"https://api.github.com/repos/Khan/KaTeX/issues/comments{/number}","contents_url":"https://api.github.com/repos/Khan/KaTeX/contents/{+path}","compare_url":"https://api.github.com/repos/Khan/KaTeX/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Khan/KaTeX/merges","archive_url":"https://api.github.com/repos/Khan/KaTeX/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Khan/KaTeX/downloads","issues_url":"https://api.github.com/repos/Khan/KaTeX/issues{/number}","pulls_url":"https://api.github.com/repos/Khan/KaTeX/pulls{/number}","milestones_url":"https://api.github.com/repos/Khan/KaTeX/milestones{/number}","notifications_url":"https://api.github.com/repos/Khan/KaTeX/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Khan/KaTeX/labels{/name}","releases_url":"https://api.github.com/repos/Khan/KaTeX/releases{/id}","deployments_url":"https://api.github.com/repos/Khan/KaTeX/deployments","created_at":"2013-07-05T09:01:54Z","updated_at":"2016-11-27T17:34:19Z","pushed_at":"2016-11-27T04:32:41Z","git_url":"git://github.com/Khan/KaTeX.git","ssh_url":"git@github.com:Khan/KaTeX.git","clone_url":"https://github.com/Khan/KaTeX.git","svn_url":"https://github.com/Khan/KaTeX","homepage":"https://khan.github.io/KaTeX/","size":15182,"stargazers_count":5187,"watchers_count":5187,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":354,"mirror_url":null,"open_issues_count":160,"forks":354,"open_issues":160,"watchers":5187,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Khan/KaTeX/pulls/567"},"html":{"href":"https://github.com/Khan/KaTeX/pull/567"},"issue":{"href":"https://api.github.com/repos/Khan/KaTeX/issues/567"},"comments":{"href":"https://api.github.com/repos/Khan/KaTeX/issues/567/comments"},"review_comments":{"href":"https://api.github.com/repos/Khan/KaTeX/pulls/567/comments"},"review_comment":{"href":"https://api.github.com/repos/Khan/KaTeX/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Khan/KaTeX/pulls/567/commits"},"statuses":{"href":"https://api.github.com/repos/Khan/KaTeX/statuses/45d6f6f898dff7325da16ed0916369d67296ffd0"}}}}
{"actor":{"display_login":"kohler"}}