ó
öÀ\c           @   sı   d  Z  d d l m Z d d l Z d d l m Z d d l m Z d d l m	 Z	 e
 r d d l m Z m Z d d l m Z d d	 l m Z n  d
   Z d   Z d   Z d   Z d S(   sô   
    sphinx.ext.jsmath
    ~~~~~~~~~~~~~~~~~

    Set up everything for use of JSMath to display math in HTML
    via JavaScript.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
i˙˙˙˙(   t   nodesN(   t   ExtensionError(   t   _(   t   get_node_equation_number(   t   Anyt   Dict(   t   Sphinx(   t   BuildEnvironmentc         C   sU   |  j  j |  j | d d d d  |  j  j |  j | j    d  t j  d  S(   Nt   spant    t   CLASSs   math notranslate nohighlights   </span>(   t   bodyt   appendt   starttagt   encodet   astextR    t   SkipNode(   t   selft   node(    (    s0   lib/python2.7/site-packages/sphinx/ext/jsmath.pyt   html_visit_math   s    %#c         C   s  | d rg |  j  j |  j | d d d  |  j  j |  j | j     |  j  j d  t j  n  x"t | j   j d   D]\ } } |  j |  } | d k r%| d r t	 |  |  } |  j  j d	 |  |  j
 | t d
   |  j  j d  n  |  j  j |  j | d d d  n |  j  j d  d | k sMd | k rh|  j  j d | d  n |  j  j |  |  j  j d  q Wt j  d  S(   Nt   nowrapt   divR
   s   math notranslate nohighlights   </div>s   

i    t   numbers   <span class="eqno">(%s)s   Permalink to this equations   </span>s   <div class="math">t   &s   \\s   \begin{split}s   \end{split}s   </div>
(   R   R   R   R   R   R    R   t	   enumeratet   splitR   t   add_permalink_refR   (   R   R   t   it   partR   (    (    s0   lib/python2.7/site-packages/sphinx/ext/jsmath.pyt   html_visit_displaymath"   s(    
"(
%c         C   su   |  j  j d k s$ |  j  j d k r( d  S|  j j sC t d   n  | j d  j   rq |  j  j |  j j  n  d  S(   Nt   htmlt   jsmathsE   jsmath_path config value must be set for the jsmath extension to workt   math(	   t   buildert   formatt   math_renderer_namet   configt   jsmath_pathR   t
   get_domaint   has_equationst   add_js_file(   t   appt   env(    (    s0   lib/python2.7/site-packages/sphinx/ext/jsmath.pyt   install_jsmath>   s    $c         C   sW   |  j  d t d  f t d  f  |  j d d t  |  j d t  i t j	 d 6t
 d 6S(   NR   R%   R	   s   env-check-consistencyt   versiont   parallel_read_safe(   t   add_html_math_rendererR   t   NoneR   t   add_config_valuet   Falset   connectR+   t   sphinxt   __display_version__t   True(   R)   (    (    s0   lib/python2.7/site-packages/sphinx/ext/jsmath.pyt   setupK   s    		(   t   __doc__t   docutilsR    R3   t   sphinx.errorsR   t   sphinx.localeR   t   sphinx.util.mathR   R1   t   typingR   R   t   sphinx.applicationR   t   sphinx.environmentR   R   R   R+   R6   (    (    (    s0   lib/python2.7/site-packages/sphinx/ext/jsmath.pyt   <module>   s   			