ó
öÀ„\c           @   sÅ   d  Z  d d l 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(   sT  
    sphinx.ext.mathjax
    ~~~~~~~~~~~~~~~~~~

    Allow `MathJax <https://www.mathjax.org/>`_ to be used to display math in
    Sphinx's HTML writer -- requires the MathJax JavaScript library on your
    webserver/computer.

    :copyright: Copyright 2007-2019 by the Sphinx team, see AUTHORS.
    :license: BSD, see LICENSE for details.
iÿÿÿÿN(   t   nodes(   t   ExtensionError(   t   _(   t   get_node_equation_number(   t   Anyt   Dict(   t   Sphinx(   t   BuildEnvironmentc         C   sw   |  j  j |  j | d d d d ƒƒ |  j  j |  j j j d |  j | j ƒ  ƒ |  j j j d d ƒ t j	 ‚ d  S(   Nt   spant    t   CLASSs   math notranslate nohighlighti    i   s   </span>(
   t   bodyt   appendt   starttagt   buildert   configt   mathjax_inlinet   encodet   astextR    t   SkipNode(   t   selft   node(    (    s1   lib/python2.7/site-packages/sphinx/ext/mathjax.pyt   html_visit_math   s    %	<c         C   s  |  j  j |  j | d d d ƒƒ | d rg |  j  j |  j | j ƒ  ƒ ƒ |  j  j d ƒ t j ‚ n  | d r½ t |  | ƒ } |  j  j d | ƒ |  j | t	 d ƒ ƒ |  j  j d	 ƒ n  |  j  j |  j
 j j d
 ƒ g  | j ƒ  j d ƒ D] } | j ƒ  rð | ^ qð } t | ƒ d k r3|  j  j d ƒ n  x‰ t | ƒ D]{ \ } } |  j | ƒ } d | k r‚|  j  j d | d ƒ n |  j  j | ƒ | t | ƒ d k  r@|  j  j d ƒ q@q@Wt | ƒ d k rä|  j  j d ƒ n  |  j  j |  j
 j j d ƒ |  j  j d ƒ t j ‚ d  S(   Nt   divR
   s   math notranslate nohighlightt   nowraps   </div>t   numbers   <span class="eqno">(%s)s   Permalink to this equations   </span>i    s   

i   s    \begin{align}\begin{aligned}s   \\s   \begin{split}s   \end{split}s   \end{aligned}\end{align} s   </div>
(   R   R   R   R   R   R    R   R   t   add_permalink_refR   R   R   t   mathjax_displayt   splitt   stript   lent	   enumerate(   R   R   R   t   prtt   partst   it   part(    (    s1   lib/python2.7/site-packages/sphinx/ext/mathjax.pyt   html_visit_displaymath'   s4    "

4c         C   së   |  j  j d k s$ |  j  j d k r( d  S|  j j sC t d ƒ ‚ n  | j d ƒ j ƒ  rç i d d 6} |  j j r‡ | j	 |  j j ƒ n  |  j  j
 |  j j |  |  j j rç d t j |  j j ƒ } |  j  j
 d  d d d	 | ƒqç n  d  S(
   Nt   htmlt   mathjaxsG   mathjax_path config value must be set for the mathjax extension to workt   matht   asyncs   MathJax.Hub.Config(%s)t   types   text/x-mathjax-configR   (   R   t   formatt   math_renderer_nameR   t   mathjax_pathR   t
   get_domaint   has_equationst   mathjax_optionst   updatet   add_js_filet   mathjax_configt   jsont   dumpst   None(   t   appt   envt   optionsR   (    (    s1   lib/python2.7/site-packages/sphinx/ext/mathjax.pyt   install_mathjaxH   s    $c         C   s¯   |  j  d t d  f t d  f ƒ |  j d d d ƒ |  j d i  d ƒ |  j d d d g d ƒ |  j d	 d
 d g d ƒ |  j d d  d ƒ |  j d t ƒ i t j d 6t	 d 6S(   NR&   R,   s[   https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMMLR%   R/   R   s   \(s   \)R   s   \[s   \]R2   s   env-check-consistencyt   versiont   parallel_read_safe(
   t   add_html_math_rendererR   R5   R$   t   add_config_valuet   connectR9   t   sphinxt   __display_version__t   True(   R6   (    (    s1   lib/python2.7/site-packages/sphinx/ext/mathjax.pyt   setup\   s    			(   t   __doc__R3   t   docutilsR    R?   t   sphinx.errorsR   t   sphinx.localeR   t   sphinx.util.mathR   t   Falset   typingR   R   t   sphinx.applicationR   t   sphinx.environmentR   R   R$   R9   RB   (    (    (    s1   lib/python2.7/site-packages/sphinx/ext/mathjax.pyt   <module>   s   			!	