2018-03-30 18:19:23 -07:00
|
|
|
from constants import *
|
2017-06-06 16:03:53 -07:00
|
|
|
|
2018-03-31 15:11:35 -07:00
|
|
|
from svg_mobject import SVGMobject
|
|
|
|
from svg_mobject import VMobjectFromSVGPathstring
|
2018-03-30 18:19:23 -07:00
|
|
|
from utils.config_ops import digest_config
|
2018-05-05 20:16:20 -07:00
|
|
|
from utils.strings import split_string_list_to_isolate_substring
|
2018-03-31 18:05:02 -07:00
|
|
|
from mobject.types.vectorized_mobject import VGroup
|
|
|
|
from mobject.types.vectorized_mobject import VectorizedPoint
|
2017-06-06 16:03:53 -07:00
|
|
|
|
2018-03-30 18:42:32 -07:00
|
|
|
import operator as op
|
2015-10-28 17:18:50 -07:00
|
|
|
|
2018-05-05 19:41:08 -07:00
|
|
|
# TODO list
|
|
|
|
# - Make sure if "color" is passed into TexMobject, it behaves as expected
|
2016-04-20 19:24:54 -07:00
|
|
|
|
2018-05-05 19:41:08 -07:00
|
|
|
TEX_MOB_SCALE_FACTOR = 0.05
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-05-05 20:16:20 -07:00
|
|
|
|
2016-04-20 19:24:54 -07:00
|
|
|
class TexSymbol(VMobjectFromSVGPathstring):
|
2016-07-19 11:08:31 -07:00
|
|
|
def pointwise_become_partial(self, mobject, a, b):
|
2018-04-06 13:58:59 -07:00
|
|
|
# TODO, this assumes a = 0
|
2016-04-20 19:24:54 -07:00
|
|
|
if b < 0.5:
|
2018-04-06 13:58:59 -07:00
|
|
|
b = 2 * b
|
2017-06-21 22:55:10 -07:00
|
|
|
added_width = 1
|
2016-04-20 19:24:54 -07:00
|
|
|
opacity = 0
|
|
|
|
else:
|
2018-04-06 13:58:59 -07:00
|
|
|
added_width = 2 - 2 * b
|
|
|
|
opacity = 2 * b - 1
|
2016-04-20 19:24:54 -07:00
|
|
|
b = 1
|
2016-07-19 11:08:31 -07:00
|
|
|
VMobjectFromSVGPathstring.pointwise_become_partial(
|
2016-04-20 19:24:54 -07:00
|
|
|
self, mobject, 0, b
|
|
|
|
)
|
2018-04-06 13:58:59 -07:00
|
|
|
self.set_stroke(width=added_width + mobject.get_stroke_width())
|
|
|
|
self.set_fill(opacity=opacity)
|
|
|
|
|
2016-04-20 19:24:54 -07:00
|
|
|
|
2018-05-05 19:41:08 -07:00
|
|
|
class SingleStringTexMobject(SVGMobject):
|
2016-02-27 16:32:53 -08:00
|
|
|
CONFIG = {
|
2018-04-06 13:58:59 -07:00
|
|
|
"template_tex_file": TEMPLATE_TEX_FILE,
|
|
|
|
"stroke_width": 0,
|
|
|
|
"fill_opacity": 1.0,
|
|
|
|
"should_center": True,
|
|
|
|
"height": None,
|
|
|
|
"organize_left_to_right": False,
|
|
|
|
"propagate_style_to_family": True,
|
|
|
|
"alignment": "",
|
2015-10-28 17:18:50 -07:00
|
|
|
}
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2018-05-05 19:41:08 -07:00
|
|
|
def __init__(self, tex_string, **kwargs):
|
|
|
|
digest_config(self, kwargs)
|
|
|
|
assert(isinstance(tex_string, str))
|
2018-05-05 19:49:25 -07:00
|
|
|
self.tex_string = tex_string
|
2016-11-07 11:05:41 -08:00
|
|
|
file_name = tex_to_svg_file(
|
2018-05-05 19:49:25 -07:00
|
|
|
self.get_modified_expression(tex_string),
|
2016-11-07 11:05:41 -08:00
|
|
|
self.template_tex_file
|
|
|
|
)
|
2018-04-06 13:58:59 -07:00
|
|
|
SVGMobject.__init__(self, file_name=file_name, **kwargs)
|
2018-05-05 19:41:08 -07:00
|
|
|
if self.height is None:
|
|
|
|
self.scale(TEX_MOB_SCALE_FACTOR)
|
2016-07-12 10:34:35 -07:00
|
|
|
if self.organize_left_to_right:
|
|
|
|
self.organize_submobjects_left_to_right()
|
2016-04-17 12:59:53 -07:00
|
|
|
|
2018-05-05 19:41:08 -07:00
|
|
|
def get_modified_expression(self, tex_string):
|
|
|
|
result = self.alignment + " " + tex_string
|
2016-09-10 17:35:15 -07:00
|
|
|
result = result.strip()
|
2017-04-20 13:30:51 -07:00
|
|
|
result = self.modify_special_strings(result)
|
2016-07-21 15:16:49 -07:00
|
|
|
return result
|
2016-07-21 11:00:45 -07:00
|
|
|
|
2017-04-20 13:30:51 -07:00
|
|
|
def modify_special_strings(self, tex):
|
|
|
|
tex = self.remove_stray_braces(tex)
|
2017-06-06 16:03:53 -07:00
|
|
|
if tex in ["\\over", "\\overline"]:
|
2018-04-06 13:58:59 -07:00
|
|
|
# fraction line needs something to be over
|
2017-06-06 16:03:53 -07:00
|
|
|
tex += "\\,"
|
2017-08-08 21:42:23 -07:00
|
|
|
if tex == "\\sqrt":
|
|
|
|
tex += "{\\quad}"
|
2017-08-25 17:56:55 -07:00
|
|
|
if tex == "\\substack":
|
|
|
|
tex = ""
|
2017-05-25 15:12:18 -07:00
|
|
|
for t1, t2 in ("\\left", "\\right"), ("\\right", "\\left"):
|
2017-06-12 12:58:56 -07:00
|
|
|
should_replace = reduce(op.and_, [
|
|
|
|
t1 in tex,
|
|
|
|
t2 not in tex,
|
2018-01-23 02:14:18 +08:00
|
|
|
len(tex) > len(t1) and tex[len(t1)] in "()[]<>|.\\"
|
2017-06-12 12:58:56 -07:00
|
|
|
])
|
|
|
|
if should_replace:
|
2017-05-25 15:12:18 -07:00
|
|
|
tex = tex.replace(t1, "\\big")
|
2017-08-29 00:04:25 -07:00
|
|
|
if tex == "":
|
|
|
|
tex = "\\quad"
|
2017-04-20 13:30:51 -07:00
|
|
|
return tex
|
|
|
|
|
2017-02-16 13:03:26 -08:00
|
|
|
def remove_stray_braces(self, tex):
|
|
|
|
"""
|
|
|
|
Makes TexMobject resiliant to unmatched { at start
|
|
|
|
"""
|
|
|
|
num_lefts, num_rights = [
|
|
|
|
tex.count(char)
|
|
|
|
for char in "{}"
|
|
|
|
]
|
2017-02-16 20:21:35 -08:00
|
|
|
if num_rights > num_lefts:
|
2017-04-21 17:40:49 -07:00
|
|
|
backwards = tex[::-1].replace("}", "", num_rights - num_lefts)
|
2017-02-16 20:21:35 -08:00
|
|
|
tex = backwards[::-1]
|
|
|
|
elif num_lefts > num_rights:
|
2017-04-21 17:40:49 -07:00
|
|
|
tex = tex.replace("{", "", num_lefts - num_rights)
|
2017-02-16 13:03:26 -08:00
|
|
|
return tex
|
|
|
|
|
2016-08-23 13:38:33 -07:00
|
|
|
def get_tex_string(self):
|
|
|
|
return self.tex_string
|
|
|
|
|
2018-05-05 19:41:08 -07:00
|
|
|
def path_string_to_mobject(self, path_string):
|
|
|
|
# Overwrite superclass default to use
|
|
|
|
# specialized path_string mobject
|
|
|
|
return TexSymbol(path_string)
|
|
|
|
|
|
|
|
def organize_submobjects_left_to_right(self):
|
|
|
|
self.sort_submobjects(lambda p: p[0])
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
|
|
class TexMobject(SingleStringTexMobject):
|
|
|
|
CONFIG = {
|
|
|
|
"arg_separator": " ",
|
2018-05-05 20:16:20 -07:00
|
|
|
"substrings_to_isolate": [],
|
2018-05-05 20:19:33 -07:00
|
|
|
"tex_to_color_map": {},
|
2018-05-05 19:41:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
def __init__(self, *tex_strings, **kwargs):
|
|
|
|
digest_config(self, kwargs)
|
2018-05-05 20:16:20 -07:00
|
|
|
tex_strings = self.break_up_tex_strings(tex_strings)
|
2018-05-05 19:41:08 -07:00
|
|
|
self.tex_strings = tex_strings
|
|
|
|
SingleStringTexMobject.__init__(
|
|
|
|
self, self.arg_separator.join(tex_strings), **kwargs
|
|
|
|
)
|
|
|
|
self.break_up_by_substrings()
|
2018-05-05 20:19:33 -07:00
|
|
|
self.set_color_by_tex_to_color_map(self.tex_to_color_map)
|
2018-05-05 19:41:08 -07:00
|
|
|
|
|
|
|
if self.organize_left_to_right:
|
|
|
|
self.organize_submobjects_left_to_right()
|
|
|
|
|
2018-05-05 20:16:20 -07:00
|
|
|
def break_up_tex_strings(self, tex_strings):
|
2018-05-05 20:19:33 -07:00
|
|
|
substrings_to_isolate = op.add(
|
|
|
|
self.substrings_to_isolate,
|
|
|
|
self.tex_to_color_map.keys()
|
|
|
|
)
|
2018-05-05 20:16:20 -07:00
|
|
|
split_list = split_string_list_to_isolate_substring(
|
2018-05-05 20:19:33 -07:00
|
|
|
tex_strings, *substrings_to_isolate
|
2018-05-05 20:16:20 -07:00
|
|
|
)
|
|
|
|
split_list = map(str.strip, split_list)
|
|
|
|
split_list = filter(lambda s: s != '', split_list)
|
|
|
|
return split_list
|
|
|
|
|
2018-05-05 19:41:08 -07:00
|
|
|
def break_up_by_substrings(self):
|
2017-06-06 16:03:53 -07:00
|
|
|
"""
|
2017-10-05 21:03:30 -05:00
|
|
|
Reorganize existing submojects one layer
|
2018-05-05 19:41:08 -07:00
|
|
|
deeper based on the structure of tex_strings (as a list
|
|
|
|
of tex_strings)
|
2017-06-06 16:03:53 -07:00
|
|
|
"""
|
2016-07-21 11:00:45 -07:00
|
|
|
new_submobjects = []
|
|
|
|
curr_index = 0
|
2018-05-05 19:49:25 -07:00
|
|
|
for tex_string in self.tex_strings:
|
|
|
|
sub_tex_mob = SingleStringTexMobject(tex_string, **self.CONFIG)
|
2017-06-06 16:03:53 -07:00
|
|
|
num_submobs = len(sub_tex_mob.submobjects)
|
|
|
|
new_index = curr_index + num_submobs
|
|
|
|
if num_submobs == 0:
|
2018-05-05 19:41:08 -07:00
|
|
|
# For cases like empty tex_strings, we want the corresponing
|
|
|
|
# part of the whole TexMobject to be a VectorizedPoint
|
|
|
|
# positioned in the right part of the TexMobject
|
|
|
|
sub_tex_mob.submobjects = [VectorizedPoint()]
|
|
|
|
last_submob_index = min(curr_index, len(self.submobjects) - 1)
|
|
|
|
sub_tex_mob.move_to(self.submobjects[last_submob_index], RIGHT)
|
2017-06-06 16:03:53 -07:00
|
|
|
else:
|
|
|
|
sub_tex_mob.submobjects = self.submobjects[curr_index:new_index]
|
2017-03-28 11:12:02 -07:00
|
|
|
new_submobjects.append(sub_tex_mob)
|
2016-07-21 11:00:45 -07:00
|
|
|
curr_index = new_index
|
|
|
|
self.submobjects = new_submobjects
|
2016-04-17 12:59:53 -07:00
|
|
|
return self
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
def get_parts_by_tex(self, tex, substring=True, case_sensitive=True):
|
2017-03-10 16:55:23 -08:00
|
|
|
def test(tex1, tex2):
|
2018-02-14 12:32:58 -08:00
|
|
|
if not case_sensitive:
|
|
|
|
tex1 = tex1.lower()
|
|
|
|
tex2 = tex2.lower()
|
|
|
|
if substring:
|
|
|
|
return tex1 in tex2
|
|
|
|
else:
|
|
|
|
return tex1 == tex2
|
2017-03-22 15:06:17 -07:00
|
|
|
|
2017-04-21 17:40:49 -07:00
|
|
|
return VGroup(*filter(
|
2018-04-06 13:58:59 -07:00
|
|
|
lambda m: test(tex, m.get_tex_string()),
|
2018-05-05 19:41:08 -07:00
|
|
|
self.submobjects
|
2017-04-21 17:40:49 -07:00
|
|
|
))
|
2017-03-25 12:18:33 -07:00
|
|
|
|
2017-03-22 15:06:17 -07:00
|
|
|
def get_part_by_tex(self, tex, **kwargs):
|
|
|
|
all_parts = self.get_parts_by_tex(tex, **kwargs)
|
|
|
|
return all_parts[0] if all_parts else None
|
2017-03-10 16:55:23 -08:00
|
|
|
|
2018-03-30 11:51:31 -07:00
|
|
|
def set_color_by_tex(self, tex, color, **kwargs):
|
2017-03-10 16:55:23 -08:00
|
|
|
parts_to_color = self.get_parts_by_tex(tex, **kwargs)
|
|
|
|
for part in parts_to_color:
|
2018-03-30 11:51:31 -07:00
|
|
|
part.set_color(color)
|
2016-08-18 12:54:04 -07:00
|
|
|
return self
|
|
|
|
|
2018-03-30 11:51:31 -07:00
|
|
|
def set_color_by_tex_to_color_map(self, texs_to_color_map, **kwargs):
|
2018-01-23 02:14:18 +08:00
|
|
|
for texs, color in texs_to_color_map.items():
|
|
|
|
try:
|
2018-05-05 19:41:08 -07:00
|
|
|
# If the given key behaves like tex_strings
|
2018-01-23 02:14:18 +08:00
|
|
|
texs + ''
|
2018-03-30 11:51:31 -07:00
|
|
|
self.set_color_by_tex(texs, color, **kwargs)
|
2018-01-23 02:14:18 +08:00
|
|
|
except TypeError:
|
|
|
|
# If the given key is a tuple
|
|
|
|
for tex in texs:
|
2018-03-30 11:51:31 -07:00
|
|
|
self.set_color_by_tex(tex, color, **kwargs)
|
2017-07-20 13:37:12 -07:00
|
|
|
return self
|
|
|
|
|
2017-05-05 11:19:10 -07:00
|
|
|
def index_of_part(self, part):
|
|
|
|
split_self = self.split()
|
|
|
|
if part not in split_self:
|
|
|
|
raise Exception("Trying to get index of part not in TexMobject")
|
2018-04-11 17:14:02 -07:00
|
|
|
return split_self.index(part)
|
2017-05-05 11:19:10 -07:00
|
|
|
|
|
|
|
def index_of_part_by_tex(self, tex, **kwargs):
|
|
|
|
part = self.get_part_by_tex(tex, **kwargs)
|
|
|
|
return self.index_of_part(part)
|
|
|
|
|
2018-05-07 13:32:47 -07:00
|
|
|
def split(self):
|
|
|
|
# Many old scenes assume that when you pass in a single string
|
|
|
|
# to TexMobject, it indexes across the characters.
|
|
|
|
if len(self.submobjects) == 1:
|
|
|
|
return self.submobjects[0].split()
|
|
|
|
else:
|
|
|
|
return super(TexMobject, self).split()
|
2018-04-11 17:14:02 -07:00
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2015-10-28 17:18:50 -07:00
|
|
|
class TextMobject(TexMobject):
|
2016-02-27 16:32:53 -08:00
|
|
|
CONFIG = {
|
2018-04-06 13:58:59 -07:00
|
|
|
"template_tex_file": TEMPLATE_TEXT_FILE,
|
|
|
|
"alignment": "\\centering",
|
2015-10-28 17:18:50 -07:00
|
|
|
}
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2017-10-19 14:31:55 -07:00
|
|
|
class BulletedList(TextMobject):
|
|
|
|
CONFIG = {
|
2018-04-06 13:58:59 -07:00
|
|
|
"buff": MED_LARGE_BUFF,
|
|
|
|
"dot_scale_factor": 2,
|
|
|
|
# Have to include because of handle_multiple_args implementation
|
|
|
|
"template_tex_file": TEMPLATE_TEXT_FILE,
|
|
|
|
"alignment": "",
|
2017-10-19 14:31:55 -07:00
|
|
|
}
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2017-10-19 14:31:55 -07:00
|
|
|
def __init__(self, *items, **kwargs):
|
|
|
|
line_separated_items = [s + "\\\\" for s in items]
|
|
|
|
TextMobject.__init__(self, *line_separated_items, **kwargs)
|
|
|
|
for part in self:
|
|
|
|
dot = TexMobject("\\cdot").scale(self.dot_scale_factor)
|
|
|
|
dot.next_to(part[0], LEFT, SMALL_BUFF)
|
|
|
|
part.add_to_back(dot)
|
|
|
|
self.arrange_submobjects(
|
2018-04-06 13:58:59 -07:00
|
|
|
DOWN,
|
|
|
|
aligned_edge=LEFT,
|
|
|
|
buff=self.buff
|
2017-10-19 14:31:55 -07:00
|
|
|
)
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
def fade_all_but(self, index_or_string, opacity=0.5):
|
2017-10-19 14:31:55 -07:00
|
|
|
arg = index_or_string
|
|
|
|
if isinstance(arg, str):
|
|
|
|
part = self.get_part_by_tex(arg)
|
|
|
|
elif isinstance(arg, int):
|
|
|
|
part = self.submobjects[arg]
|
|
|
|
else:
|
|
|
|
raise Exception("Expected int or string, got {0}".format(arg))
|
|
|
|
for other_part in self.submobjects:
|
|
|
|
if other_part is part:
|
2018-04-06 13:58:59 -07:00
|
|
|
other_part.set_fill(opacity=1)
|
2017-10-19 14:31:55 -07:00
|
|
|
else:
|
2018-04-06 13:58:59 -07:00
|
|
|
other_part.set_fill(opacity=opacity)
|
2017-10-19 14:31:55 -07:00
|
|
|
|
2018-05-02 17:17:34 +02:00
|
|
|
|
|
|
|
class TexMobjectFromPresetString(TexMobject):
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
digest_config(self, kwargs)
|
|
|
|
TexMobject.__init__(self, self.tex, **kwargs)
|
|
|
|
self.set_color(self.color)
|
|
|
|
|
2017-10-19 14:31:55 -07:00
|
|
|
##########
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2016-05-03 23:14:40 -07:00
|
|
|
def tex_hash(expression, template_tex_file):
|
|
|
|
return str(hash(expression + template_tex_file))
|
2015-10-28 17:18:50 -07:00
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2016-04-17 12:59:53 -07:00
|
|
|
def tex_to_svg_file(expression, template_tex_file):
|
2016-05-03 23:14:40 -07:00
|
|
|
image_dir = os.path.join(
|
2017-10-05 21:03:30 -05:00
|
|
|
TEX_IMAGE_DIR,
|
2016-05-03 23:14:40 -07:00
|
|
|
tex_hash(expression, template_tex_file)
|
|
|
|
)
|
2015-10-28 17:18:50 -07:00
|
|
|
if os.path.exists(image_dir):
|
|
|
|
return get_sorted_image_list(image_dir)
|
2016-04-17 00:31:38 -07:00
|
|
|
tex_file = generate_tex_file(expression, template_tex_file)
|
2016-04-17 12:59:53 -07:00
|
|
|
dvi_file = tex_to_dvi(tex_file)
|
|
|
|
return dvi_to_svg(dvi_file)
|
2015-10-28 17:18:50 -07:00
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2016-04-17 00:31:38 -07:00
|
|
|
def generate_tex_file(expression, template_tex_file):
|
2016-05-03 23:14:40 -07:00
|
|
|
result = os.path.join(
|
2017-10-05 21:03:30 -05:00
|
|
|
TEX_DIR,
|
2016-05-03 23:14:40 -07:00
|
|
|
tex_hash(expression, template_tex_file)
|
2016-08-18 12:54:04 -07:00
|
|
|
) + ".tex"
|
2015-10-28 17:18:50 -07:00
|
|
|
if not os.path.exists(result):
|
2018-04-06 13:58:59 -07:00
|
|
|
print("Writing \"%s\" to %s" % (
|
2016-04-17 00:31:38 -07:00
|
|
|
"".join(expression), result
|
2017-10-05 21:03:30 -05:00
|
|
|
))
|
2015-10-28 17:18:50 -07:00
|
|
|
with open(template_tex_file, "r") as infile:
|
|
|
|
body = infile.read()
|
|
|
|
body = body.replace(TEX_TEXT_TO_REPLACE, expression)
|
|
|
|
with open(result, "w") as outfile:
|
|
|
|
outfile.write(body)
|
|
|
|
return result
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2017-09-27 17:29:13 +08:00
|
|
|
def get_null():
|
|
|
|
if os.name == "nt":
|
|
|
|
return "NUL"
|
|
|
|
return "/dev/null"
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
2016-04-17 12:59:53 -07:00
|
|
|
def tex_to_dvi(tex_file):
|
|
|
|
result = tex_file.replace(".tex", ".dvi")
|
|
|
|
if not os.path.exists(result):
|
2015-10-28 17:18:50 -07:00
|
|
|
commands = [
|
2017-10-05 21:03:30 -05:00
|
|
|
"latex",
|
|
|
|
"-interaction=batchmode",
|
2017-05-04 15:40:10 +02:00
|
|
|
"-halt-on-error",
|
2015-10-28 17:18:50 -07:00
|
|
|
"-output-directory=" + TEX_DIR,
|
|
|
|
tex_file,
|
2017-09-27 17:29:13 +08:00
|
|
|
">",
|
|
|
|
get_null()
|
2015-10-28 17:18:50 -07:00
|
|
|
]
|
2017-05-04 15:40:10 +02:00
|
|
|
exit_code = 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()
|
|
|
|
raise Exception(
|
|
|
|
"Latex error converting to dvi. "
|
|
|
|
"See log output above or the log file: %s" % log_file)
|
2015-10-28 17:18:50 -07:00
|
|
|
return result
|
|
|
|
|
2018-04-06 13:58:59 -07:00
|
|
|
|
|
|
|
def dvi_to_svg(dvi_file, regen_if_exists=False):
|
2015-10-28 17:18:50 -07:00
|
|
|
"""
|
2017-10-05 21:03:30 -05:00
|
|
|
Converts a dvi, which potentially has multiple slides, into a
|
2015-10-28 17:18:50 -07:00
|
|
|
directory full of enumerated pngs corresponding with these slides.
|
|
|
|
Returns a list of PIL Image objects for these images sorted as they
|
|
|
|
where in the dvi
|
|
|
|
"""
|
2016-04-17 12:59:53 -07:00
|
|
|
result = dvi_file.replace(".dvi", ".svg")
|
|
|
|
if not os.path.exists(result):
|
2015-10-28 17:18:50 -07:00
|
|
|
commands = [
|
2016-04-17 12:59:53 -07:00
|
|
|
"dvisvgm",
|
|
|
|
dvi_file,
|
|
|
|
"-n",
|
|
|
|
"-v",
|
|
|
|
"0",
|
|
|
|
"-o",
|
2016-04-17 00:31:38 -07:00
|
|
|
result,
|
2017-09-27 17:29:13 +08:00
|
|
|
">",
|
|
|
|
get_null()
|
2015-10-28 17:18:50 -07:00
|
|
|
]
|
|
|
|
os.system(" ".join(commands))
|
2016-04-17 00:31:38 -07:00
|
|
|
return result
|