File: //lib/python3.6/site-packages/docutils/utils/math/__pycache__/tex2mathml_extern.cpython-36.pyc
3
{2�e � @ sL d dl Z dZd
dd�Zddd�Zddd �Zed
krHdZeee�jd�� dS )� NzP\documentclass{article}
\usepackage{amsmath}
\begin{document}
%s
\end{document}
c
C s4 t jdddgt jt jt jdd�}|jjt| jd�� |jj� |jj � }|j
j � jd�}|rl|jd�dksr| r||j
|� t jd dd
ddgt jt jt jdd�}|jj|� |jj� |jj � jd�}|j
j � jd�}|r�|jd�dks�| r�|j
|� |jd
�|jd�d }} ||| � }d|k�r0t|��|S )zhConvert LaTeX math code to MathML with LaTeXML_
.. _LaTeXML: http://dlmf.nist.gov/LaTeXML/
�latexml�-z--inputencoding=utf8T)�stdin�stdout�stderr� close_fds�utf8�Errorr Zlatexmlpostz--nonumbersectionsz--format=xhtmlz--z<mathz</math>� zclass="ltx_ERROR)�
subprocess�Popen�PIPEr �write�document_template�encode�closer �readr �decode�find�error�SyntaxError)
� math_code�reporter�pZlatexml_codeZlatexml_errZpost_p�resultZ
post_p_err�start�end� r �'/usr/lib/python3.6/tex2mathml_extern.pyr sB
r c C s� t jdddgt jt jt jdd�}|jjt| jd�� |jj� |jj � }|j
j � jd�}|jd�dkr�d j
d
d� |j� D ��}td| ��|r�|jd
�dks�| r�|j|� |jd�|jd�d }}|||� }|S )zkConvert LaTeX math code to MathML with TtM_
.. _TtM: http://hutchinson.belmont.ma.us/tth/mml/
�ttmz-uz-rT)r r r r r z**** Unknownr �
c S s g | ]}|j d �r|�qS )z****)�
startswith)�.0�liner r r �
<listcomp>\ s zttm.<locals>.<listcomp>z&
Message from external converter TtM:
z
**** Errorz<mathz</math>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 I s&