##// END OF EJS Templates
a few fixes...
Matthias BUSSONNIER -
Show More
@@ -1,6 +1,12 b''
1 """Utility function for installing MathJax javascript library into
1 """Utility function for installing MathJax javascript library into
2 the notebook's 'static' directory, for offline use.
2 the notebook's 'static' directory, for offline use.
3
3
4 Authors:
5
6 * Min RK
7 * Mark Sienkiewicz
8 * Matthias Bussonnier
9
4 To download and install MathJax:
10 To download and install MathJax:
5
11
6 From Python:
12 From Python:
@@ -33,11 +39,6 b' To find the directory where IPython would like MathJax installed:'
33 # the file COPYING, distributed as part of this software.
39 # the file COPYING, distributed as part of this software.
34 #-----------------------------------------------------------------------------
40 #-----------------------------------------------------------------------------
35
41
36 # Authors:
37 #
38 # * Min RK
39 # * Mark Sienkiewicz at Space Telescope Science Institute (command line invocation)
40 #
41
42
42 #-----------------------------------------------------------------------------
43 #-----------------------------------------------------------------------------
43 # Imports
44 # Imports
@@ -50,16 +51,13 b' import tarfile'
50 import urllib2
51 import urllib2
51 import zipfile
52 import zipfile
52
53
53 from IPython.frontend.html import notebook as nbmod
54
55 #-----------------------------------------------------------------------------
54 #-----------------------------------------------------------------------------
56 #
55 #
57 #-----------------------------------------------------------------------------
56 #-----------------------------------------------------------------------------
58
57
59 # Where mathjax will be installed.
58 # Where mathjax will be installed.
60
59
61 static = os.path.join(os.path.dirname(os.path.abspath(nbmod.__file__)), 'static')
60 dest = os.path.join(locate_profile('default'), 'static')
62 dest = os.path.join(static, 'mathjax')
63
61
64 ##
62 ##
65
63
@@ -116,8 +114,8 b' def extract_zip( fd, dest ) :'
116
114
117 ##
115 ##
118
116
119 def install_mathjax(tag='v1.1', replace=False, fd=None, extractor=extract_tar ):
117 def install_mathjax(tag='v2.0', replace=False, file=None, extractor=extract_tar ):
120 """Download and install MathJax for offline use.
118 """Download and/or install MathJax for offline use.
121
119
122 This will install mathjax to the 'static' dir in the IPython notebook
120 This will install mathjax to the 'static' dir in the IPython notebook
123 package, so it will fail if the caller does not have write access
121 package, so it will fail if the caller does not have write access
@@ -130,20 +128,24 b" def install_mathjax(tag='v1.1', replace=False, fd=None, extractor=extract_tar ):"
130
128
131 replace : bool [False]
129 replace : bool [False]
132 Whether to remove and replace an existing install.
130 Whether to remove and replace an existing install.
133 tag : str ['v1.1']
131 tag : str ['v2.0']
134 Which tag to download. Default is 'v1.1', the current stable release,
132 Which tag to download. Default is 'v1.1', the current stable release,
135 but alternatives include 'v1.1a' and 'master'.
133 but alternatives include 'v1.1a' and 'master'.
134 file : file like object [ defualt to content of https://github.com/mathjax/MathJax/tarball/#{tag}]
135 File handle from which to untar/unzip/... mathjax
136 extractor : function
137 Method tu use to untar/unzip/... `file`
136 """
138 """
137
139
138 if not check_perms(replace) :
140 if not check_perms(replace) :
139 return
141 return
140
142
141 if fd is None :
143 if file is None :
142 # download mathjax
144 # download mathjax
143 mathjax_url = "https://github.com/mathjax/MathJax/tarball/%s"%tag
145 mathjax_url = "https://github.com/mathjax/MathJax/tarball/%s"%tag
144 print "Downloading mathjax source from %s"%mathjax_url
146 print "Downloading mathjax source from %s"%mathjax_url
145 response = urllib2.urlopen(mathjax_url)
147 response = urllib2.urlopen(mathjax_url)
146 fd = response.fp
148 file = response.fp
147
149
148 print "Extracting to %s"%dest
150 print "Extracting to %s"%dest
149 extractor( fd, dest )
151 extractor( fd, dest )
@@ -161,7 +163,7 b' def test_func( remove ) :'
161 print "ok"
163 print "ok"
162 if remove :
164 if remove :
163 shutil.rmtree( dest )
165 shutil.rmtree( dest )
164 return 0
166 return status
165
167
166 ##
168 ##
167
169
@@ -357,8 +357,9 b' For unusual needs, IPython can tell you what directory it wants to find MathJax '
357
357
358 python -m IPython.external.mathjax -d
358 python -m IPython.external.mathjax -d
359
359
360 All of these options require write access to the IPython install directory, so if
360 By default Mathjax will be installed in your ipython profile directory, but you
361 you have a system-wide Python install, it may need to be done with ``sudo``.
361 can make system wide install, please refere to the documentation and helper function
362 of IPython.external.mathjax
362
363
363 Browser Compatibility
364 Browser Compatibility
364 ---------------------
365 ---------------------
General Comments 0
You need to be logged in to leave comments. Login now