ipython/ipython — pull request #6948 by bollwyvl (2014-11-15 16:26:20+00:00)
Title: Ignore failure of widget MathJax typesetting

Having never known MathJax `$...$` could be used for _some_ of the core widgets, it was surprising and confusing when I was (trying) to give an impromptu, disconnected demo and nothing worked because MathJax wasn't available.

I understand the desire to make this fairly-heavyweight dependency an optional install. But widgets should probably not fail unusably when MathJax isn't available, for whatever reason.

This PR moves the actual, ungainly `MathJax.Hub.Queue` call from _n_ places around the core widgets to `DOMWidgetView`, under a much simpler API, `.typeset(element, [text])`, where the presence of MathJax is tested. Since typesetting brings with it more expectations (i.e., you won't have any other DOM children), `.typeset` also optionally accepts the text to set, and since jQuery is used so extensively throughout core, the element can be a jquery selector.

## Questions for other PRs
- Should typesetting-as-default be extended across all the core widgets (i.e. `Button.description`, `Accordion.titles`, probably more...)?
- Could this be made more explicit, such as with a traitlet type, e.g. `TypesetUnicode`...
- Actually would there be any way for the downstream to know that was the case?
- Should this, one of the few, and most idiosyncratic, remaining uses of `window` globals, be wrapped, with a `util`, something like:

```js
require(["notebook/js/mathjaxutils"], function(mathjax){
mathjax().then(
function(yup){...},
function(nope){...}
)
})
```