
    k7ip$              	         S r SSKJr  SrSSKrSSKJr  SSKJrJ	r	  Sr
/ 4S jrS"S#S	 jjrS"S
 jrS"S jrS"S jr\S:X  a  Sr\" S5        \" S\" \5       S35        \" S\" \R'                  SS5      5       S35        \" S\" \5       S35        \" S\" \5       S35        \" S5        \" S5        \" \" \SS95        \" S5        \" \" \R'                  SS5      SS95        \" S5        \" \" \SS95        \" S5        \" \" \SS95        \" S5        S r \" \" S!\ S!35      5        gg! \ aM  r\" \5        \" \R,                  5        \R,                   H  r\" \R1                  5       5        M      SrCgSrCff = f)$zWrappers for TeX->MathML conversion by external tools

This module is provisional:
the API is not settled and may change with any minor Docutils version.
    )annotationsreStructuredTextN)nodes)	MathErrorwrap_math_codez;\documentclass{article}
\begin{document}
%s
\end{document}
c                ~   SnU(       d3  U R                   (       a"  [        R                  " SU R                   S/S9/nU(       a  SU R                  S    S3nOVU R                  (       a!  SU R                  S    SU R                   S	3nO$U R
                  (       d  SU R                  S    S
3nU(       a	  [        X!S9eg )N pre-wrapclasseszTeX to MathML converter `r   z	` failed:zTeX to MathMl converter `z` exited with Errno .z` returned no MathML.details)stderrr   	paragraphargs
returncodestdoutr   )resultr   msgs      _/home/james-whalen/.local/lib/python3.13/site-packages/docutils/utils/math/tex2mathml_extern.py_check_resultr   #   s     Cv}}??2v}}zlKL)&++a.)9C			*6;;q>*: ;$$*$5$5#6a9]])&++a.)99NO
--     c                   / SQnU(       a  SOSn[        X5      nSU;   a  UR                  SS5      n [        R                  " X SSS9nSUR                  ;   aJ  UR                  UR                  R                  S	5      S
-   UR                  R                  S5       Ul        OIUR                  UR                  R                  S5      S
-   UR                  R                  S5       Ul        [        U5        SU SUR                   S3$ )zZConvert LaTeX math code to MathML with blahtexml__.

__ http://gva.noekeon.org/blahtexml/
)	blahtexml--mathmlz
--indentedz	--spacingmoderatez--mathml-encodingrawz--other-encodingr   z--doctype-xhtml+mathmlz--annotate-TeXz display="block"r	   z{align*}z	{aligned}Tinputcapture_outputtextz<error>z	<message>	   z
</message>z<markup>z	</markup>z0<math xmlns="http://www.w3.org/1998/Math/MathML"z>
</math>)r   replace
subprocessrunr   findr   r   )	math_codeas_blockr   mathml_args_wrappedr   s         r   r   r   4   s    
D )1$bKi2HX$$Z=	^^D+/d<F FMM!fmm&8&8&Ea&G&,mm&8&8&FH fmm&8&8&DQ&F&,mm&8&8&EG&>{m Lw( )r   c                  ^	 / SQn[         [        X5      -  n Sm	[        R                  " X SSS9nUR                  (       a8  SR                  U	4S jUR                  R                  5        5       5      Ul        [        U5        / SQn[        R                  " XCR                  SSS9nUR                  R                  S5      nUS	:w  aC  UR                  R                  S
U5      S-   nUR                  Xg R                  SS5      Ul        OIUR                  UR                  R                  S5      UR                  R                  S5      S-    Ul        UR                  (       a  UR                  nOUR                  nSR                  U	4S jUR                  5        5       5      Ul        [        U5        UR                  $ )zConvert LaTeX math code to MathML with LaTeXML__.

Comprehensive macro support but **very** slow.

__ http://dlmf.nist.gov/LaTeXML/
)latexml-z--preload=amsmathz--preload=amssymbz--inputencoding=utf8--)zError:zWarning:zFatal:Tr   
c              3  X   >#    U  H  nUR                  T5      (       d  M  Uv   M!     g 7fN
startswith.0line
error_tagss     r   	<genexpr>latexml.<locals>.<genexpr>s   s'      #C4OD&*ooj&A $(44O   *	*)latexmlpostr/   z--nonumbersectionsz--format=html5z--omitdoctypez--noscanz--nocrossrefz--nographicimagesz--nopictureimagesz--nodefaultresourcesr0   z<table class="ltx_equationgroupz</table>   ltx_equationgroupzborderless align-center<mathr$      c              3  X   >#    U  H  nUR                  T5      (       d  M  Uv   M!     g 7fr3   r4   r6   s     r   r:   r;      s&      ?0H"&//*"=  $t0Hr<   )document_templater   r&   r'   r   join
splitlinesr   r   r(   r%   )
r)   r*   args1result1args2result2startstop_msg_sourcer9   s
            @r   r.   r.   X   sy   E "N9$GGI1JnnU,0t=G~~ #CGNN4M4M4O #C C'E nnU..,0t=G NN ABE{~~"":u5a7 3;;!:< !(;(;G(D(/(;(;I(Fq(HJ ~~nnnnYY ?0F0F0H ? ?GN'>>r   c                <   / SQn[         R                  " U[        X5      SSS9nUR                  UR                  R	                  S5      UR                  R	                  S5      S-    Ul        / nUR
                  (       a  UR
                  R                  5       nU[        R                  " SUS   5      [        R                  " SS	R                  US
S 5      5      [        R                  " SS	R                  USS 5      S/S9/-  n[        X4S9  UR                  $ )zIConvert LaTeX math code to MathML with pandoc__.

__ https://pandoc.org/
)pandocr   z--from=latexTr   rA   r$   rB   r	   r   r1         Nr
   r   r   )r&   r'   r   r   r(   r   rF   r   r   literal_blockrE   r   )r)   r*   r   r   r   liness         r   rO   rO      s    
D ^^Dy(K+/d<F MM&--"4"4W"="(--"4"4Y"?"ACFM G}}((*EOOBa1''DIIeAaj,ABOOB		%)(<-7L: 	
 &*==r   c                   / SQn[        X5      n  [        R                  " X SSSS9nUR
                  UR
                  R                  S5      UR
                  R                  S5      S-    Ul        U(       a!  UR
                  R                  S	S
5      Ul        SR                  S UR                  R                  5        5       5      Ul	        [        U5        UR
                  $ ! [         a  n[	        U5      eSnAff = f)zoConvert LaTeX math code to MathML with TtM__.

Aged, limited, but fast.

__ http://silas.psfc.mit.edu/tth/mml/
)ttmz-Lz-rTz
ISO-8859-1)r    r!   r"   encodingNrA   r$   rB   z<math xmlns=z<math display="block" xmlns=r1   c              3  b   #    U  H%  nUR                  S 5      (       d  M  USS S-   v   M'     g7f)z****    Nr   r4   )r7   r8   s     r   r:   ttm.<locals>.<genexpr>   s/      ;*D$!%!9 -d12hn*Ds   //)r   r&   r'   UnicodeEncodeErrorr   r   r(   r%   rE   r   rF   r   )r)   r*   r   r   errs        r   rU   rU      s    D y3I/3$)57 MM&--"4"4W"="(--"4"4Y"?"ACFM--n.LNII ;*0--*B*B*D; ;FM &==  ns   C% %
C?/C::C?__main__uR   \frac{\partial \sin^2(\alpha)}{\partial \vec r}\varpi \mathbb{R} \, \text{Grüße}z<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>test external mathml converters</title>
</head>
<body>
<p>Test external converters</p>
<p>
z	latexml: ,zttm: mathbbmathbfzblahtexml: zpandoc: r   z</p>z<p>latexml:</p>T)r*   z<p>ttm:</p>z<p>blahtexml:</p>z<p>pandoc:</p>z</main>
</body>
</html>z
\sinc \phy$)F)returnstr)__doc__
__future__r   __docformat__r&   docutilsr   docutils.utils.mathr   r   rD   r   r   r.   rO   rU   __name__exampleprintr%   buggyr[   r   nodeastext r   r   <module>ro      s   #"   9  #% ."!)H?DBF z6G 
   
Igg&'q
)*	E#gooh9:;1
=>	K	'*+1
-.	HVG_%Q
'(	&M	
	''D
)*	-	#gooh1D
AB	
	)Gd
+,	
	&4
()	
%&E	! 	fqq\"#G J  !c
ckkKKD$++-   !s   D. .F4AE<<F