
    Ph                         d dl Z d dlmZmZmZ ddlmZmZ erddlm	Z	 ddl
mZ ddlmZ d	gZ e j                  d
      Z G d de      Z G d d	e      Zy)    N)TYPE_CHECKINGMatchOptional   )BaseDirectiveDirectiveParser   )BlockParser)
BlockState)MarkdownRSTDirectivez\.\.( +)(?P<type>[a-zA-Z0-9_-]+)\:\: *(?P<title>[^\n]*)(?:\n|$)(?P<options>(?:  \1 {0,3}\:[a-zA-Z0-9_-]+\: *[^\n]*\n+)*)\n*(?P<text>(?:  \1 {0,3}[^\n]*\n+)*)c                   p    e Zd ZdZedee   defd       Zedee   defd       Zedee   defd       Z	y)	RSTParserrst_directivemreturnc                 $    | j                  d      S )Ntypegroupr   s    Q/var/www/html/saasai/venv/lib/python3.12/site-packages/mistune/directives/_rst.py
parse_typezRSTParser.parse_type   s    wwv    c                 $    | j                  d      S )Ntitler   r   s    r   parse_titlezRSTParser.parse_title   s    wwwr   c                     | j                  d      }| j                  d      }|d t        |        }t        | j                  d            dz   dj                  fd|j                         D              dz   S )Nr   textr   r	   
c              3   (   K   | ]	  }|d    y wN ).0lineleadings     r   	<genexpr>z*RSTParser.parse_content.<locals>.<genexpr>&   s     F4EDgh4Es   )r   lenjoin
splitlines)r   full_contentr   pretextr&   s       @r   parse_contentzRSTParser.parse_content    sf    wwqzwwv|#d),aggaj/A%yyFDOO4EFFMMr   N)
__name__
__module____qualname__namestaticmethodr   strr   r   r-   r#   r   r   r   r      s{    DeCj S    uSz  c     Ns N N Nr   r   c            	       P     e Zd ZdZeZdZdddee   ddde	e
   fd	Zd fd
Z xZS )r   a  A RST style of directive syntax is inspired by reStructuredText.
    The syntax is very powerful that you can define a lot of custom
    features on your own. The syntax looks like:

    .. code-block:: text

        .. directive-type:: directive value
           :option-key: option value
           :option-key: option value

           content text here

    To use ``RSTDirective``, developers can add it into plugin list in
    the :class:`Markdown` instance:

    .. code-block:: python

        import mistune
        from mistune.directives import RSTDirective, Admonition

        md = mistune.create_markdown(plugins=[
            # ...
            RSTDirective([Admonition()]),
        ])
    z^\.\. +[a-zA-Z0-9_-]+\:\:blockr
   r   stater   r   c                     t         j                  |j                  |j                        }|sy | j	                  |||       |j                         S r"   )_directive_rematchsrccursorparse_methodend)selfr5   r   r6   m2s        r   parse_directivezRSTDirective.parse_directiveG   s?      ELL9%U+vvxr   c                 N    t         t        |   |       | j                  |       y r"   )superr   __call__register_block_parser)r>   markdown	__class__s     r   rC   zRSTDirective.__call__O   s     lD*84""8,r   )rE   r   r   N)r.   r/   r0   __doc__r   parserdirective_patternr   r3   r   intr@   rC   __classcell__)rF   s   @r   r   r   )   sK    4 F4] uSz , [cdg[h - -r   )retypingr   r   r   _baser   r   block_parserr
   corer   rE   r   __all__compiler8   r   r   r#   r   r   <module>rS      sV    	 1 1 1*!#
 

-N N((-= (-r   