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