fixed a bug with wrong LaTeX input
This commit is contained in:
parent
249e64bc72
commit
6095292560
|
@ -20,11 +20,18 @@ from io import BytesIO
|
|||
import matplotlib
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
import importlib
|
||||
|
||||
|
||||
def get_png(tex):
|
||||
importlib.reload(plt)
|
||||
buf = BytesIO()
|
||||
|
||||
exc = None
|
||||
|
||||
try:
|
||||
plt.subplot()
|
||||
|
||||
plt.text(0, 0.6, r"$%s$" % tex, fontsize = 50)
|
||||
fig = plt.gca()
|
||||
fig.axes.get_xaxis().set_visible(False)
|
||||
|
@ -34,7 +41,13 @@ def get_png(tex):
|
|||
|
||||
buf.seek(0)
|
||||
|
||||
except Exception as e:
|
||||
exc = e
|
||||
finally:
|
||||
plt.clf()
|
||||
|
||||
if(exc):
|
||||
raise exc
|
||||
|
||||
return buf
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user