B
    öÀ„\  ã               @   s   d Z dd„ Zdd„ ZdS )z¾
    sphinx.util.math
    ~~~~~~~~~~~~~~~~

    Utility functions for math.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
c             C   s~   | j jjrr| j jjrrd}| j jdkr8d| jd |f }n|}|d d }| j j |i ¡ |d¡}d t	t
|ƒ¡}n|d	 }|S )
NZdisplaymathZ
singlehtmlz%s/%séÿÿÿÿZidsé    © Ú.Únumber)ZbuilderZconfigZmath_numfigZnumfigÚnameZdocnamesZ
fignumbersÚgetÚjoinÚmapÚstr)ÚwriterZnodeZfigtypeÚkeyÚidr   r   r   ú/lib/python3.7/site-packages/sphinx/util/math.pyÚget_node_equation_number   s    r   c       
      C   sÚ   dd„ }|d krd}nd| }d}t t||  d¡ƒƒ}g }t|ƒdkrJdS t|ƒdkrˆ|rhd	| }d
}nd| }d}| d|d  ¡ n>|ršd| }d}nd| }d}x|D ]}	| d|	 ¡  ¡ q¬W d|d |¡|f S )Nc             S   s   |   ¡ S )N)Ústrip)Úpartr   r   r   Úis_equation'   s    z%wrap_displaymath.<locals>.is_equationÚ z
\label{%s}Tz

r   é   z\begin{equation}z\end{equation}z\begin{equation*}z\end{equation*}z\begin{split}%s\end{split}
z \begin{align}%s\!\begin{aligned}z\end{aligned}\end{align}z!\begin{align*}%s\!\begin{aligned}z\end{aligned}\end{align*}z%s\\
z%s
%s%s)ÚlistÚfilterÚsplitÚlenÚappendr   r   )
ÚtextZlabelZ	numberingr   ZlabeldefÚpartsZ	equationsZbeginÚendr   r   r   r   Úwrap_displaymath%   s0    
r   N)Ú__doc__r   r   r   r   r   r   Ú<module>
   s   	