U
    muf                     @   sN   d ddgZ dZdZdd Zdd Zd	d
 Zdd Zdd  Zdd Zdd Z	dS )mathmath_in_quotemath_in_listz7^ {0,3}\$\$[ \t]*\n(?P<math_text>[\s\S]+?)\n\$\$[ \t]*$z"\$(?!\s)(?P<math_text>.+?)(?!\s)\$c                 C   s&   | d}|d|d | d S )N	math_text
block_mathtyperaw   groupZappend_tokenend)blockmstatetext r   8/tmp/pip-unpacked-wheel-8p1ovdot/mistune/plugins/math.pyparse_block_math   s    
r   c                 C   s"   | d}|d|d | S )Nr   inline_mathr   r
   )inliner   r   r   r   r   r   parse_inline_math   s    
r   c                 C   s   d| d S )Nz<div class="math">$$
z

$$</div>
r   rendererr   r   r   r   render_block_math   s    r   c                 C   s   d| d S )Nz<span class="math">\(z	\)</span>r   r   r   r   r   render_inline_math   s    r   c                 C   sZ   | j jdttdd | jjdttdd | jrV| jjdkrV| jdt	 | jdt
 dS )a'  A mistune plugin to support math. The syntax is used
    by many markdown extensions:

    .. code-block:: text

        Block math is surrounded by $$:

        $$
        f(a)=f(b)
        $$

        Inline math is surrounded by `$`, such as $f(a)=f(b)$

    :param md: Markdown instance
    r   listbeforer   linkhtmlN)r   registerBLOCK_MATH_PATTERNr   r   INLINE_MATH_PATTERNr   r   NAMEr   r   Zmdr   r   r   r      s
    c                 C   s   | j j| j jddd dS )z(Enable block math plugin in block quote.r   r   r   N)r   insert_ruleZblock_quote_rulesr$   r   r   r   r   2   s    c                 C   s   | j j| j jddd dS )z!Enable block math plugin in list.r   r   r   N)r   r%   Z
list_rulesr$   r   r   r   r   7   s    N)
__all__r!   r"   r   r   r   r   r   r   r   r   r   r   r   <module>   s   
