Show More
@@ -97,9 +97,10 b' def latex_to_png(s, encode=False, backend=None, wrap=False):' | |||||
97 | def latex_to_png_mpl(s, wrap): |
|
97 | def latex_to_png_mpl(s, wrap): | |
98 | try: |
|
98 | try: | |
99 | from matplotlib import mathtext |
|
99 | from matplotlib import mathtext | |
|
100 | from pyparsing import ParseFatalException | |||
100 | except ImportError: |
|
101 | except ImportError: | |
101 | return None |
|
102 | return None | |
102 |
|
103 | |||
103 | # mpl mathtext doesn't support display math, force inline |
|
104 | # mpl mathtext doesn't support display math, force inline | |
104 | s = s.replace('$$', '$') |
|
105 | s = s.replace('$$', '$') | |
105 | if wrap: |
|
106 | if wrap: | |
@@ -110,7 +111,7 b' def latex_to_png_mpl(s, wrap):' | |||||
110 | f = BytesIO() |
|
111 | f = BytesIO() | |
111 | mt.to_png(f, s, fontsize=12) |
|
112 | mt.to_png(f, s, fontsize=12) | |
112 | return f.getvalue() |
|
113 | return f.getvalue() | |
113 | except: |
|
114 | except (ValueError, RuntimeError, ParseFatalException): | |
114 | return None |
|
115 | return None | |
115 |
|
116 | |||
116 |
|
117 | |||
@@ -141,7 +142,7 b' def latex_to_png_dvipng(s, wrap):' | |||||
141 |
|
142 | |||
142 | with open(outfile, "rb") as f: |
|
143 | with open(outfile, "rb") as f: | |
143 | return f.read() |
|
144 | return f.read() | |
144 | except: |
|
145 | except subprocess.CalledProcessError: | |
145 | return None |
|
146 | return None | |
146 | finally: |
|
147 | finally: | |
147 | shutil.rmtree(workdir) |
|
148 | shutil.rmtree(workdir) |
General Comments 0
You need to be logged in to leave comments.
Login now