o
    n§¥_  ã                   @   s\   d dl mZ d dlZdZddd„Zddd„Zdd	d
„Zedkr,dZe	eeƒ 
d¡ƒ dS dS )é    )Úprint_functionNzP\documentclass{article}
\usepackage{amsmath}
\begin{document}
%s
\end{document}
c           
      C   s&  t jg d¢t jt jt jdd�}|j t|   d¡¡ |j ¡  |j 	¡ }|j
 	¡  d¡}|r<| d¡dks7|s<| |¡ t jg d¢t jt jt jdd�}|j |¡ |j ¡  |j 	¡  d¡}|j
 	¡  d¡}|rv| d¡dksq|sv| |¡ | d¡| d	¡d
 }}	|||	… }d|v r‘t|ƒ‚|S )zdConvert LaTeX math code to MathML with LaTeXML_

    .. _LaTeXML: http://dlmf.nist.gov/LaTeXML/
    )Úlatexmlú-z--inputencoding=utf8T©ÚstdinÚstdoutÚstderrÚ	close_fdsÚutf8ÚErrorr   )Úlatexmlpostr   z--nonumbersectionsz--format=xhtmlz--ú<mathú</math>é   zclass="ltx_ERROR)Ú
subprocessÚPopenÚPIPEr   ÚwriteÚdocument_templateÚencodeÚcloser   Úreadr   ÚdecodeÚfindÚerrorÚSyntaxError)
Ú	math_codeÚreporterÚpÚlatexml_codeÚlatexml_errÚpost_pÚresultÚ
post_p_errÚstartÚend© r&   úG/usr/lib/python3/dist-packages/docutils/utils/math/tex2mathml_extern.pyr      s:   
ø	



ö

r   c                 C   sÔ   t jg d¢t jt jt jdd�}|j t|   d¡¡ |j ¡  |j 	¡ }|j
 	¡  d¡}| d¡dkrEd dd	„ | ¡ D ƒ¡}td
| ƒ‚|rN| d¡dksP|sU| |¡ | d¡| d¡d }}|||… }|S )zgConvert LaTeX math code to MathML with TtM_

    .. _TtM: http://hutchinson.belmont.ma.us/tth/mml/
    )Úttmz-uz-rTr   r
   z**** Unknownr   Ú
c                 S   s   g | ]	}|  d ¡r|‘qS )z****)Ú
startswith)Ú.0Úliner&   r&   r'   Ú
<listcomp>]   s    
ÿzttm.<locals>.<listcomp>z&
Message from external converter TtM:
ú
**** Errorr   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   ÚjoinÚ
splitlinesr   r   )r   r   r   r"   ÚerrÚmsgr$   r%   r&   r&   r'   r(   J   s$   
ø	


r(   Tc           
      C   s   g d¢}|r	d}nd}|  d¡ tjdg| tjtjtjdd�}|j |  d¡¡ |j ¡  |j 	¡  
d¡}|j 	¡  
d¡}| d	¡d
krWtd|| d¡d | d¡…  ƒ‚|rg| d¡d
ksb|sg| |¡ | d¡d | d¡}}	d||||	… f }|S )zlConvert LaTeX math code to MathML with blahtexml_

    .. _blahtexml: http://gva.noekeon.org/blahtexml/
    )
z--mathmlz
--indentedz	--spacingÚmoderatez--mathml-encodingÚrawz--other-encodingr4   z--doctype-xhtml+mathmlz--annotate-TeXÚ zmode="display"z--displaymathÚ	blahtexmlTr   r
   z<error>r   z,
Message from external converter blahtexml:
z	<message>é	   z
</message>r.   z<markup>z	</markup>z><math xmlns="http://www.w3.org/1998/Math/MathML"%s>
%s</math>
)Úappendr   r   r   r   r   r   r   r   r   r   r   r   r   r   )
r   Úinliner   ÚoptionsÚmathmode_argr   r"   r1   r$   r%   r&   r&   r'   r6   f   s4   
ü
ÿ
ÿr6   Ú__main__uG   \frac{\partial \sin^2(\alpha)}{\partial \vec r}\varpi \, \text{GrÃ¼ÃŸe}r
   )N)TN)Ú
__future__r   r   r   r   r(   r6   Ú__name__ÚexampleÚprintr   r&   r&   r&   r'   Ú<module>   s   

.
)û