B
    c\                 @   sd   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
mZ ddlmZ G d	d
 d
eZdS )zHTML Exporter class    N)defaultUnicode)Config)Highlight2HTML)IPythonRendererMarkdownWithMath   )TemplateExporterc                   s   e Zd ZdZedddjddZeddd	 Zed
dd Z	eddd Z
dZe fddZdd Z fddZdd Zd fdd	Z  ZS )HTMLExportera'  
    Exports a basic HTML document.  This exporter assists with the export of
    HTML.  Inherit from it if you are writing your own HTML template and need
    custom preprocessors/filters.  If you don't need custom preprocessors/
    filters, just change the 'template_file' config option.
       ¶z+The text used as the text for anchor links.)helpT)ZconfigZfile_extensionc             C   s   dS )Nz.html )selfr   r   7lib/python3.7/site-packages/nbconvert/exporters/html.py_file_extension_default   s    z$HTMLExporter._file_extension_defaultZdefault_template_pathc             C   s   t jdddS )Nz..Z	templatesZhtml)ospathjoin)r   r   r   r   _default_template_path_default!   s    z+HTMLExporter._default_template_path_defaultZtemplate_filec             C   s   dS )Nzfull.tplr   )r   r   r   r   _template_file_default%   s    z#HTMLExporter._template_file_defaultz	text/htmlc                sF   t ddddddddd	d
dg
iddiddid}|tt| j |S )NZdisplay_data_priorityz)application/vnd.jupyter.widget-state+jsonz(application/vnd.jupyter.widget-view+jsonzapplication/javascriptz	text/htmlztext/markdownzimage/svg+xmlz
text/latexz	image/pngz
image/jpegz
text/plainZenabledT)ZNbConvertBaseZCSSHTMLHeaderPreprocessorZHighlightMagicsPreprocessor)r   mergesuperr
   default_config)r   c)	__class__r   r   r   +   s    zHTMLExporter.default_configc             C   s   t d| jd}t|d|S )z?Markdown to HTML filter respecting the anchor_link_text settingF)escapeanchor_link_text)renderer)r   r   r   Zrender)r   sourcer   r   r   r   markdown2htmlE   s    
zHTMLExporter.markdown2htmlc             #   s.   xt t|  D ]
}|V  qW d| jfV  d S )Nr   )r   r
   default_filtersr   )r   Zpair)r   r   r   r    K   s    
zHTMLExporter.default_filtersc          	   C   sn   xh|j D ]^}d|krxP|d  D ]@\}}x6| D ]*\}}|d|d| d ||  }q4W q"W qW |S )NZattachmentszattachment:{}zdata:z	;base64, )Zcellsitemsreplaceformat)r   nboutputZcellkeyZ
attachmentZatt_typeZattr   r   r   process_attachmentsP   s    "z HTMLExporter.process_attachmentsNc       	         sr   |j di }|d|dd }| jdt|| d}| d| tt| j||f|\}}| ||}||fS )NZlanguage_infopygments_lexernamehighlight_code)r(   parent)	Zmetadatagetfiltersr   Zregister_filterr   r
   from_notebook_noder'   )	r   r$   Z	resourceskwZlanginfoZlexerr*   r%   Z
att_output)r   r   r   r.   Z   s    zHTMLExporter.from_notebook_node)N)__name__
__module____qualname____doc__r   tagr   r   r   r   r   Zoutput_mimetypepropertyr   r   r    r'   r.   __classcell__r   r   )r   r   r
      s   
r
   )r3   r   Z	traitletsr   r   Ztraitlets.configr   Znbconvert.filters.highlightr   Z"nbconvert.filters.markdown_mistuner   r   Ztemplateexporterr	   r
   r   r   r   r   <module>   s   