Skip to content

Commit d0ecacd

Browse files
committed
add missing file, no outputs when generating svg/png files
1 parent c17e87d commit d0ecacd

File tree

3 files changed

+90
-6
lines changed

3 files changed

+90
-6
lines changed

Diff for: etc/default.svg

+83
Loading

Diff for: python2/pracmln/utils/latexmath2png.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __write_output(infile, outdir, workdir='.', filename='', size=1, svg=True):
9191
outfilename = os.path.join(outdir, filename)
9292

9393
if svg:
94-
dvicmd = "dvisvgm -o {}.svg --no-fonts {} >/dev/null".format(outfilename, dvifile)
94+
dvicmd = "dvisvgm -v 0 -o {}.svg --no-fonts {}".format(outfilename, dvifile)
9595
else:
9696
dvicmd = "dvipng -q* -T tight -x {} -z 9 -bg Transparent -o {}.png {} >/dev/null".format(size * 1000, outfilename, dvifile)
9797
rc = os.system(dvicmd)
@@ -144,6 +144,7 @@ def math2png(content, outdir, packages=default_packages, declarations=[], filena
144144
'generating the {} image from the .dvi file.'.format('dvisvgm' if svg else 'dvipng', 'svg' if svg else 'png'))
145145
outfilename = os.path.join(locs.etc, 'default.{}'.format('svg' if svg else 'png'))
146146
finally:
147+
outfilename = os.path.join(locs.etc, 'default.{}'.format('svg' if svg else 'png'))
147148
if svg:
148149
with open(outfilename, 'r') as outfile:
149150
filecontent = outfile.read()
@@ -159,8 +160,8 @@ def math2png(content, outdir, packages=default_packages, declarations=[], filena
159160
filecontent = base64.b64encode(png.read())
160161

161162
# cleanup and delete temporary files
162-
if os.path.exists(texfile):
163+
if os.path.exists(texfile) and locs.etc not in outfilename:
163164
os.remove(texfile)
164-
if os.path.exists(outfilename):
165+
if os.path.exists(outfilename) and locs.etc not in outfilename:
165166
os.remove(outfilename)
166167
return filecontent, ratio

Diff for: python3/pracmln/utils/latexmath2png.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __write_output(infile, outdir, workdir='.', filename='', size=1, svg=True):
9191
outfilename = os.path.join(outdir, filename)
9292

9393
if svg:
94-
dvicmd = "dvisvgm -o {}.svg --no-fonts {} >/dev/null".format(outfilename, dvifile)
94+
dvicmd = "dvisvgm -v 0 -o {}.svg --no-fonts {}".format(outfilename, dvifile)
9595
else:
9696
dvicmd = "dvipng -q* -T tight -x {} -z 9 -bg Transparent -o {}.png {} >/dev/null".format(size * 1000, outfilename, dvifile)
9797
rc = os.system(dvicmd)
@@ -159,8 +159,8 @@ def math2png(content, outdir, packages=default_packages, declarations=[], filena
159159
filecontent = base64.b64encode(png.read())
160160

161161
# cleanup and delete temporary files
162-
if os.path.exists(texfile):
162+
if os.path.exists(texfile) and locs.etc not in outfilename:
163163
os.remove(texfile)
164-
if os.path.exists(outfilename):
164+
if os.path.exists(outfilename) and locs.etc not in outfilename:
165165
os.remove(outfilename)
166166
return filecontent, ratio

0 commit comments

Comments
 (0)