##// END OF EJS Templates
hook up latex tools config to global instance...
Min RK -
Show More
@@ -54,7 +54,6 b' from IPython.core.prefilter import PrefilterManager'
54 54 from IPython.core.profiledir import ProfileDir
55 55 from IPython.core.prompts import PromptManager
56 56 from IPython.core.usage import default_banner
57 from IPython.lib.latextools import LaTeXTool
58 57 from IPython.testing.skipdoctest import skip_doctest
59 58 from IPython.utils import PyColorize
60 59 from IPython.utils import io
@@ -521,7 +520,6 b' class InteractiveShell(SingletonConfigurable):'
521 520 self.init_display_pub()
522 521 self.init_data_pub()
523 522 self.init_displayhook()
524 self.init_latextool()
525 523 self.init_magics()
526 524 self.init_alias()
527 525 self.init_logstart()
@@ -715,12 +713,6 b' class InteractiveShell(SingletonConfigurable):'
715 713 # the appropriate time.
716 714 self.display_trap = DisplayTrap(hook=self.displayhook)
717 715
718 def init_latextool(self):
719 """Configure LaTeXTool."""
720 cfg = LaTeXTool.instance(parent=self)
721 if cfg not in self.configurables:
722 self.configurables.append(cfg)
723
724 716 def init_virtualenv(self):
725 717 """Add a virtualenv to sys.path so the user can import modules from it.
726 718 This isn't perfect: it doesn't use the Python interpreter with which the
@@ -12,7 +12,7 b' import shutil'
12 12 import subprocess
13 13
14 14 from IPython.utils.process import find_cmd, FindCmdError
15 from IPython.config.application import Application
15 from IPython.config import get_config
16 16 from IPython.config.configurable import SingletonConfigurable
17 17 from IPython.utils.traitlets import List, Bool, Unicode
18 18 from IPython.utils.py3compat import cast_unicode, cast_unicode_py2 as u
@@ -20,7 +20,9 b' from IPython.utils.py3compat import cast_unicode, cast_unicode_py2 as u'
20 20
21 21 class LaTeXTool(SingletonConfigurable):
22 22 """An object to store configuration of the LaTeX tool."""
23
23 def _config_default(self):
24 return get_config()
25
24 26 backends = List(
25 27 Unicode, ["matplotlib", "dvipng"],
26 28 help="Preferred backend to draw LaTeX math equations. "
@@ -93,11 +95,12 b' def latex_to_png_mpl(s, wrap):'
93 95 from matplotlib import mathtext
94 96 except ImportError:
95 97 return None
96
98
97 99 # mpl mathtext doesn't support display math, force inline
98 100 s = s.replace('$$', '$')
99 101 if wrap:
100 102 s = u'${0}$'.format(s)
103
101 104 mt = mathtext.MathTextParser('bitmap')
102 105 f = BytesIO()
103 106 mt.to_png(f, s, fontsize=12)
General Comments 0
You need to be logged in to leave comments. Login now