
    Mh                         d Z ddlZddlZddlmZ ddlmZ ddlmZm	Z	m
Z
 ddlmZ 	 ddlmZ n# e$ r dZY nw xY w G d	 d
e          ZdS )z:Module that pre-processes the notebook for export to HTML.    N)JupyterStyle)Style)TypeUnicodeUnion   )Preprocessor)DEFAULT_STATIC_FILES_PATHc                       e Zd ZdZ edd                              d          Z e ed           ee	          gd	e

                              d          Zd Zd Zd Zd ZdS )CSSHTMLHeaderPreprocessorz
    Preprocessor used to pre-process notebook for HTML output.  Adds IPython notebook
    front-end CSS and Pygments CSS to HTML output.
    z
.highlightzCSS highlight class identifier)helpT)configdefault)klassz!Name of the pygments style to use)r   default_valuec                 >    t          j        | g|R i | d| _        dS )zInitialize the preprocessor.N)r	   __init___default_css_hash)selfpargskwargss      e/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/nbconvert/preprocessors/csshtmlheader.pyr   z"CSSHTMLHeaderPreprocessor.__init__#   s1    d5U555f555!%    c                 P    i |d<   |                      |          |d         d<   ||fS )a  Fetch and add CSS to the resource dictionary

        Fetch CSS from IPython and Pygments to add at the beginning
        of the html files.  Add this css in resources in the
        "inlining.css" key

        Parameters
        ----------
        nb : NotebookNode
            Notebook being converted
        resources : dictionary
            Additional resources used in the conversion process.  Allows
            preprocessors to pass variables into the Jinja engine.
        inliningcss)_generate_header)r   nb	resourcess      r   
preprocessz$CSSHTMLHeaderPreprocessor.preprocess(   s5     !#	*'+'<'<Y'G'G	*e$9}r   c                    ddl m} g } || j                  }|                    | j                  }|                    |           |d         }t          j                            |dd          }t          j        	                    |          rt          rE| j        >|                     t          j                            t          dd                    | _        |                     |          | j        k    rPt          |d	          5 }|                    |                                           ddd           n# 1 swxY w Y   |S )
zb
        Fills self.header with lines of CSS extracted from IPython
        and Pygments.
        r   )HtmlFormatter)style
config_dircustomz
custom.cssNzutf-8)encoding)pygments.formattersr"   r#   get_style_defshighlight_classappendospathjoinisfiler
   r   _hashopenread)	r   r   r"   header	formatterpygments_cssr$   custom_css_filenamefs	            r   r   z*CSSHTMLHeaderPreprocessor._generate_header;   sp   
 	655555!M
333	 //0DEEl###
 |,
 gll:xNN7>>-.. 	,( T-C-K)-GLL!:HlSS* *& zz-..$2HHH-@@@ ,AMM!&&((+++, , , , , , , , , , , , , , ,s   (E  EEc                     t          j                    }t          |d          5 }|                    |                                           ddd           n# 1 swxY w Y   |                                S )zCompute the hash of a file.rbN)hashlibmd5r0   updater1   digest)r   filenamer:   r6   s       r   r/   zCSSHTMLHeaderPreprocessor._hashW   s    kmm(D!! 	!QJJqvvxx   	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!zz||s   (AAAN)__name__
__module____qualname____doc__r   tagr)   r   r   r   r   r#   r   r    r   r/    r   r   r   r      s         
 gl1QRRRVV^bVccOE			TT.../0"   
cc	 
& & &
  &  8    r   r   )rA   r9   r+   jupyterlab_pygmentsr   pygments.styler   	traitletsr   r   r   baser	   notebookr
   ImportErrorr   rC   r   r   <module>rJ      s    @ @
  				 , , , , , ,             * * * * * * * * * *      %2222222 % % % $%G G G G G G G G G Gs   / 99