
    \j                        d dl mZ d dlmZ d dlZddlmZ  ej                  e      Z	dddd	d
d	 	 	 	 	 	 	 	 	 	 	 ddZ
 e
       Zy)    )annotations)CallableN   )
StateBlock)~`fenceF)r      )markers
token_typeexact_matchdisallow_marker_in_infomin_markersc                J     |rd nd 	 	 	 	 	 	 	 	 	 	 d fd}|S )a  Create a fence parsing rule with configurable options.

    :param markers: Tuple of single characters that can be used as fence markers.
    :param token_type: The token type name to emit (e.g. "fence", "colon_fence").
    :param exact_match: If True, the closing fence must have exactly the same
        number of marker characters as the opening fence (not "at least as many").
        This enables nesting of fences with different marker counts.
    :param disallow_marker_in_info: Tuple of marker characters that are not allowed
        to appear in the info string. The check only applies when the actual opening
        marker is in this tuple (e.g. a tilde fence is unaffected by ``"`"`` being
        listed). Per CommonMark, backtick fences cannot have backticks in the info
        string. Use ``()`` to disable this restriction.
    :param min_markers: Minimum number of marker characters to form a fence.
    :return: A block rule function with signature
        ``(state, startLine, endLine, silent) -> bool``.
    c                    || k(  S N opening_lenclosing_lens     G/root/env/lib/python3.12/site-packages/markdown_it/rules_block/fence.py<lambda>z!make_fence_rule.<locals>.<lambda>(       ;+;U     c                    || k\  S r   r   r   s     r   r   z!make_fence_rule.<locals>.<lambda>+   r   r   c                    t         j                  d| |||       d}| j                  |   | j                  |   z   }| j                  |   }| j                  |      ry|z   |kD  ry| j                  |   }|vry|}| j                  ||      }||z
  }	|	k  ry| j                  || }
| j                  || }|v r||v ry|ry|}	 |dz  }||k\  rn| j                  |   | j                  |   z   x}}| j                  |   }||k  r| j                  |   | j                  k  rn`	 | j                  |   |k7  rr	 | j                  |      r| j                  ||      } |	||z
        s| j                  |      }||k  rd}	 | j                  |   }	||rdndz   | _        | j                  dd      }||_        | j                  |dz   ||	d      |_        |
|_        || j                  g|_        y# t        $ r Y yw xY w)Nzentering fence: %s, %s, %s, %sFTr   r   code)LOGGERdebugbMarkstShifteMarksis_code_blocksrcskipCharsStrsCount	blkIndent
IndexError
skipSpaceslinepushinfogetLinescontentmarkupmap)state	startLineendLinesilenthaveEndMarkerposmaximummarkermemlengthr/   paramsnextLinetokenclosing_matcherr   r   r   r   s                 r   _fence_rulez$make_fence_rule.<locals>._fence_rule-   sV    	,eY	
 ll9%Y(??,,y)y)w&3    f-sK3s#3w',,61A  MH7" X.h1GGGC#ll8,GW}h!7%//!I 99S>V+ ,
 ""8,$$S&1C"6395 ""3'CW} M i(m;


:vq1
y1}hM

+	A  s   $G1 1	G=<G=)
r1   r   r2   intr3   r@   r4   boolreturnrA   r   )r   r   r   r   r   r?   r>   s   `` `` @r   make_fence_rulerC      sW    4 U V__&)_47_AE_	_ _B r   )r   tuple[str, ...]r   strr   rA   r   rD   r   r@   rB   z,Callable[[StateBlock, int, int, bool], bool])
__future__r   collections.abcr   loggingstate_blockr   	getLogger__name__r   rC   r	   r   r   r   <module>rL      s    " $  #			8	$
  */5BB B 	B
 -B B 2BL 	r   