Merge pull request #27 from minrk/mathjax

add mathjax to components
This commit is contained in:
Matthias Bussonnier 2015-04-17 13:19:35 -07:00 committed by Min RK
commit 5d6a9b7065
5 changed files with 25 additions and 22 deletions

View File

@ -20,8 +20,6 @@ before_install:
- git clone --quiet --depth 1 https://github.com/minrk/travis-wheels travis-wheels
install:
- pip install -f travis-wheels/wheelhouse -r requirements.txt file://$PWD#egg=jupyter_notebook[test] coveralls
before_script:
- 'if [[ $GROUP == js* ]]; then python -m IPython.external.mathjax mathjax.zip; fi'
script:
- 'if [[ $GROUP == js* ]]; then python -m jupyter_notebook.jstest $GROUP; fi'
- 'if [[ $GROUP == python ]]; then nosetests --with-coverage --cover-package=jupyter_notebook jupyter_notebook; fi'

View File

@ -12,6 +12,7 @@
"jquery": "components/jquery#~2.0",
"jquery-ui": "components/jqueryui#~1.10",
"marked": "~0.3",
"MathJax": "~2.5",
"moment": "~2.8.4",
"requirejs": "~2.1",
"term.js": "chjj/term.js#~0.0.4",

View File

@ -617,26 +617,7 @@ class NotebookApp(JupyterApp):
static_url_prefix = self.tornado_settings.get("static_url_prefix",
url_path_join(self.base_url, "static")
)
# try local mathjax, either in nbextensions/mathjax or static/mathjax
for (url_prefix, search_path) in [
(url_path_join(self.base_url, "nbextensions"), self.nbextensions_path),
(static_url_prefix, self.static_file_path),
]:
self.log.debug("searching for local mathjax in %s", search_path)
try:
mathjax = filefind(os.path.join('mathjax', 'MathJax.js'), search_path)
except IOError:
continue
else:
url = url_path_join(url_prefix, u"mathjax/MathJax.js")
self.log.info("Serving local MathJax from %s at %s", mathjax, url)
return url
# no local mathjax, serve from CDN
url = u"https://cdn.mathjax.org/mathjax/latest/MathJax.js"
self.log.info("Using MathJax from CDN: %s", url)
return url
return url_path_join(static_url_prefix, 'components', 'MathJax', 'MathJax.js')
def _mathjax_url_changed(self, name, old, new):
if new and not self.enable_mathjax:

View File

@ -23,6 +23,10 @@ define([
// we use CSS to left justify single line equations in code cells.
displayAlign: 'center',
"HTML-CSS": {
availableFonts: [],
imageFont: null,
preferredFont: null,
webFont: "STIX-Web",
styles: {'.MathJax_Display': {"margin": 0}},
linebreaks: { automatic: true }
}

View File

@ -138,6 +138,25 @@ def find_package_data():
if f.endswith(('.js', '.css')):
static_data.append(pjoin(parent, f))
# Trim mathjax
mj = lambda *path: pjoin(components, 'MathJax', *path)
static_data.extend([
mj('MathJax.js'),
mj('config', 'TeX-AMS_HTML-full.js'),
mj('jax', 'output', 'HTML-CSS', '*.js'),
])
for tree in [
mj('localization'), # limit to en?
mj('fonts', 'HTML-CSS', 'STIX-Web', 'woff'),
mj('jax', 'input', 'TeX'),
mj('jax', 'output', 'HTML-CSS', 'autoload'),
mj('jax', 'output', 'HTML-CSS', 'fonts', 'STIX-Web'),
]:
for parent, dirs, files in os.walk(tree):
for f in files:
static_data.append(pjoin(parent, f))
os.chdir(os.path.join('tests',))
js_tests = glob('*.js') + glob('*/*.js')