{"action":"created","issue":{"url":"https://api.github.com/repos/substance/tahi-editor-ve/issues/1","labels_url":"https://api.github.com/repos/substance/tahi-editor-ve/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/substance/tahi-editor-ve/issues/1/comments","events_url":"https://api.github.com/repos/substance/tahi-editor-ve/issues/1/events","html_url":"https://github.com/substance/tahi-editor-ve/issues/1","id":94378498,"number":1,"title":"Use MathJax in a smarter way.","user":{"login":"oliver----","id":284099,"avatar_url":"https://avatars.githubusercontent.com/u/284099?v=3","gravatar_id":"","url":"https://api.github.com/users/oliver----","html_url":"https://github.com/oliver----","followers_url":"https://api.github.com/users/oliver----/followers","following_url":"https://api.github.com/users/oliver----/following{/other_user}","gists_url":"https://api.github.com/users/oliver----/gists{/gist_id}","starred_url":"https://api.github.com/users/oliver----/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliver----/subscriptions","organizations_url":"https://api.github.com/users/oliver----/orgs","repos_url":"https://api.github.com/users/oliver----/repos","events_url":"https://api.github.com/users/oliver----/events{/privacy}","received_events_url":"https://api.github.com/users/oliver----/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-10T19:46:25Z","updated_at":"2015-07-12T22:33:53Z","closed_at":null,"body":"From Lens:\r\n````\r\n  this.renderBody = function() {\r\n    var inputs = [], i;\r\n    var $content = $(this.content);\r\n    for (i=0; i<this.node.data.length; i++) {\r\n      inputs.push({\r\n        format: this.node.format[i],\r\n        data: this.node.data[i]\r\n      });\r\n    }\r\n    inputs.sort(function(a, b) {\r\n      return _precedence[a.format] - _precedence[b.format];\r\n    });\r\n\r\n    if (inputs.length > 0) {\r\n      // TODO: we should allow to make it configurable\r\n      // which math source format should be used in first place\r\n      // For now, we take the first available format which is not image\r\n      // and use the image to configure MathJax's preview.\r\n      var hasPreview = false;\r\n      var hasSource = false;\r\n\r\n      // always add a preview element as this is better for MJ\r\n      // ... and add it before the script element\r\n      var $preview = $('<span>').addClass('MathJax_Preview');\r\n      this.$content.append($preview);\r\n\r\n      for (i=0; i<inputs.length; i++) {\r\n        var format = inputs[i].format;\r\n        var data = inputs[i].data;\r\n        switch (format) {\r\n          case \"mathml\":\r\n          case \"latex\":\r\n            // add only one source\r\n            if (!hasSource) {\r\n              var type = _types[format];\r\n              if (!this.node.inline) type += \"; mode=display\";\r\n              var scriptEl = document.createElement('script');\r\n              scriptEl.setAttribute(\"type\", type);\r\n              scriptEl.textContent = data;\r\n              this.content.appendChild(scriptEl);\r\n              hasSource = true;\r\n              // if there has been no other preview, just use the source as preview\r\n              if (!hasPreview) {\r\n                $preview.append(data);\r\n                hasPreview = true;\r\n              }\r\n            }\r\n            break;\r\n          case \"image\":\r\n            // add only one preview\r\n            if (!hasPreview) {\r\n              $preview.append($('<img>').attr('src', data));\r\n              hasPreview = true;\r\n            }\r\n            break;\r\n          case \"svg\":\r\n            // add only one preview\r\n            if (!hasPreview) {\r\n              $preview.append($(data));\r\n              hasPreview = true;\r\n            }\r\n            break;\r\n          default:\r\n            console.error(\"Unknown formula format:\", format);\r\n        }\r\n      }\r\n    }\r\n\r\n    if (this.options.header) {\r\n      var gotoMainOccurrence = $$('a.jump-to-resource', {\r\n        href: '#',\r\n        html: \"<i class=\\\"icon-search\\\"></i> Show in context\"\r\n      });\r\n      $content.append(gotoMainOccurrence);\r\n\r\n      var numberRefsEl = $$('div.number-of-references');\r\n      var numRefs = this.node.document.indexes.referenceByTarget.get(this.node.id).getLength();\r\n      if (numRefs === 0) {\r\n        numberRefsEl.textContent = \"No references\";\r\n      } else if (numRefs === 1) {\r\n        numberRefsEl.textContent = \"1 reference\";\r\n      } else {\r\n        numberRefsEl.textContent = numRefs + \" references\";\r\n      }\r\n      $content.append(numberRefsEl);\r\n    }\r\n ````"},"comment":{"url":"https://api.github.com/repos/substance/tahi-editor-ve/issues/comments/120769822","html_url":"https://github.com/substance/tahi-editor-ve/issues/1#issuecomment-120769822","issue_url":"https://api.github.com/repos/substance/tahi-editor-ve/issues/1","id":120769822,"user":{"login":"oliver----","id":284099,"avatar_url":"https://avatars.githubusercontent.com/u/284099?v=3","gravatar_id":"","url":"https://api.github.com/users/oliver----","html_url":"https://github.com/oliver----","followers_url":"https://api.github.com/users/oliver----/followers","following_url":"https://api.github.com/users/oliver----/following{/other_user}","gists_url":"https://api.github.com/users/oliver----/gists{/gist_id}","starred_url":"https://api.github.com/users/oliver----/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oliver----/subscriptions","organizations_url":"https://api.github.com/users/oliver----/orgs","repos_url":"https://api.github.com/users/oliver----/repos","events_url":"https://api.github.com/users/oliver----/events{/privacy}","received_events_url":"https://api.github.com/users/oliver----/received_events","type":"User","site_admin":false},"created_at":"2015-07-12T22:33:53Z","updated_at":"2015-07-12T22:33:53Z","body":"Some links:\r\nhttp://docs.mathjax.org/en/latest/model.html\r\nhttp://docs.mathjax.org/en/latest/typeset.html"}}