Show More
@@ -0,0 +1,7 b'' | |||
|
1 | Relative filenames in Latex rendering | |
|
2 | ===================================== | |
|
3 | ||
|
4 | The `latex_to_png_dvipng` command internally generates input and output file arguments to `latex` and `dvipis`. These arguments are now generated as relative files to the current working directory instead of absolute file paths. | |
|
5 | This solves a problem where the current working directory contains characters that are not handled properly by `latex` and `dvips`. | |
|
6 | There are no changes to the user API. | |
|
7 |
@@ -146,11 +146,11 b" def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):" | |||
|
146 | 146 | return None |
|
147 | 147 | try: |
|
148 | 148 | workdir = Path(tempfile.mkdtemp()) |
|
149 |
tmpfile = |
|
|
150 |
dvifile = |
|
|
151 |
outfile = |
|
|
149 | tmpfile = "tmp.tex" | |
|
150 | dvifile = "tmp.dvi" | |
|
151 | outfile = "tmp.png" | |
|
152 | 152 | |
|
153 | with tmpfile.open("w", encoding="utf8") as f: | |
|
153 | with workdir.joinpath(tmpfile).open("w", encoding="utf8") as f: | |
|
154 | 154 | f.writelines(genelatex(s, wrap)) |
|
155 | 155 | |
|
156 | 156 | with open(os.devnull, 'wb') as devnull: |
@@ -181,7 +181,7 b" def latex_to_png_dvipng(s, wrap, color='Black', scale=1.0):" | |||
|
181 | 181 | stderr=devnull, |
|
182 | 182 | ) |
|
183 | 183 | |
|
184 | with outfile.open("rb") as f: | |
|
184 | with workdir.joinpath(outfile).open("rb") as f: | |
|
185 | 185 | return f.read() |
|
186 | 186 | except subprocess.CalledProcessError: |
|
187 | 187 | return None |
General Comments 0
You need to be logged in to leave comments.
Login now