
    i                    |    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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                6     |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     d/home/piyush/.hermes/hermes-agent/venv/lib/python3.11/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    stater   	startLiner   endLinesilentr   r   c                *   t                               d| |||           d}| j        |         | j        |         z   }| j        |         }|                     |          rdS |z   |k    rdS | j        |         }|vrdS |}|                     ||          }||z
  }	|	k     rdS | j        ||         }
| j        ||         }|v r||v rdS |rdS |}	 |dz  }||k    rn| j        |         | j        |         z   x}}| j        |         }||k     r| j        |         | j	        k     rn	 | j        |         |k    rgn# t          $ r Y n_w xY w|                     |          r|                     ||          } |	||z
            s|                     |          }||k     rd}	 | j        |         }	||rdndz   | _        |                     dd          }||_        |                     |dz   ||	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lengthr9   paramsnextLinetokenclosing_matcherr   r   r   r   s                 r   _fence_rulez$make_fence_rule.<locals>._fence_rule-   s    	,eY	
 	
 	
 l9%Y(??,y)y)) 	5w&&53  5   f--sK53s7#3w;',,,61A1A5  	4 &	MH7"" X.h1GGGC#l8,GW}}h!7%/!I!I 9S>V++ ,    ""8,, $$S&11C"?63955  ""3''CW}} M i(m!:;


:vq11
y1}hMM
+	ts   'D: :
EE)
r"   r   r#   r   r$   r   r%   r   r   r   r   )r   r   r   r   r   rE   rD   s   `` `` @r   make_fence_rulerF      sl    4  VUU VU_ _ _ _ _ _ _ _ _ _B r    )r   r   r   r   r   r   r   r   r   r   r   r   )
__future__r   collections.abcr   loggingstate_blockr   	getLogger__name__r(   rF   r	   r   r    r   <module>rM      s    " " " " " " $ $ $ $ $ $  # # # # # #		8	$	$
  */5B B B B B BL 	r    