o
    Ni	                     @   s2   d Z G dd deZdd ZdddZdd	 Zd
S )a4  
This is the Docutils (Python Documentation Utilities) "math" sub-package.

It contains various modules for conversion between different math formats
(LaTeX, MathML, HTML).

:math2html:    LaTeX math -> HTML conversion from eLyXer
:latex2mathml: LaTeX math -> presentational MathML
:unichar2tex:  Unicode character to LaTeX math translation table
:tex2unichar:  LaTeX math to Unicode character translation dictionaries
:mathalphabet2unichar:  LaTeX math alphabets to Unicode character translation
:tex2mathml_extern: Wrapper for 3rd party TeX -> MathML converters
c                       s$   e Zd ZdZg f fdd	Z  ZS )	MathErrorzException for math syntax and math conversion errors.

    The additional attribute `details` may hold a list of Docutils
    nodes suitable as children for a ``<system_message>``.
    c                    s   t  | || _d S )N)super__init__details)selfmsgr   	__class__ P/home/ubuntu/.local/lib/python3.10/site-packages/docutils/utils/math/__init__.pyr   $   s   
zMathError.__init__)__name__
__module____qualname____doc__r   __classcell__r	   r	   r   r
   r      s    r   c                 C   s   |  d}ddd |D S )zAReturn string (LaTeX math) `code` with environments stripped out.z\begin{c                 s   s    | ]
}| d d V  qdS )z\end{N)split).0chunkr	   r	   r
   	<genexpr>,   s    z toplevel_code.<locals>.<genexpr>)r   join)codechunksr	   r	   r
   toplevel_code)   s   

r   Fc                 C   s,   t | ddkrd}nd}|s|d7 }|S )a:  Return the right math environment to display `code`.

    The test simply looks for line-breaks (``\``) outside environments.
    Multi-line formulae are set with ``align``, one-liners with
    ``equation``.

    If `numbered` evaluates to ``False``, the "starred" versions are used
    to suppress numbering.
    z\\    alignequation*)r   find)r   numberedenvr	   r	   r
   pick_math_environment0   s   
r    c                 C   s"   |rt | }d|| |f S d|  S )Nz\begin{%s}
%s
\end{%s}z$%s$)r    )r   as_blockr   r	   r	   r
   wrap_math_codeC   s   r"   N)F)r   
ValueErrorr   r   r    r"   r	   r	   r	   r
   <module>   s
   
