{"action":"created","comment":{"url":"https://api.github.com/repos/Automattic/jetpack/pulls/comments/39238187","id":39238187,"diff_hunk":"@@ -17,8 +17,137 @@\n  *\n  * $latex e^{\\i \\pi} + 1 = 0$  ->  [latex]e^{\\i \\pi} + 1 = 0[/latex]\n  * $latex [a, b]$              ->  [latex][a, b][/latex]\n+ *\n+ * In addition to supporting old markup, we also now support MathJax math delimiters:\n+ * Inline: \"\\(math here\\)\"\n+ * Block-level: \"$$math here$$\" and \"\\[math here\\]\"\n+ * MathJax delimiters do not support colors and sizes as part of the expression.\n+ */\n+\n+/**\n+ * MathJax configuration.\n+ *\n+ * In-line MathJax configuration options give us more granularity than simply\n+ * picking one of the built-in configurations. It also makes it filterable.\n+ *\n+ * @since 3.8\n+ *\n+ * @link http://docs.mathjax.org/en/latest/configuration.html#using-in-line-configuration-options\n+ *\n+ * @return array\n+ */\n+function latex_mathjax_config() {\n+\t$config = array(\n+\t\t// TeX-AMS_HTML.js allows math to be specified in TeX or LaTeX notation, with the AMSmath and AMSsymbols packages included, and produces output using the HTML-CSS output processor.\n+\t\t'config' => array( 'TeX-AMS_HTML.js' ),\n+\t\t'jax'    => array(\n+\t\t\t'input/TeX',\n+\t\t\t'output/HTML-CSS',\n+\t\t\t'output/CommonHTML',\n+\t\t),\n+\t\t'extensions' => array(\n+\t\t\t'tex2jax.js',\n+\t\t\t'CHTML-preview.js',\n+\t\t\t'Safe.js'\n+\t\t),\n+\t\t'TeX' => array(\n+\t\t\t'extensions' => array(\n+\t\t\t\t'AMSmath.js',\n+\t\t\t\t'AMSsymbols.js',\n+\t\t\t),\n+\t\t\t'Macros' => array(\n+\t\t\t\t// /i command sequence is supported by WP Latex but not MathJax.\n+\t\t\t\t'i' => \"{\\\\imath}\",\n+\t\t\t\t// /j command sequence is supported by WP Latex but not MathJax.\n+\t\t\t\t'j' => \"{\\\\jmath}\",\n+\t\t\t),\n+\t\t),\n+\t\t'tex2jax' => array(\n+\t\t\t'inlineMath' => array(\n+\t\t\t\tarray( '\\(', '\\)' ),\n+\t\t\t\tarray( '$latex ', '$' ),\n+\t\t\t\tarray( '[latex]', '[/latex]' ),\n+\t\t\t),\n+\t\t\t'ignoreClass' => 'math_ignore',\n+\t\t),\n+\t\t// Specify a z-index for MathMenu so it appears properly when used inside modals.\n+\t\t'MathMenu' => array(\n+\t\t\t'styles' => array(\n+\t\t\t\t'.MathJax_Menu' => array('z-index' => 2001),\n+\t\t\t),\n+\t\t),\n+\t);\n+\n+\t// Users who can edit posts or pages should see math parse error details.\n+\tif ( current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' ) ) {\n+\t\t$config['TeX']['noErrors']    = array( 'disabled' => true );\n+\t\t$config['TeX']['noUndefined'] = array( 'disabled' => true );\n+\t}\n+\n+\treturn $config;\n+}\n+\n+/**\n+ * Output in-line MathJax configuration.\n+ *\n+ * @since 3.8\n+ *\n+ * @link http://docs.mathjax.org/en/latest/configuration.html#using-in-line-configuration-options\n+ * @link https://github.com/mathjax/MathJax-website/commit/df7f655623b1a6fc0bc637d9f4b47cb3461aa118\n+ */\n+function latex_mathjax_output() { ?>\n+\t<script type=\"text/x-mathjax-config\">\n+\t\tMathJax.Hub.Register.StartupHook('MathMenu Ready', function () {\n+\t\t\tMathJax.Menu.BGSTYLE['z-index'] = 2000;\n+\t\t});\n+\t\tMathJax.Hub.Config(<?php echo wp_json_encode(\n+\t\t\tapply_filters( 'latex_mathjax_output', latex_mathjax_config() )\n+\t\t); ?>);\n+\t</script>\n+<?php }\n+\n+/**\n+ * Enqueue MathJax JavaScript.\n+ *\n+ * @since 3.8\n  */\n+function latex_enqueue_scripts() {\n+\t$mathjax_url = '//cdn.mathjax.org/mathjax/latest/MathJax.js';","path":"modules/latex.php","position":130,"original_position":108,"commit_id":"d456732ee2759d6ba63819ed10999b4acc354cdc","original_commit_id":"f20c72312bf0b6e3d1141614ef734beedf661e6d","user":{"login":"popthestack","id":136891,"avatar_url":"https://avatars.githubusercontent.com/u/136891?v=3","gravatar_id":"","url":"https://api.github.com/users/popthestack","html_url":"https://github.com/popthestack","followers_url":"https://api.github.com/users/popthestack/followers","following_url":"https://api.github.com/users/popthestack/following{/other_user}","gists_url":"https://api.github.com/users/popthestack/gists{/gist_id}","starred_url":"https://api.github.com/users/popthestack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/popthestack/subscriptions","organizations_url":"https://api.github.com/users/popthestack/orgs","repos_url":"https://api.github.com/users/popthestack/repos","events_url":"https://api.github.com/users/popthestack/events{/privacy}","received_events_url":"https://api.github.com/users/popthestack/received_events","type":"User","site_admin":false},"body":"Getting rid of the default MathJax delimiters also has the benefit of us being able to easily control this. :+1: ","created_at":"2015-09-11T03:13:23Z","updated_at":"2015-09-11T03:13:23Z","html_url":"https://github.com/Automattic/jetpack/pull/2685#discussion_r39238187","pull_request_url":"https://api.github.com/repos/Automattic/jetpack/pulls/2685","_links":{"self":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/comments/39238187"},"html":{"href":"https://github.com/Automattic/jetpack/pull/2685#discussion_r39238187"},"pull_request":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/2685"}}},"pull_request":{"url":"https://api.github.com/repos/Automattic/jetpack/pulls/2685","id":44388657,"html_url":"https://github.com/Automattic/jetpack/pull/2685","diff_url":"https://github.com/Automattic/jetpack/pull/2685.diff","patch_url":"https://github.com/Automattic/jetpack/pull/2685.patch","issue_url":"https://api.github.com/repos/Automattic/jetpack/issues/2685","number":2685,"state":"open","locked":false,"title":"Enhance/reimplement latex using mathjax","user":{"login":"popthestack","id":136891,"avatar_url":"https://avatars.githubusercontent.com/u/136891?v=3","gravatar_id":"","url":"https://api.github.com/users/popthestack","html_url":"https://github.com/popthestack","followers_url":"https://api.github.com/users/popthestack/followers","following_url":"https://api.github.com/users/popthestack/following{/other_user}","gists_url":"https://api.github.com/users/popthestack/gists{/gist_id}","starred_url":"https://api.github.com/users/popthestack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/popthestack/subscriptions","organizations_url":"https://api.github.com/users/popthestack/orgs","repos_url":"https://api.github.com/users/popthestack/repos","events_url":"https://api.github.com/users/popthestack/events{/privacy}","received_events_url":"https://api.github.com/users/popthestack/received_events","type":"User","site_admin":false},"body":"This pull request re-implements the Jetpack Latex module using [MathJax](https://www.mathjax.org/).\r\n\r\nRendering math equations as PNGs doesn't work well with shifting page layouts, it removes some typesetting information, and isn't very high resolution. Using MathJax allows the browser itself to handle fonts and typesetting in order to keep the output pretty.\r\n\r\nThis shouldn't cause any backwards compatibility breaks.\r\n\r\nSome points for discussion:\r\n\r\n * I'm purposefully serving MathJax files from the MathJax CDN. Given the size of the MathJax assets (~40 MB) I wanted to see what others thought before including them in the repo.\r\n * The change to `jetpack-modules.js` to run MathJax for the Beautiful Math modal description in the admin is not my favorite. It feels hacky.\r\n * `wp_encode_json` for the options might not safe enough; however, the options need to be filterable.\r\n * Please let me know where this could benefit from more inline documentation. It's not always easy to spot places it's lacking when you've got all the code in your head. :)","created_at":"2015-09-08T02:52:24Z","updated_at":"2015-09-11T03:13:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da9687cc01cdb7f60264f2c1983a54c804cf3e3f","assignee":null,"milestone":{"url":"https://api.github.com/repos/Automattic/jetpack/milestones/24","html_url":"https://github.com/Automattic/jetpack/milestones/3.8","labels_url":"https://api.github.com/repos/Automattic/jetpack/milestones/24/labels","id":1238559,"number":24,"title":"3.8","description":"","creator":{"login":"kraftbj","id":88897,"avatar_url":"https://avatars.githubusercontent.com/u/88897?v=3","gravatar_id":"","url":"https://api.github.com/users/kraftbj","html_url":"https://github.com/kraftbj","followers_url":"https://api.github.com/users/kraftbj/followers","following_url":"https://api.github.com/users/kraftbj/following{/other_user}","gists_url":"https://api.github.com/users/kraftbj/gists{/gist_id}","starred_url":"https://api.github.com/users/kraftbj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kraftbj/subscriptions","organizations_url":"https://api.github.com/users/kraftbj/orgs","repos_url":"https://api.github.com/users/kraftbj/repos","events_url":"https://api.github.com/users/kraftbj/events{/privacy}","received_events_url":"https://api.github.com/users/kraftbj/received_events","type":"User","site_admin":false},"open_issues":91,"closed_issues":8,"state":"open","created_at":"2015-08-03T15:09:41Z","updated_at":"2015-09-08T16:30:36Z","due_on":"2015-10-28T04:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/Automattic/jetpack/pulls/2685/commits","review_comments_url":"https://api.github.com/repos/Automattic/jetpack/pulls/2685/comments","review_comment_url":"https://api.github.com/repos/Automattic/jetpack/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Automattic/jetpack/issues/2685/comments","statuses_url":"https://api.github.com/repos/Automattic/jetpack/statuses/d456732ee2759d6ba63819ed10999b4acc354cdc","head":{"label":"popthestack:enhance/reimplement-latex-using-mathjax","ref":"enhance/reimplement-latex-using-mathjax","sha":"d456732ee2759d6ba63819ed10999b4acc354cdc","user":{"login":"popthestack","id":136891,"avatar_url":"https://avatars.githubusercontent.com/u/136891?v=3","gravatar_id":"","url":"https://api.github.com/users/popthestack","html_url":"https://github.com/popthestack","followers_url":"https://api.github.com/users/popthestack/followers","following_url":"https://api.github.com/users/popthestack/following{/other_user}","gists_url":"https://api.github.com/users/popthestack/gists{/gist_id}","starred_url":"https://api.github.com/users/popthestack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/popthestack/subscriptions","organizations_url":"https://api.github.com/users/popthestack/orgs","repos_url":"https://api.github.com/users/popthestack/repos","events_url":"https://api.github.com/users/popthestack/events{/privacy}","received_events_url":"https://api.github.com/users/popthestack/received_events","type":"User","site_admin":false},"repo":{"id":41521599,"name":"jetpack","full_name":"popthestack/jetpack","owner":{"login":"popthestack","id":136891,"avatar_url":"https://avatars.githubusercontent.com/u/136891?v=3","gravatar_id":"","url":"https://api.github.com/users/popthestack","html_url":"https://github.com/popthestack","followers_url":"https://api.github.com/users/popthestack/followers","following_url":"https://api.github.com/users/popthestack/following{/other_user}","gists_url":"https://api.github.com/users/popthestack/gists{/gist_id}","starred_url":"https://api.github.com/users/popthestack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/popthestack/subscriptions","organizations_url":"https://api.github.com/users/popthestack/orgs","repos_url":"https://api.github.com/users/popthestack/repos","events_url":"https://api.github.com/users/popthestack/events{/privacy}","received_events_url":"https://api.github.com/users/popthestack/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/popthestack/jetpack","description":"Your WordPress, Streamlined.","fork":true,"url":"https://api.github.com/repos/popthestack/jetpack","forks_url":"https://api.github.com/repos/popthestack/jetpack/forks","keys_url":"https://api.github.com/repos/popthestack/jetpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/popthestack/jetpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/popthestack/jetpack/teams","hooks_url":"https://api.github.com/repos/popthestack/jetpack/hooks","issue_events_url":"https://api.github.com/repos/popthestack/jetpack/issues/events{/number}","events_url":"https://api.github.com/repos/popthestack/jetpack/events","assignees_url":"https://api.github.com/repos/popthestack/jetpack/assignees{/user}","branches_url":"https://api.github.com/repos/popthestack/jetpack/branches{/branch}","tags_url":"https://api.github.com/repos/popthestack/jetpack/tags","blobs_url":"https://api.github.com/repos/popthestack/jetpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/popthestack/jetpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/popthestack/jetpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/popthestack/jetpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/popthestack/jetpack/statuses/{sha}","languages_url":"https://api.github.com/repos/popthestack/jetpack/languages","stargazers_url":"https://api.github.com/repos/popthestack/jetpack/stargazers","contributors_url":"https://api.github.com/repos/popthestack/jetpack/contributors","subscribers_url":"https://api.github.com/repos/popthestack/jetpack/subscribers","subscription_url":"https://api.github.com/repos/popthestack/jetpack/subscription","commits_url":"https://api.github.com/repos/popthestack/jetpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/popthestack/jetpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/popthestack/jetpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/popthestack/jetpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/popthestack/jetpack/contents/{+path}","compare_url":"https://api.github.com/repos/popthestack/jetpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/popthestack/jetpack/merges","archive_url":"https://api.github.com/repos/popthestack/jetpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/popthestack/jetpack/downloads","issues_url":"https://api.github.com/repos/popthestack/jetpack/issues{/number}","pulls_url":"https://api.github.com/repos/popthestack/jetpack/pulls{/number}","milestones_url":"https://api.github.com/repos/popthestack/jetpack/milestones{/number}","notifications_url":"https://api.github.com/repos/popthestack/jetpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/popthestack/jetpack/labels{/name}","releases_url":"https://api.github.com/repos/popthestack/jetpack/releases{/id}","created_at":"2015-08-28T02:10:59Z","updated_at":"2015-08-28T02:11:02Z","pushed_at":"2015-09-10T01:54:43Z","git_url":"git://github.com/popthestack/jetpack.git","ssh_url":"git@github.com:popthestack/jetpack.git","clone_url":"https://github.com/popthestack/jetpack.git","svn_url":"https://github.com/popthestack/jetpack","homepage":"http://jetpack.me","size":61158,"stargazers_count":0,"watchers_count":0,"language":"PHP","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":"Automattic:master","ref":"master","sha":"7aed6f006a1012f6680abda6cdeb31be62f6314d","user":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"repo":{"id":15231212,"name":"jetpack","full_name":"Automattic/jetpack","owner":{"login":"Automattic","id":887802,"avatar_url":"https://avatars.githubusercontent.com/u/887802?v=3","gravatar_id":"","url":"https://api.github.com/users/Automattic","html_url":"https://github.com/Automattic","followers_url":"https://api.github.com/users/Automattic/followers","following_url":"https://api.github.com/users/Automattic/following{/other_user}","gists_url":"https://api.github.com/users/Automattic/gists{/gist_id}","starred_url":"https://api.github.com/users/Automattic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Automattic/subscriptions","organizations_url":"https://api.github.com/users/Automattic/orgs","repos_url":"https://api.github.com/users/Automattic/repos","events_url":"https://api.github.com/users/Automattic/events{/privacy}","received_events_url":"https://api.github.com/users/Automattic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Automattic/jetpack","description":"Your WordPress, Streamlined.","fork":false,"url":"https://api.github.com/repos/Automattic/jetpack","forks_url":"https://api.github.com/repos/Automattic/jetpack/forks","keys_url":"https://api.github.com/repos/Automattic/jetpack/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Automattic/jetpack/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Automattic/jetpack/teams","hooks_url":"https://api.github.com/repos/Automattic/jetpack/hooks","issue_events_url":"https://api.github.com/repos/Automattic/jetpack/issues/events{/number}","events_url":"https://api.github.com/repos/Automattic/jetpack/events","assignees_url":"https://api.github.com/repos/Automattic/jetpack/assignees{/user}","branches_url":"https://api.github.com/repos/Automattic/jetpack/branches{/branch}","tags_url":"https://api.github.com/repos/Automattic/jetpack/tags","blobs_url":"https://api.github.com/repos/Automattic/jetpack/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Automattic/jetpack/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Automattic/jetpack/git/refs{/sha}","trees_url":"https://api.github.com/repos/Automattic/jetpack/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Automattic/jetpack/statuses/{sha}","languages_url":"https://api.github.com/repos/Automattic/jetpack/languages","stargazers_url":"https://api.github.com/repos/Automattic/jetpack/stargazers","contributors_url":"https://api.github.com/repos/Automattic/jetpack/contributors","subscribers_url":"https://api.github.com/repos/Automattic/jetpack/subscribers","subscription_url":"https://api.github.com/repos/Automattic/jetpack/subscription","commits_url":"https://api.github.com/repos/Automattic/jetpack/commits{/sha}","git_commits_url":"https://api.github.com/repos/Automattic/jetpack/git/commits{/sha}","comments_url":"https://api.github.com/repos/Automattic/jetpack/comments{/number}","issue_comment_url":"https://api.github.com/repos/Automattic/jetpack/issues/comments{/number}","contents_url":"https://api.github.com/repos/Automattic/jetpack/contents/{+path}","compare_url":"https://api.github.com/repos/Automattic/jetpack/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Automattic/jetpack/merges","archive_url":"https://api.github.com/repos/Automattic/jetpack/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Automattic/jetpack/downloads","issues_url":"https://api.github.com/repos/Automattic/jetpack/issues{/number}","pulls_url":"https://api.github.com/repos/Automattic/jetpack/pulls{/number}","milestones_url":"https://api.github.com/repos/Automattic/jetpack/milestones{/number}","notifications_url":"https://api.github.com/repos/Automattic/jetpack/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Automattic/jetpack/labels{/name}","releases_url":"https://api.github.com/repos/Automattic/jetpack/releases{/id}","created_at":"2013-12-16T16:43:01Z","updated_at":"2015-09-08T16:31:25Z","pushed_at":"2015-09-10T20:55:09Z","git_url":"git://github.com/Automattic/jetpack.git","ssh_url":"git@github.com:Automattic/jetpack.git","clone_url":"https://github.com/Automattic/jetpack.git","svn_url":"https://github.com/Automattic/jetpack","homepage":"http://jetpack.me","size":92614,"stargazers_count":396,"watchers_count":396,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":269,"mirror_url":null,"open_issues_count":600,"forks":269,"open_issues":600,"watchers":396,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/2685"},"html":{"href":"https://github.com/Automattic/jetpack/pull/2685"},"issue":{"href":"https://api.github.com/repos/Automattic/jetpack/issues/2685"},"comments":{"href":"https://api.github.com/repos/Automattic/jetpack/issues/2685/comments"},"review_comments":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/2685/comments"},"review_comment":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Automattic/jetpack/pulls/2685/commits"},"statuses":{"href":"https://api.github.com/repos/Automattic/jetpack/statuses/d456732ee2759d6ba63819ed10999b4acc354cdc"}}}}