def png(contents, latex_command):
"""Creates a png if needed."""
outfile = sha(contents + latex_command)
src = os.path.join(IMAGEDIR, outfile + '.png')
if not os.path.isfile(src):
try:
os.mkdir(IMAGEDIR)
stderr.write('Created directory ' + IMAGEDIR + '\n')
except OSError:
pass
latex2png(latex_command + "{" + contents + "}", outfile)
stderr.write('Created image ' + src + '\n')
return src
评论列表
文章目录