Format: application/x-python-code
1 o
2
3 ��h� � @ s� d Z ddlmZmZ ddlZddlZddlZddlZddlm Z ddl
4 Z
5 ddlmZ ddl
6 mZmZ ddlmZ ddlmZ dd lmZmZmZ G d
7 d� de�Z ddefdd�Zddd�Zddd�Zdd� Zdd� ZdZd dd�Z dS )!zTools for handling LaTeX.� )�BytesIO�openN)�encodebytes)�Path)�find_cmd�FindCmdError��
8 get_config)�SingletonConfigurable)�List�Bool�Unicodec @ sr e Zd ZdZdd� Zee� ddgdd�jdd �Ze dd
9 d�jdd �Z
10 eg d�dd�jdd �Zed
11 d�jdd �ZdS )� LaTeXToolz3An object to store configuration of the LaTeX tool.c C s t � S )Nr )�self� r �Lc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/lib/latextools.py�_config_default s zLaTeXTool._config_default�
12 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)
13 �__name__�
14 __module__�__qualname__�__doc__r r r
15 �tag�backendsr � use_breqn�packages�preambler r r r r s4
16 �������
17 �r F�Black� �?�sc
18
19 C s� t | t�sJ �t�� j}|du r|d }||vrdS |dkr!t}nL|dkrft}|�d�ret|�dkr^zd� d�
20 d d
21 � t�|dd� d�D ���}W n# t
22 y] } zt
23 d
24 � |��|�d}~ww t
25 d
26 � |���nt
27 d� |���|| |||�} |r|| r|t| �} | S )al Render a LaTeX string to PNG.
28
29 Parameters
30 ----------
31 s : str
32 The raw string containing valid inline LaTeX.
33 encode : bool, optional
34 Should the PNG data base64 encoded to make it JSON'able.
35 backend : {matplotlib, dvipng}
36 Backend for producing PNG data.
37 wrap : bool
38 If true, Automatically wrap `s` as a LaTeX equation.
39 color : string
40 Foreground color name among dvipsnames, e.g. 'Maroon' or on hex RGB
41 format, e.g. '#AA20FA'.
42 scale : float
43 Scale factor for the resulting PNG.
44 None is returned when the backend cannot be used.
45
46 Nr r r �#� zRGB {}� c S s g | ] }t t|d ���qS )� )�str�int)�.0�xr r r �
47 <listcomp>a s z latex_to_png.<locals>.<listcomp>� � zInvalid color specification {}.zNo such backend {0})�
48 isinstancer'