o
    Ni2                  
   @   s   d Z ddlmZ ddlmZ zddlmZ W n0 eyF   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yd Z zed
edZ[ww ejdk rneddd ZG dd deZdS )aj  
A parser for CommonMark Markdown text using `recommonmark`__.

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

.. important:: This module is provisional

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

   * The API is not settled and may change with any minor Docutils version.
    )	Component)nodes)addnodesNc                   @   s   e Zd ZdS )pending_xrefN)__name__
__module____qualname__ r	   r	   Y/home/ubuntu/.local/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                   @   s>   e Zd ZdZdZ	 dZdZdd Zdd Zd	d
 Z	dd Z
d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   J   s   
zParser.get_transformsc              
   C   s  t |dD ]\}}t||jjkr%|jd|d  }||  dS qz	t	| || W n% t
yT } z|jjr=||jd| }|| W Y d}~nd}~ww |tjD ]C}|j}d}|d t|k rt|| tjrt||d  tjrt|| ||d  ||< ||| _n|d7 }|d t|k sjq[|tD ]}d|d vr|d d q|tjD ]}d	|jv r|d |d	  |d	= q|jjs|tjD ]}|jd
}	|j||	 q|tjD ]}|jd }
d|
vrt|
 |
d< |j||
 qdS )z9Use the upstream parser and clean up afterwards.
        
z&Line %d exceeds the line-length-limit.   Nz2Parsing with "recommonmark" returned the error:
%sr   codeclasseslanguagezRaw content disabled.name)	enumeratesplitlensettingsline_length_limitreportererrorappendr   parse	Exception	tracebackfindallr   TextElementchildrenr   Textpopparentr   r   
attributesraw_enabledrawwarningreplacer   r   fully_normalize_nameastext)r   inputstringdocumentiliner'   errr   r.   r5   	referencer	   r	   r
   r)   M   sh   

 	


zParser.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_textN)r   r   r   __doc__	supportedconfig_sectionconfig_section_dependenciesr   r)   r?   rB   r	   r	   r	   r
   r   >   s    <	r   )rC   docutilsr   r   r   r   ImportErrorsystypesInlineElementr   
ModuleTypemodulesSimpleNamespacer   recommonmark.parserr   r=   __version__r   r   r	   r	   r	   r
   <module>   s8   


