{"action":"created","comment":{"url":"https://api.github.com/repos/rstudio/rstudio/pulls/comments/75715818","id":75715818,"diff_hunk":"@@ -0,0 +1,132 @@\n+/*\n+ * MathJaxLoader.java\n+ *\n+ * Copyright (C) 2009-16 by RStudio, Inc.\n+ *\n+ * Unless you have received this program directly from RStudio pursuant\n+ * to the terms of a commercial license agreement with RStudio, then\n+ * this program is licensed to you under the terms of version 3 of the\n+ * GNU Affero General Public License. This program is distributed WITHOUT\n+ * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,\n+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the\n+ * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.\n+ *\n+ */\n+package org.rstudio.studio.client.common.mathjax;\n+\n+import com.google.gwt.core.client.Scheduler;\n+import com.google.gwt.core.client.Scheduler.RepeatingCommand;\n+import com.google.gwt.dom.client.Document;\n+import com.google.gwt.dom.client.HeadElement;\n+import com.google.gwt.dom.client.ScriptElement;\n+import com.google.inject.Singleton;\n+\n+@Singleton\n+public class MathJaxLoader\n+{\n+   public interface Callback\n+   {\n+      public void onLoaded(boolean alreadyLoaded);\n+   }\n+   \n+   public MathJaxLoader()\n+   {\n+      ensureMathJaxLoaded();\n+   }\n+   \n+   public static void ensureMathJaxLoaded()\n+   {\n+      ensureMathJaxLoaded(null);\n+   }\n+   \n+   public static boolean isMathJaxLoaded()\n+   {\n+      return MATHJAX_LOADED;\n+   }\n+   \n+   public static void ensureMathJaxLoaded(Callback callback)\n+   {\n+      if (MATHJAX_LOADED)\n+      {\n+         callback.onLoaded(MATHJAX_LOADED);\n+         return;\n+      }\n+      \n+      initializeMathJaxConfig();\n+      ScriptElement mathJaxEl = createMathJaxScriptElement();\n+      HeadElement headEl = Document.get().getHead();\n+      headEl.appendChild(mathJaxEl);\n+      Scheduler.get().scheduleFixedDelay(new RepeatingCommand()\n+      {\n+         @Override\n+         public boolean execute()\n+         {\n+            if (isMathJaxReady())\n+            {\n+               MATHJAX_LOADED = true;\n+               callback.onLoaded(false);\n+               onMathJaxLoaded();\n+               return false;\n+            }\n+            \n+            RETRY_COUNT++;\n+            return RETRY_COUNT < 20;\n+         }\n+      }, 50);\n+   }\n+   \n+   // Private Methods ----\n+   \n+   private static final native void onMathJaxLoaded() /*-{\n+      var MathJax = $wnd.MathJax;\n+      \n+      // avoid jittering\n+      MathJax.Hub.processSectionDelay = 0;\n+   }-*/;\n+   \n+   private static final native void initializeMathJaxConfig() /*-{\n+\n+      if (typeof $wnd.MathJax !== \"undefined\")\n+         return;\n+\n+      $wnd.MathJax = {\n+         extensions: ['tex2jax.js'],\n+         jax: ['input/TeX', 'output/HTML-CSS'],\n+         tex2jax: {\n+            inlineMath:  [['$', '$'], ['\\\\(', '\\\\)']],\n+            displayMath: [['$$', '$$'], ['\\\\[', '\\\\]']],\n+            processEscapes: true\n+         },\n+         \"HTML-CSS\": {","path":"src/gwt/src/org/rstudio/studio/client/common/mathjax/MathJaxLoader.java","position":100,"original_position":100,"commit_id":"537a1043e893fbc60935b000460c601f1093be9f","original_commit_id":"a4e532dfa068dddd1a522237647049e52524c8f8","user":{"login":"kevinushey","id":1976582,"avatar_url":"https://avatars.githubusercontent.com/u/1976582?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinushey","html_url":"https://github.com/kevinushey","followers_url":"https://api.github.com/users/kevinushey/followers","following_url":"https://api.github.com/users/kevinushey/following{/other_user}","gists_url":"https://api.github.com/users/kevinushey/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinushey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinushey/subscriptions","organizations_url":"https://api.github.com/users/kevinushey/orgs","repos_url":"https://api.github.com/users/kevinushey/repos","events_url":"https://api.github.com/users/kevinushey/events{/privacy}","received_events_url":"https://api.github.com/users/kevinushey/received_events","type":"User","site_admin":false},"body":"Indeed you're right, these settings were necessary to ensure nice rendering on Qt -- otherwise, the rendered MathJax was way too small. Nice catch!","created_at":"2016-08-22T16:59:21Z","updated_at":"2016-08-22T16:59:21Z","html_url":"https://github.com/rstudio/rstudio/pull/758#discussion_r75715818","pull_request_url":"https://api.github.com/repos/rstudio/rstudio/pulls/758","_links":{"self":{"href":"https://api.github.com/repos/rstudio/rstudio/pulls/comments/75715818"},"html":{"href":"https://github.com/rstudio/rstudio/pull/758#discussion_r75715818"},"pull_request":{"href":"https://api.github.com/repos/rstudio/rstudio/pulls/758"}}},"pull_request":{"url":"https://api.github.com/repos/rstudio/rstudio/pulls/758","id":81535321,"html_url":"https://github.com/rstudio/rstudio/pull/758","diff_url":"https://github.com/rstudio/rstudio/pull/758.diff","patch_url":"https://github.com/rstudio/rstudio/pull/758.patch","issue_url":"https://api.github.com/repos/rstudio/rstudio/issues/758","number":758,"state":"open","locked":false,"title":"inline rendering of latex chunks","user":{"login":"kevinushey","id":1976582,"avatar_url":"https://avatars.githubusercontent.com/u/1976582?v=3","gravatar_id":"","url":"https://api.github.com/users/kevinushey","html_url":"https://github.com/kevinushey","followers_url":"https://api.github.com/users/kevinushey/followers","following_url":"https://api.github.com/users/kevinushey/following{/other_user}","gists_url":"https://api.github.com/users/kevinushey/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinushey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinushey/subscriptions","organizations_url":"https://api.github.com/users/kevinushey/orgs","repos_url":"https://api.github.com/users/kevinushey/repos","events_url":"https://api.github.com/users/kevinushey/events{/privacy}","received_events_url":"https://api.github.com/users/kevinushey/received_events","type":"User","site_admin":false},"body":"Note: not ready for merge; just wanted to open this PR to discuss things like styling / UI, and other things we might want to implement for this feature.\r\n\r\nThis PR represents some initial work re: rendering of LaTeX chunks within an R Markdown document. Right now, the content of the chunk is copied into a popup, and that popup is then rendered with MathJax. The latex 'chunks' are executed with `Cmd + Enter`.\r\n\r\n![latex](https://cloud.githubusercontent.com/assets/1976582/17713894/13074bf6-63b2-11e6-8335-ecc3d048089e.gif)\r\n","created_at":"2016-08-16T20:05:37Z","updated_at":"2016-08-22T16:59:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d1978abedf44f6ee885394c66c9aa5998bc2d69d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/rstudio/rstudio/pulls/758/commits","review_comments_url":"https://api.github.com/repos/rstudio/rstudio/pulls/758/comments","review_comment_url":"https://api.github.com/repos/rstudio/rstudio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rstudio/rstudio/issues/758/comments","statuses_url":"https://api.github.com/repos/rstudio/rstudio/statuses/537a1043e893fbc60935b000460c601f1093be9f","head":{"label":"rstudio:feature/mathjax-chunk-render","ref":"feature/mathjax-chunk-render","sha":"537a1043e893fbc60935b000460c601f1093be9f","user":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"repo":{"id":1147463,"name":"rstudio","full_name":"rstudio/rstudio","owner":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rstudio/rstudio","description":"RStudio is an integrated development environment (IDE) for R","fork":false,"url":"https://api.github.com/repos/rstudio/rstudio","forks_url":"https://api.github.com/repos/rstudio/rstudio/forks","keys_url":"https://api.github.com/repos/rstudio/rstudio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rstudio/rstudio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rstudio/rstudio/teams","hooks_url":"https://api.github.com/repos/rstudio/rstudio/hooks","issue_events_url":"https://api.github.com/repos/rstudio/rstudio/issues/events{/number}","events_url":"https://api.github.com/repos/rstudio/rstudio/events","assignees_url":"https://api.github.com/repos/rstudio/rstudio/assignees{/user}","branches_url":"https://api.github.com/repos/rstudio/rstudio/branches{/branch}","tags_url":"https://api.github.com/repos/rstudio/rstudio/tags","blobs_url":"https://api.github.com/repos/rstudio/rstudio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rstudio/rstudio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rstudio/rstudio/git/refs{/sha}","trees_url":"https://api.github.com/repos/rstudio/rstudio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rstudio/rstudio/statuses/{sha}","languages_url":"https://api.github.com/repos/rstudio/rstudio/languages","stargazers_url":"https://api.github.com/repos/rstudio/rstudio/stargazers","contributors_url":"https://api.github.com/repos/rstudio/rstudio/contributors","subscribers_url":"https://api.github.com/repos/rstudio/rstudio/subscribers","subscription_url":"https://api.github.com/repos/rstudio/rstudio/subscription","commits_url":"https://api.github.com/repos/rstudio/rstudio/commits{/sha}","git_commits_url":"https://api.github.com/repos/rstudio/rstudio/git/commits{/sha}","comments_url":"https://api.github.com/repos/rstudio/rstudio/comments{/number}","issue_comment_url":"https://api.github.com/repos/rstudio/rstudio/issues/comments{/number}","contents_url":"https://api.github.com/repos/rstudio/rstudio/contents/{+path}","compare_url":"https://api.github.com/repos/rstudio/rstudio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rstudio/rstudio/merges","archive_url":"https://api.github.com/repos/rstudio/rstudio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rstudio/rstudio/downloads","issues_url":"https://api.github.com/repos/rstudio/rstudio/issues{/number}","pulls_url":"https://api.github.com/repos/rstudio/rstudio/pulls{/number}","milestones_url":"https://api.github.com/repos/rstudio/rstudio/milestones{/number}","notifications_url":"https://api.github.com/repos/rstudio/rstudio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rstudio/rstudio/labels{/name}","releases_url":"https://api.github.com/repos/rstudio/rstudio/releases{/id}","deployments_url":"https://api.github.com/repos/rstudio/rstudio/deployments","created_at":"2010-12-07T19:10:25Z","updated_at":"2016-08-22T15:19:53Z","pushed_at":"2016-08-22T16:08:51Z","git_url":"git://github.com/rstudio/rstudio.git","ssh_url":"git@github.com:rstudio/rstudio.git","clone_url":"https://github.com/rstudio/rstudio.git","svn_url":"https://github.com/rstudio/rstudio","homepage":"http://www.rstudio.org","size":97082,"stargazers_count":1425,"watchers_count":1425,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":378,"mirror_url":null,"open_issues_count":5,"forks":378,"open_issues":5,"watchers":1425,"default_branch":"master"}},"base":{"label":"rstudio:master","ref":"master","sha":"82f503e27731e2995b978b0ab5c3c3c26ef39e9d","user":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"repo":{"id":1147463,"name":"rstudio","full_name":"rstudio/rstudio","owner":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rstudio/rstudio","description":"RStudio is an integrated development environment (IDE) for R","fork":false,"url":"https://api.github.com/repos/rstudio/rstudio","forks_url":"https://api.github.com/repos/rstudio/rstudio/forks","keys_url":"https://api.github.com/repos/rstudio/rstudio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rstudio/rstudio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rstudio/rstudio/teams","hooks_url":"https://api.github.com/repos/rstudio/rstudio/hooks","issue_events_url":"https://api.github.com/repos/rstudio/rstudio/issues/events{/number}","events_url":"https://api.github.com/repos/rstudio/rstudio/events","assignees_url":"https://api.github.com/repos/rstudio/rstudio/assignees{/user}","branches_url":"https://api.github.com/repos/rstudio/rstudio/branches{/branch}","tags_url":"https://api.github.com/repos/rstudio/rstudio/tags","blobs_url":"https://api.github.com/repos/rstudio/rstudio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rstudio/rstudio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rstudio/rstudio/git/refs{/sha}","trees_url":"https://api.github.com/repos/rstudio/rstudio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rstudio/rstudio/statuses/{sha}","languages_url":"https://api.github.com/repos/rstudio/rstudio/languages","stargazers_url":"https://api.github.com/repos/rstudio/rstudio/stargazers","contributors_url":"https://api.github.com/repos/rstudio/rstudio/contributors","subscribers_url":"https://api.github.com/repos/rstudio/rstudio/subscribers","subscription_url":"https://api.github.com/repos/rstudio/rstudio/subscription","commits_url":"https://api.github.com/repos/rstudio/rstudio/commits{/sha}","git_commits_url":"https://api.github.com/repos/rstudio/rstudio/git/commits{/sha}","comments_url":"https://api.github.com/repos/rstudio/rstudio/comments{/number}","issue_comment_url":"https://api.github.com/repos/rstudio/rstudio/issues/comments{/number}","contents_url":"https://api.github.com/repos/rstudio/rstudio/contents/{+path}","compare_url":"https://api.github.com/repos/rstudio/rstudio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rstudio/rstudio/merges","archive_url":"https://api.github.com/repos/rstudio/rstudio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rstudio/rstudio/downloads","issues_url":"https://api.github.com/repos/rstudio/rstudio/issues{/number}","pulls_url":"https://api.github.com/repos/rstudio/rstudio/pulls{/number}","milestones_url":"https://api.github.com/repos/rstudio/rstudio/milestones{/number}","notifications_url":"https://api.github.com/repos/rstudio/rstudio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rstudio/rstudio/labels{/name}","releases_url":"https://api.github.com/repos/rstudio/rstudio/releases{/id}","deployments_url":"https://api.github.com/repos/rstudio/rstudio/deployments","created_at":"2010-12-07T19:10:25Z","updated_at":"2016-08-22T15:19:53Z","pushed_at":"2016-08-22T16:08:51Z","git_url":"git://github.com/rstudio/rstudio.git","ssh_url":"git@github.com:rstudio/rstudio.git","clone_url":"https://github.com/rstudio/rstudio.git","svn_url":"https://github.com/rstudio/rstudio","homepage":"http://www.rstudio.org","size":97082,"stargazers_count":1425,"watchers_count":1425,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":378,"mirror_url":null,"open_issues_count":5,"forks":378,"open_issues":5,"watchers":1425,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rstudio/rstudio/pulls/758"},"html":{"href":"https://github.com/rstudio/rstudio/pull/758"},"issue":{"href":"https://api.github.com/repos/rstudio/rstudio/issues/758"},"comments":{"href":"https://api.github.com/repos/rstudio/rstudio/issues/758/comments"},"review_comments":{"href":"https://api.github.com/repos/rstudio/rstudio/pulls/758/comments"},"review_comment":{"href":"https://api.github.com/repos/rstudio/rstudio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rstudio/rstudio/pulls/758/commits"},"statuses":{"href":"https://api.github.com/repos/rstudio/rstudio/statuses/537a1043e893fbc60935b000460c601f1093be9f"}}}}
{"actor":{"display_login":"kevinushey"}}