mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Merge pull request #26 from hashar/handle-latex-error
Handle latex errors when converting to dvi
This commit is contained in:
commit
b6a1a6878b
1 changed files with 14 additions and 2 deletions
|
@ -3,6 +3,7 @@ from svg_mobject import SVGMobject, VMobjectFromSVGPathstring
|
||||||
from topics.geometry import BackgroundRectangle
|
from topics.geometry import BackgroundRectangle
|
||||||
from helpers import *
|
from helpers import *
|
||||||
import collections
|
import collections
|
||||||
|
import sys
|
||||||
|
|
||||||
TEX_MOB_SCALE_FACTOR = 0.05
|
TEX_MOB_SCALE_FACTOR = 0.05
|
||||||
TEXT_MOB_SCALE_FACTOR = 0.05
|
TEXT_MOB_SCALE_FACTOR = 0.05
|
||||||
|
@ -278,12 +279,23 @@ def tex_to_dvi(tex_file):
|
||||||
commands = [
|
commands = [
|
||||||
"latex",
|
"latex",
|
||||||
"-interaction=batchmode",
|
"-interaction=batchmode",
|
||||||
|
"-halt-on-error",
|
||||||
"-output-directory=" + TEX_DIR,
|
"-output-directory=" + TEX_DIR,
|
||||||
tex_file,
|
tex_file,
|
||||||
"> /dev/null"
|
"> /dev/null"
|
||||||
]
|
]
|
||||||
#TODO, Error check
|
exit_code = os.system(" ".join(commands))
|
||||||
os.system(" ".join(commands))
|
if exit_code != 0:
|
||||||
|
latex_output = ''
|
||||||
|
log_file = tex_file.replace(".tex", ".log")
|
||||||
|
if os.path.exists(log_file):
|
||||||
|
with open(log_file, 'r') as f:
|
||||||
|
latex_output = f.read()
|
||||||
|
if latex_output:
|
||||||
|
sys.stderr.write(latex_output)
|
||||||
|
raise Exception(
|
||||||
|
"Latex error converting to dvi. "
|
||||||
|
"See log output above or the log file: %s" % log_file)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def dvi_to_svg(dvi_file, regen_if_exists = False):
|
def dvi_to_svg(dvi_file, regen_if_exists = False):
|
||||||
|
|
Loading…
Add table
Reference in a new issue