B
    c\                 @   s`   d Z ddlZddlmZmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ G d	d
 d
eZdS )zLaTeX Exporter class    N)Unicodedefault)Config)Highlight2Latex)resolve_references   )TemplateExporterc                   s   e Zd ZdZdZeddd Zeddd Zed	d
d Zeddd Z	e
djddZdZ fddZe fddZd fdd	Z fddZ  ZS )LatexExportera  
    Exports to a Latex template.  Inherit from this class if your template is
    LaTeX based and you need custom tranformers/filters.  Inherit from it if 
    you are writing your own HTML template and need custom tranformers/filters.  
    If you don't need custom tranformers/filters, just change the 
    'template_file' config option.  Place your template in the special "/latex" 
    subfolder of the "../templates" folder.
    latexZfile_extensionc             C   s   dS )Nz.tex )selfr   r   8lib/python3.7/site-packages/nbconvert/exporters/latex.py_file_extension_default   s    z%LatexExporter._file_extension_defaultZtemplate_filec             C   s   dS )Nzarticle.tplxr   )r   r   r   r   _template_file_default   s    z$LatexExporter._template_file_defaultZdefault_template_pathc             C   s   t jdddS )Nz..	templatesr
   )ospathjoin)r   r   r   r   _default_template_path_default#   s    z,LatexExporter._default_template_path_defaultZtemplate_skeleton_pathc             C   s   t jddddS )Nz..r   r
   Zskeleton)r   r   r   )r   r   r   r   _template_skeleton_path_default'   s    z-LatexExporter._template_skeleton_path_defaultz.tplxT)Zconfigz
text/latexc             #   s,   xt t|  D ]
}|V  qW dtfV  d S )Nr   )superr	   default_filtersr   )r   x)	__class__r   r   r   0   s    
zLatexExporter.default_filtersc          	      sR   t ddddddddgid	d
id	d
id	d
id	d
id	d
id}|tt| j |S )NZdisplay_data_priorityz
text/latexzapplication/pdfz	image/pngz
image/jpegzimage/svg+xmlztext/markdownz
text/plainZenabledT)ZNbConvertBaseZExtractOutputPreprocessorZSVG2PDFPreprocessorZLatexPreprocessorZSphinxPreprocessorZHighlightMagicsPreprocessor)r   merger   r	   default_config)r   c)r   r   r   r   5   s    zLatexExporter.default_configNc                sZ   |j di }|d|dd }| jdt|| d}| d| tt| j||f|S )NZlanguage_infopygments_lexernamehighlight_code)r   parent)Zmetadatagetfiltersr   Zregister_filterr   r	   from_notebook_node)r   ZnbZ	resourceskwZlanginfoZlexerr   )r   r   r   r#   N   s
    z LatexExporter.from_notebook_nodec                s6   t t|  }d|_d|_d|_d|_d|_d|_|S )Nz((*z*))z(((z)))z((=z=)))	r   r	   _create_environmentZblock_start_stringZblock_end_stringZvariable_start_stringZvariable_end_stringZcomment_start_stringZcomment_end_string)r   Zenvironment)r   r   r   r%   V   s    z!LatexExporter._create_environment)N)__name__
__module____qualname____doc__Zexport_from_notebookr   r   r   r   r   r   tagZtemplate_extensionZoutput_mimetyper   propertyr   r#   r%   __classcell__r   r   )r   r   r	      s   r	   )r)   r   Z	traitletsr   r   Ztraitlets.configr   Znbconvert.filters.highlightr   Znbconvert.filters.filter_linksr   Ztemplateexporterr   r	   r   r   r   r   <module>   s   