
    ^h                         S SK r S SKJrJrJr  SSKJrJr  \(       a  SSKJ	r	  SSK
Jr  SSKJr  S	/r\ R                  " S
5      r " S S\5      r " S S	\5      rg)    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                   ~    \ rS rSrSr\S\\   S\4S j5       r\S\\   S\4S j5       r	\S\\   S\4S j5       r
Srg	)
	RSTParser   rst_directivemreturnc                 $    U R                  S5      $ )Ntypegroupr   s    Q/home/james-whalen/.local/lib/python3.13/site-packages/mistune/directives/_rst.py
parse_typeRSTParser.parse_type   s    wwv    c                 $    U R                  S5      $ )Ntitler   r   s    r   parse_titleRSTParser.parse_title   s    wwwr   c                    ^ U R                  S5      nU R                  S5      nUS [        U5      *  n[        U R                  S5      5      S-   mSR                  U4S jUR                  5        5       5      S-   $ )Nr   textr   r	   
c              3   ,   >#    U  H	  oTS  v   M     g 7fN ).0lineleadings     r   	<genexpr>*RSTParser.parse_content.<locals>.<genexpr>&   s     F4EDgh4Es   )r   lenjoin
splitlines)r   full_contentr"   pretextr)   s       @r   parse_contentRSTParser.parse_content    sf    wwqzwwv|#d),aggaj/A%yyFDOO4EFFMMr   r&   N)__name__
__module____qualname____firstlineno__namestaticmethodr   strr   r   r1   __static_attributes__r&   r   r   r   r      s{    DeCj S    uSz  c     Ns N N Nr   r   c            	       ^   ^  \ rS rSrSr\rSrSSS\\	   SSS	\
\   4S
 jrSU 4S jjrSrU =r$ )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                     [         R                  UR                  UR                  5      nU(       d  g U R	                  XU5        UR                  5       $ r%   )_directive_rematchsrccursorparse_methodend)selfr=   r   r>   m2s        r   parse_directiveRSTDirective.parse_directiveG   s=      ELL9%U+vvxr   c                 N   > [         [        U ]  U5        U R                  U5        g r%   )superr   __call__register_block_parser)rF   markdown	__class__s     r   rL   RSTDirective.__call__O   s     lD*84""8,r   r&   )rN   r   r   N)r3   r4   r5   r6   __doc__r   parserdirective_patternr   r9   r   intrH   rL   r:   __classcell__)rO   s   @r   r   r   )   sK    4 F4] uSz , [cdg[h - -r   )retypingr   r   r   _baser   r   block_parserr
   corer   rN   r   __all__compiler@   r   r   r&   r   r   <module>r]      sT    	 1 1 1*!#
 

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