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