
    ^h                         S r SSKrSSKrSSKJr  SSKJr  SSKJrJ	r	J
r
  SSKJr   SSKJr   " S	 S
\5      rg! \ a    Sr Nf = f)z:Module that pre-processes the notebook for export to HTML.    N)JupyterStyle)Style)TypeUnicodeUnion   )Preprocessor)DEFAULT_STATIC_FILES_PATHc                       \ rS rSrSr\" SSS9R                  SS9r\" \" S5      \	" \
S	9/S
\S9R                  SS9rS rS rS rS rSrg)CSSHTMLHeaderPreprocessor   z
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                 F    [         R                  " U /UQ70 UD6  SU l        g)zInitialize the preprocessor.N)r	   __init___default_css_hash)selfpargskwargss      _/home/james-whalen/.local/lib/python3.13/site-packages/nbconvert/preprocessors/csshtmlheader.pyr   "CSSHTMLHeaderPreprocessor.__init__#   s"    d5U5f5!%    c                 @    0 US'   U R                  U5      US   S'   X4$ )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   
preprocess$CSSHTMLHeaderPreprocessor.preprocess(   s0     !#	*'+'<'<Y'G	*e$}r   c                    SSK Jn  / nU" U R                  S9nUR                  U R                  5      nUR                  U5        US   n[        R                  R                  USS5      n[        R                  R                  U5      (       a  [        (       aF  U R                  c9  U R                  [        R                  R                  [        SS5      5      U l        U R                  U5      U R                  :w  a4  [        USS	9 nUR                  UR                  5       5        SSS5        U$ U$ ! , (       d  f       U$ = f)
zJ
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   *CSSHTMLHeaderPreprocessor._generate_header;   s   
 	6!

3	 //0D0DEl#
 |,
 ggll:xN77>>-..((T-C-C-K)-GGLL!:HlS*& zz-.$2H2HH-@AMM!&&(+ Av A@s   	 D55
Ec                     [         R                  " 5       n[        US5       nUR                  UR	                  5       5        SSS5        UR                  5       $ ! , (       d  f       UR                  5       $ = f)zCompute the hash of a file.rbN)hashlibmd5r3   updater4   digest)r   filenamer>   r9   s       r   r2   CSSHTMLHeaderPreprocessor._hashW   sQ    kkm(D!QJJqvvx  "zz| "!zz|s    A
A7)r   N)__name__
__module____qualname____firstlineno____doc__r   tagr,   r   r   r   r   r&   r   r"   r   r2   __static_attributes__ r   r   r   r      sl    
 l1QRVV^bVcO		T./0" 
cc	 
&
&8r   r   )rG   r=   r.   jupyterlab_pygmentsr   pygments.styler   	traitletsr   r   r   baser	   notebookr
   ImportErrorr   rJ   r   r   <module>rQ      sL    @
  	 ,   * * %2
G G	  % $%s   : AA