Show More
@@ -12,6 +12,8 b' import subprocess' | |||
|
12 | 12 | from base64 import encodebytes |
|
13 | 13 | import textwrap |
|
14 | 14 | |
|
15 | from pathlib import Path, PurePath | |
|
16 | ||
|
15 | 17 | from IPython.utils.process import find_cmd, FindCmdError |
|
16 | 18 | from traitlets.config import get_config |
|
17 | 19 | from traitlets.config.configurable import SingletonConfigurable |
@@ -136,12 +138,12 b" def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):" | |||
|
136 | 138 | except FindCmdError: |
|
137 | 139 | return None |
|
138 | 140 | try: |
|
139 | workdir = tempfile.mkdtemp() | |
|
140 |
tmpfile = |
|
|
141 |
dvifile = |
|
|
142 |
outfile = |
|
|
141 | workdir = PurePath(tempfile.mkdtemp()) | |
|
142 | tmpfile = workdir.joinpath("tmp.tex") | |
|
143 | dvifile = workdir.joinpath("tmp.dvi") | |
|
144 | outfile = workdir.joinpath("tmp.png") | |
|
143 | 145 | |
|
144 |
with open( |
|
|
146 | with tmpfile.open("w", encoding='utf8') as f: | |
|
145 | 147 | f.writelines(genelatex(s, wrap)) |
|
146 | 148 | |
|
147 | 149 | with open(os.devnull, 'wb') as devnull: |
@@ -155,7 +157,7 b" def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):" | |||
|
155 | 157 | "-bg", "transparent", "-o", outfile, dvifile, "-fg", color], |
|
156 | 158 | cwd=workdir, stdout=devnull, stderr=devnull) |
|
157 | 159 | |
|
158 |
with open( |
|
|
160 | with outfile.open("rb") as f: | |
|
159 | 161 | return f.read() |
|
160 | 162 | except subprocess.CalledProcessError: |
|
161 | 163 | return None |
General Comments 0
You need to be logged in to leave comments.
Login now