o
    i                  
   @  s  d Z ddlmZ dZddlmZ ddlmZ zddlmZ W n0 e	yN   ddl
Z
ddlZG dd	 d	ejejZed
 e
jd
< Ze  e_Zee_Y nw zddlZddlmZ W n e	yl Z ze	dedZ[ww ejdk rve	ddd ZG dd deZdS )u^  
A parser for CommonMark Markdown text using `recommonmark`__.

__ https://pypi.org/project/recommonmark/

.. important:: This module is deprecated.

   * The "recommonmark" package is unmaintained and deprecated.
     This wrapper module will be removed in Docutils 1.0.

   * The API is not settled and may change with any minor Docutils version.
    )annotationsreStructuredText)	Component)nodes)addnodesNc                   @  s   e Zd ZdS )pending_xrefN)__name__
__module____qualname__ r   r   k/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/docutils/parsers/recommonmark_wrapper.pyr   *   s    r   sphinx)CommonMarkParserzeParsing "recommonmark" Markdown flavour requires the
  package https://pypi.org/project/recommonmark.z0.6.0z^The installed version of "recommonmark" is too old. Update with "pip install -U recommonmark".c                 C  s   t | tjtjfS N)
isinstancer   literalliteral_block)noder   r   r   
is_literal?   s   r   c                      sT   e Zd ZdZdZ	 dZdZdd Zdd Zd fddZ	dddZ
dddZ  ZS )ParserzMarkDown parser based on recommonmark.

    This parser is provisional:
    the API is not settled and may change with any minor Docutils version.
    )recommonmark
commonmarkmarkdownmdzrecommonmark parser)parsersc                 C  s
   t | S r   )r   get_transforms)selfr   r   r   r   O   s   
zParser.get_transformsc              
   C  s   t |dD ]\}}t||jjkr%|jd|d  }||  dS qz
t	| || W dS  t
yV } z|jjr>||jd| }|| W Y d}~dS d}~ww )zpWrapper of upstream method.

        Ensure "line-length-limt". Report errors with `document.reporter`.
        
z&Line %d exceeds the line-length-limit.   Nz2Parsing with "recommonmark" returned the error:
%s)	enumeratesplitlensettingsline_length_limitreportererrorappendr   parse	Exception	traceback)r   inputstringdocumentiliner%   errr   r   r   r'   R   s&   

zParser.parsereturnNonec           
        s  | j }|tjD ]C}|j}d}|d t|k rLt|| tjr@t||d  tjr@t|| ||d  ||< ||| _	n|d7 }|d t|k sq	|tjD ]}t|s_|j	
| qS|tD ]}d|d vrt|d d qe|tjD ]}d|jv r|d |d  |d= q{|jjs|tjD ]<}|jd}t|j	tjr||}tjd| |d}|j	|| ||}|| || q|j	|| q|tjD ]}|jd }	d	|	vrt|	 |	d	< |j	||	 qt   d
S )z7Finalize parse details.  Call at end of `self.parse()`.r   r   codeclasseslanguagezRaw content disabled. )refidnameN)r+   findallr   TextElementchildrenr!   r   Textpopparentremover   r&   r   
attributesr"   raw_enabledrawr$   warningset_idproblematicastextreplaceadd_backrefr   r   fully_normalize_namesuperfinish_parse)
r   r+   r   r9   r,   messagemsgidrC   prbid	reference	__class__r   r   rI   l   s^    	




zParser.finish_parsec                 C  s   dS )zyDummy function to prevent spurious warnings.

        cf. https://github.com/readthedocs/recommonmark/issues/177
        Nr   )r   r   r   r   r   visit_document   s    zParser.visit_documentc                 C  s   | j t|j d S r   )current_noder&   r   r:   r   )r   mdnoder   r   r   
visit_text   s   zParser.visit_text)r/   r0   )r   r	   r
   __doc__	supportedconfig_sectionconfig_section_dependenciesr   r'   rI   rP   rS   __classcell__r   r   rN   r   r   C   s    
9r   )rT   
__future__r   __docformat__docutilsr   r   r   r   ImportErrorsystypesInlineElementr   
ModuleTypemodulesSimpleNamespacer   recommonmark.parserr   r.   __version__r   r   r   r   r   r   <module>   s<   

