Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/IPython/lib/__pycache__/latextools.cpython-39.pyc
Ðазад
a o�h� � @ s� d Z ddlmZmZ ddlZddlZddlZddlZddlm Z ddl Z ddlmZ ddl mZmZ ddlmZ ddlmZ dd lmZmZmZ dd lmZ G dd� de�Zddd�Zddd�Zd dd�Zdd� Zdd� ZdZ d!dd�Z!dS )"zTools for handling LaTeX.� )�BytesIO�openN)�encodebytes)�Path)�find_cmd�FindCmdError�� get_config)�SingletonConfigurable)�List�Bool�Unicode)�cast_unicodec @ sr e Zd ZdZdd� Zee� ddgdd�jdd �Ze dd d�jdd �Z eg d�dd�jdd �Zed d�jdd �ZdS )� LaTeXToolz3An object to store configuration of the LaTeX tool.c C s t � S )Nr )�self� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/IPython/lib/latextools.py�_config_default s zLaTeXTool._config_default� matplotlib�dvipnga Preferred backend to draw LaTeX math equations. Backends in the list are checked one by one and the first usable one is used. Note that `matplotlib` backend is usable only for inline style equations. To draw display style equations, `dvipng` backend must be specified. )�helpT)�configzmUse breqn.sty to automatically break long equations. This configuration takes effect only for dvipng backend.)ZamsmathZamsthmZamssymbZbmziA list of packages to use for dvipng backend. 'breqn' will be automatically appended when use_breqn=True.zKAdditional preamble to use when generating LaTeX source for dvipng backend.N) �__name__� __module__�__qualname__�__doc__r r r �tag�backendsr � use_breqn�packages�preambler r r r r s2 ��������r F�Black� �?c C s t | �} t�� j}|du r"|d }||vr.dS |dkr<t}n�|dkr�t}|�d�r�t|�dkr�z.d�d� d d � t �|dd� d�D ���}W q� ty� } ztd �|��|�W Y d}~q�d}~0 0 q�td �|���ntd�|���|| |||�} |�r| �rt | �} | S )al Render a LaTeX string to PNG. Parameters ---------- s : str The raw string containing valid inline LaTeX. encode : bool, optional Should the PNG data base64 encoded to make it JSON'able. backend : {matplotlib, dvipng} Backend for producing PNG data. wrap : bool If true, Automatically wrap `s` as a LaTeX equation. color : string Foreground color name among dvipsnames, e.g. 'Maroon' or on hex RGB format, e.g. '#AA20FA'. scale : float Scale factor for the resulting PNG. None is returned when the backend cannot be used. Nr r r �#� zRGB {}� c S s g | ]}t t|d ���qS )� )�str�int)�.0�xr r r � <listcomp>a � z latex_to_png.<locals>.<listcomp>� � zInvalid color specification {}.zNo such backend {0})r r �instancer �latex_to_png_mpl�latex_to_png_dvipng� startswith�len�format�join�textwrap�wrap� ValueErrorr ) �s�encode�backendr7 �color�scaleZallowed_backends�f�eZbin_datar r r �latex_to_png= s0 �(r@ c C s z0ddl m}m}m} ddlm} ddlm} W n tyD Y d S 0 | � dd�} |r`d� | �} z�|jdd �} d | } t� }|� d�}|j| d| d �\} }}}}|j| d |d fd�}|jd|| | | |d� |�|� |j|| ddd� |�� W S tt|f�y Y d S 0 d S )Nr )�figure�font_manager�mathtext)�backend_agg)�ParseFatalExceptionz$$�$z${0}$� )�size�x �path�H )�dpi�prop)Zfigsize)Zfontpropertiesr<