o
    
j                     @  sX   d dl mZ d dlmZ d dlZddlmZ eeZ	dddd	d
ddddZ
e
 ZdS )    )annotations)CallableN   )
StateBlock)~`fenceF)r      )markers
token_typeexact_matchdisallow_marker_in_infomin_markersr
   tuple[str, ...]r   strr   boolr   r   intreturn,Callable[[StateBlock, int, int, bool], bool]c                   s0   |rdd  ndd  d fd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                 S  s   || kS N opening_lenclosing_lenr   r   P/home/kuhnn/.local/lib/python3.10/site-packages/markdown_it/rules_block/fence.py<lambda>(       z!make_fence_rule.<locals>.<lambda>c                 S  s   || kS r   r   r   r   r   r   r   +   r   stater   	startLiner   endLinesilentr   r   c                   s  t d| ||| d}| j| | j|  }| j| }| |r!dS | |kr)dS | j| }|vr4dS |}| ||}|| }	|	k rFdS | j|| }
| j|| }|v r^||v r^dS |rbdS |}	 |d7 }||krnnT| j| | j|   }}| j| }||k r| j| | j	k rn6z| j| |krW qdW n	 t
y   Y n"w | |rqd| ||} |	|| sqd| |}||k rqdd}	 | j| }	||rdnd | _| dd}||_| |d ||	d|_|
|_|| jg|_dS )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)r   r   r   r    haveEndMarkerposmaximummarkermemlengthr3   paramsnextLinetokenclosing_matcherr   r
   r   r   r   r   _fence_rule-   st   







z$make_fence_rule.<locals>._fence_ruleN)
r   r   r   r   r   r   r    r   r   r   r   )r
   r   r   r   r   r@   r   r>   r   make_fence_rule   s
   
arA   )r
   r   r   r   r   r   r   r   r   r   r   r   )
__future__r   collections.abcr   loggingstate_blockr   	getLogger__name__r"   rA   r   r   r   r   r   <module>   s   
 
