a
    ö£Be—  ã                   @   sL   g d ¢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   úW/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/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   ©Úmdr   r   r   r      s
    r   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    r   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    r   N)
Ú__all__r!   r"   r   r   r   r   r   r   r   r   r   r   r   Ú<module>   s   