ó
¡V]c           @   sf   d  d l  Z  d Z d d „ Z d d „ Z e d d „ Z e d k rb d Z e e ƒ j	 d ƒ GHn  d S(	   iÿÿÿÿNsP   \documentclass{article}
\usepackage{amsmath}
\begin{document}
%s
\end{document}
c   
   
   C   sÉ  t  j d d d g d t  j d t  j d t  j d t ƒ} | j j t |  j d ƒ ƒ | j j ƒ  | j	 j
 ƒ  } | j j
 ƒ  j d ƒ } | r¼ | j d	 ƒ d
 k s¬ | r¼ | j | ƒ n  t  j d d d d d g d t  j d t  j d t  j d t ƒ} | j j | ƒ | j j ƒ  | j	 j
 ƒ  j d ƒ } | j j
 ƒ  j d ƒ } | rz| j d	 ƒ d
 k sj| rz| j | ƒ n  | j d ƒ | j d ƒ d } }	 | | |	 !} d | k rÅt | ƒ ‚ n  | S(   sd   Convert LaTeX math code to MathML with LaTeXML_

    .. _LaTeXML: http://dlmf.nist.gov/LaTeXML/
    t   latexmlt   -s   --inputencoding=utf8t   stdint   stdoutt   stderrt	   close_fdst   utf8t   Errori    t   latexmlposts   --nonumbersectionss   --format=xhtmls   --s   <maths   </math>i   s   class="ltx_ERROR(   t
   subprocesst   Popent   PIPEt   TrueR   t   writet   document_templatet   encodet   closeR   t   readR   t   decodet   findt   errort   SyntaxError(
   t	   math_codet   reportert   pt   latexml_codet   latexml_errt   post_pt   resultt
   post_p_errt   startt   end(    (    sD   lib/python2.7/site-packages/docutils/utils/math/tex2mathml_extern.pyR       sB    						"						"#c   	   
   C   sO  t  j d d d g d t  j d t  j d t  j d t ƒ} | j j t |  j d ƒ ƒ | j j ƒ  | j	 j
 ƒ  } | j j
 ƒ  j d ƒ } | j d	 ƒ d
 k ré d j g  | j ƒ  D] } | j d ƒ r² | ^ q² ƒ } t d | ƒ ‚ n  | r| j d ƒ d
 k s| r| j | ƒ n  | j d ƒ | j d ƒ d } } | | | !} | S(   sg   Convert LaTeX math code to MathML with TtM_

    .. _TtM: http://hutchinson.belmont.ma.us/tth/mml/
    t   ttms   -us   -rR   R   R   R   R   s   **** Unknowni    s   
s   ****s&   
Message from external converter TtM:
s
   **** Errors   <maths   </math>i   (   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   t   joint
   splitlinest
   startswithR   R   (	   R   R   R   R   t   errt   linet   msgR   R   (    (    sD   lib/python2.7/site-packages/docutils/utils/math/tex2mathml_extern.pyR    I   s(    						"#c   
   
   C   sˆ  d d d d d d d d d d	 g
 } | r3 d
 } n d } | j  d ƒ t j d g | d t j d t j d t j d t ƒ} | j j |  j d ƒ ƒ | j j ƒ  | j	 j
 ƒ  j d ƒ } | j j
 ƒ  j d ƒ } | j d ƒ d k rt d | | j d ƒ d | j d ƒ !ƒ ‚ n  | rJ| j d ƒ d k s:| rJ| j | ƒ n  | j d ƒ d | j d ƒ } }	 d | | | |	 !f } | S(   sl   Convert LaTeX math code to MathML with blahtexml_

    .. _blahtexml: http://gva.noekeon.org/blahtexml/
    s   --mathmls
   --indenteds	   --spacingt   moderates   --mathml-encodingt   raws   --other-encodings   --doctype-xhtml+mathmls   --annotate-TeXt    s   mode="display"s   --displaymatht	   blahtexmlR   R   R   R   R   s   <error>i    s,   
Message from external converter blahtexml:
s	   <message>i	   s
   </message>s
   **** Errors   <markup>s	   </markup>s>   <math xmlns="http://www.w3.org/1998/Math/MathML"%s>
%s</math>
(   t   appendR	   R
   R   R   R   R   R   R   R   R   R   R   R   R   R   (
   R   t   inlineR   t   optionst   mathmode_argR   R   R$   R   R   (    (    sD   lib/python2.7/site-packages/docutils/utils/math/tex2mathml_extern.pyR*   e   s:    						*"#t   __main__uH   \frac{\partial \sin^2(\alpha)}{\partial \vec r} \varpi \, \text{GrÃ¼ÃŸe}R   (
   R	   R   t   NoneR    R    R   R*   t   __name__t   exampleR   (    (    (    sD   lib/python2.7/site-packages/docutils/utils/math/tex2mathml_extern.pyt   <module>   s   .)