aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/ipython/py2/IPython/lib/latextools.py
diff options
context:
space:
mode:
authorNikita Slyusarev <nslus@yandex-team.com>2022-02-10 16:46:53 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:53 +0300
commit469afdc4e2587bf62ecdd096b75a0baa444c4012 (patch)
tree49e222ea1c5804306084bb3ae065bb702625360f /contrib/python/ipython/py2/IPython/lib/latextools.py
parentcd77cecfc03a3eaf87816af28a33067c4f0cdb59 (diff)
downloadydb-469afdc4e2587bf62ecdd096b75a0baa444c4012.tar.gz
Restoring authorship annotation for Nikita Slyusarev <nslus@yandex-team.com>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/ipython/py2/IPython/lib/latextools.py')
-rw-r--r--contrib/python/ipython/py2/IPython/lib/latextools.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/contrib/python/ipython/py2/IPython/lib/latextools.py b/contrib/python/ipython/py2/IPython/lib/latextools.py
index 5b3c93dc63..c3230dd489 100644
--- a/contrib/python/ipython/py2/IPython/lib/latextools.py
+++ b/contrib/python/ipython/py2/IPython/lib/latextools.py
@@ -39,24 +39,24 @@ class LaTeXTool(SingletonConfigurable):
# for display style, the default ["matplotlib", "dvipng"] can
# be used. To NOT use dvipng so that other repr such as
# unicode pretty printing is used, you can use ["matplotlib"].
- ).tag(config=True)
+ ).tag(config=True)
use_breqn = Bool(
True,
help="Use breqn.sty to automatically break long equations. "
"This configuration takes effect only for dvipng backend.",
- ).tag(config=True)
+ ).tag(config=True)
packages = List(
['amsmath', 'amsthm', 'amssymb', 'bm'],
help="A list of packages to use for dvipng backend. "
"'breqn' will be automatically appended when use_breqn=True.",
- ).tag(config=True)
+ ).tag(config=True)
preamble = Unicode(
help="Additional preamble to use when generating LaTeX source "
"for dvipng backend.",
- ).tag(config=True)
+ ).tag(config=True)
def latex_to_png(s, encode=False, backend=None, wrap=False):
@@ -64,7 +64,7 @@ def latex_to_png(s, encode=False, backend=None, wrap=False):
Parameters
----------
- s : str
+ s : str
The raw string containing valid inline LaTeX.
encode : bool, optional
Should the PNG data base64 encoded to make it JSON'able.
@@ -97,24 +97,24 @@ def latex_to_png(s, encode=False, backend=None, wrap=False):
def latex_to_png_mpl(s, wrap):
try:
from matplotlib import mathtext
- from pyparsing import ParseFatalException
+ from pyparsing import ParseFatalException
except ImportError:
return None
-
+
# mpl mathtext doesn't support display math, force inline
s = s.replace('$$', '$')
if wrap:
s = u'${0}$'.format(s)
- try:
- mt = mathtext.MathTextParser('bitmap')
- f = BytesIO()
- mt.to_png(f, s, fontsize=12)
- return f.getvalue()
- except (ValueError, RuntimeError, ParseFatalException):
- return None
+ try:
+ mt = mathtext.MathTextParser('bitmap')
+ f = BytesIO()
+ mt.to_png(f, s, fontsize=12)
+ return f.getvalue()
+ except (ValueError, RuntimeError, ParseFatalException):
+ return None
+
-
def latex_to_png_dvipng(s, wrap):
try:
find_cmd('latex')
@@ -142,8 +142,8 @@ def latex_to_png_dvipng(s, wrap):
with open(outfile, "rb") as f:
return f.read()
- except subprocess.CalledProcessError:
- return None
+ except subprocess.CalledProcessError:
+ return None
finally:
shutil.rmtree(workdir)