
    ^h}                     >    S r SSKrSSKJr  SSKJr   " S S\5      rg)zThis preprocessor detect cells using a different language through
magic extensions such as `%%R` or `%%octave`. Cell's metadata is marked
so that the appropriate highlighter can be used in the `highlight`
filter.
    N)Dict   )Preprocessorc                      ^  \ rS rSrSr\" SSSSSSS	S
SSSS.5      r\" SS9R                  SS9rSU 4S jjr	S r
S rSrU =r$ )HighlightMagicsPreprocessor   zI
Detects and tags code cells that use a different languages than Python.
rbashcython
javascriptjulialatexoctaveperlrubyshsql)z%%Rz%%bashz%%cythonz%%javascriptz%%juliaz%%latexz%%octavez%%perlz%%rubyz%%shz%%sqlzSyntax highlighting for magic's extension languages. Each item associates a language magic extension such as %%R, with a pygments lexer such as r.)helpT)configc                   > [         TU ]  " SSU0UD6  U R                  R                  U R                  5        SR                  U R                  R                  5       5      n[        R                  " SU S35      U l	        g)zPublic constructorr   |z^\s*(z)\s+N )
super__init__default_languagesupdate	languagesjoinkeysrecompilere_magic_language)selfr   kwany_language	__class__s       a/home/james-whalen/.local/lib/python3.13/site-packages/nbconvert/preprocessors/highlightmagics.pyr   $HighlightMagicsPreprocessor.__init__0   sm     	--"- 	%%dnn5 xx 6 6 ; ; =>!#u\N$,G!H    c                     U R                   R                  U5      nU(       a  U R                  UR                  S5         $ g)z
When a cell uses another language through a magic extension,
the other language is returned.
If no language magic is detected, this function returns None.

Parameters
----------
source: str
    Source code of the cell to highlight
r   N)r"   matchr   group)r#   sourcems      r'   which_magic_language0HighlightMagicsPreprocessor.which_magic_language=   s;     ""((0 ))!''!*55r)   c                 z    UR                   S:X  a)  U R                  UR                  5      nU(       a  XAS   S'   X4$ )aW  
Tags cells using a magic extension language

Parameters
----------
cell : NotebookNode cell
    Notebook cell being processed
resources : dictionary
    Additional resources used in the conversion process.  Allows
    preprocessors to pass variables into the Jinja engine.
cell_index : int
    Index of the cell being processed (see base.py)
codemetadatamagics_language)	cell_typer/   r-   )r#   cell	resources
cell_indexmagic_languages        r'   preprocess_cell+HighlightMagicsPreprocessor.preprocess_cellQ   s=      >>V#!66t{{CN6DZ !23r)   )r"   )N)__name__
__module____qualname____firstlineno____doc__r   r   tagr   r   r/   r:   __static_attributes____classcell__)r&   s   @r'   r   r      sr    
  ( 	
" / 
cc I( r)   r   )r@   r    	traitletsr   baser   r   r   r)   r'   <module>rF      s#    
  T, Tr)   