
    Mh                         d Z ddlZddlZddlZddlZddlmZmZ ddlm	Z	 ddl
mZ dZdZdd
Zd Zd Zde_         G d de          Zd ZdadS )zUtility for calling pandoc    N)BytesIOTextIOWrapper)check_version   )ConversionExceptionz2.9.2z4.0.0utf-8c                    dd|d|g}|r|                     |           t                       t          j        |t          j        t          j                  }|                    |                                           \  }}t          t          |          |d          	                                }	|	
                    d          S )aL  Convert an input string using pandoc.

    Pandoc converts an input string `from` a format `to` a target format.

    Parameters
    ----------
    source : string
        Input string, assumed to be valid format `from`.
    fmt : string
        The name of the input format (markdown, etc.)
    to : string
        The name of the output format (html, etc.)

    Returns
    -------
    out : unicode
        Output as returned by pandoc.

    Raises
    ------
    PandocMissing
        If pandoc is not installed.
    Any error messages generated by pandoc are printed to stderr.

    pandocz-fz-t)stdinstdoutreplace
)extendcheck_pandoc_version
subprocessPopenPIPEcommunicateencoder   r   readrstrip)
sourcefmtto
extra_argsencodingcmdpout_out_strs
             V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/nbconvert/utils/pandoc.pyr
   r
      s    4 T3b
)C 

:  	JOJOLLLA]]6==??++FCGCLL(I>>CCEEG>>$    c                  r   t           t          j        d          st                      t	          j        ddg          } |                                 }t          j        d          }|d         	                    dd          
                                D ]}|                    |          r|a  nt           S )ar  Gets the Pandoc version if Pandoc is installed.

    If the minimal version is not met, it will probe Pandoc for its version, cache it and return that value.
    If the minimal version is met, it will return the cached version and stop probing Pandoc
    (unless `clean_cache()` is called).

    Raises
    ------
    PandocMissing
        If pandoc is unavailable.
    Nr
   z-vz^\d+(\.\d+){1,}$r   asciir   )	__versionshutilwhichPandocMissingr   check_output
splitlinesrecompiledecodesplitmatch)r   	out_linesversion_patterntoks       r"   get_pandoc_versionr4   ;   s     |H%% 	"//!%x&677NN$$	*%899Q<&&w	::@@BB 	 	C$$S)) 	 r#   c                  V   t           j        t           j        S t                      } | t          j        dt
          d           dS t          | t          t                    }|t           _        |s8t          j        d| z  dt          z  z   d	t          z  z   d
z   t
          d           |S )zReturns True if pandoc's version meets at least minimal version.

    Raises
    ------
    PandocMissing
        If pandoc is unavailable.
    NzSorry, we cannot determine the version of pandoc.
Please consider reporting this issue and include theoutput of pandoc --version.
Continuing...   )
stacklevelF)max_vz5You are using an unsupported version of pandoc (%s).
z#Your version must be at least (%s) zbut less than (%s).
zFRefer to https://pandoc.org/installing.html.
Continuing with doubts...)	r   _cachedr4   warningswarnRuntimeWarningr   _minimal_version_maximal_version)voks     r"   r   r   W   s     #/#++Ay9 	
 	
 	
 	
 u	q*2B	C	C	CB#%  
DqH36FFG%(889 XX 	
 	
 	
 	
 Ir#   c                   "     e Zd ZdZ fdZ xZS )r)   z(Exception raised when Pandoc is missing.c                 J    t                                          d           dS )zInitialize the exception.z^Pandoc wasn't found.
Please check that pandoc is installed:
https://pandoc.org/installing.htmlN)super__init__)selfargskwargs	__class__s      r"   rD   zPandocMissing.__init__   s.    1	
 	
 	
 	
 	
r#   )__name__
__module____qualname____doc__rD   __classcell__)rH   s   @r"   r)   r)      s>        22
 
 
 
 
 
 
 
 
r#   r)   c                  
    da dS )zClean the internal cache.N)r&    r#   r"   clean_cacherP      s     IIIr#   )Nr   )rL   r,   r'   r   r:   ior   r   nbconvert.utils.versionr   
exceptionsr   r=   r>   r
   r4   r   r9   r)   rP   r&   rO   r#   r"   <module>rT      s        
			       % % % % % % % % 1 1 1 1 1 1 + + + + + +  %  %  %  % P  8     F  $  	
 	
 	
 	
 	
' 	
 	
 	
   			r#   