B \C5@sBdZddlmmmZddddddd d d d d ddd Zdddddddddddd ZejZej Z e ej e ej e eje eje eje ejdddd DZd!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFg&ZdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`daZdbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddddd4ZddddZGdddZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZ GdddeZ!GdddeZ"GdddeZ#GdddeZ$GdddeZ%GdddeZ&GdddeZ'GdddeZ(GdddeZ)Gdd„deZ*GddĄdeZ+GddƄdeZ,dddɄZ-dd˄Z.ddd̈́Z/dS)z2Convert LaTex math code into presentational MathMLN´¯u˘uˇu˙¨u⃛`^u˚u⃡u˜u⃗) acutebarZbrevecheckdotZddotZdddotZgraveZhatZmathringZoverleftrightarrowtildeZvecuΦuΞuΣuΨuΔuΘuϒuΠuΩuΓuΛ) PhiXiSigmaPsiDeltaThetaUpsilonPiOmegaGammaLambdacCsg|] }t|qS)special).0symbolrrD/tmp/pip-build-uw_ogi45/docutils/docutils/utils/math/latex2mathml.py 8sr)sumintZointprodZarccosZarcsinZarctanargcoscoshZcotZcothZcscdegZdetZdimexpgcdZhominfZkerZlgZlimZliminfZlimsuplnlogmaxminZPrsecsinsinhsuptantanhZinjlimZ varinjlimZ varlimsupZprojlimZ varliminfZ varprojlimu𝔸u𝔹uℂu𝔻u𝔼u𝔽u𝔾uℍu𝕀u𝕁u𝕂u𝕃u𝕄uℕu𝕆uℙuℚuℝu𝕊u𝕋u𝕌u𝕍u𝕎u𝕏u𝕐uℤ)ABCDEFGHIJKLMNOPQRSTUVWXYZu𝒜uℬu𝒞u𝒟uℰuℱu𝒢uℋuℐu𝒥u𝒦uℒuℳu𝒩u𝒪u𝒫u𝒬uℛu𝒮u𝒯u𝒰u𝒱u𝒲u𝒳u𝒴u𝒵u𝒶u𝒷u𝒸u𝒹uℯu𝒻uℊu𝒽u𝒾u𝒿u𝓀u𝓁u𝓂u𝓃uℴu𝓅u𝓆u𝓇u𝓈u𝓉u𝓊u𝓋u𝓌u𝓍u𝓎u𝓏)4r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJrKabcdefghijklmnopqrstuvwxyzu≠u∉u≢)=z\inz\equivc@sfeZdZdZdZdddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)mathzBase class for MathML elements.i@BNcCsPg|_|dk r>t|tkr4x"|D]}||q Wn |||dk rL||_dS)z\math([children]) -> MathML element children can be one child or a list of children.N)childrentypelistappendinline)selfrhrlchildrrr__init__s   z math.__init__cCs8t|dr,|jjdddd|jDS|jjSdS)Nrhz(%s),cSsg|] }t|qSr)repr)rrnrrrrsz!math.__repr__..)hasattr __class____name__joinrh)rmrrr__repr__s z math.__repr__cCst|j|jkS)zRoom for more children?)lenrh nchildren)rmrrrfullsz math.fullcCs:|r t|j|||_|}x|r4|j}q$W|S)zvappend(child) -> element Appends child and returns self if self is not full or first non-full parent.)ryAssertionErrorrhrkparent)rmrnnoderrrrks    z math.appendcCs|jd}|jd=|S)zAdelete_child() -> child Delete last child and return it.)rh)rmrnrrr delete_childs zmath.delete_childcCs|j}x|r|j}qW|S)zKclose() -> parent Close element and return first non-full element.)r{ry)rmr{rrrcloses  z math.closecCs|||S)zxml() -> xml-string) xml_startxml_bodyxml_end)rmrrrxmlszmath.xmlcCs:t|dsd|jjgSd}|jr,d|gSd|gSdS)Nrlz<%s>z"http://www.w3.org/1998/Math/MathMLzz )rr���rs���rt���rl���)rm���xmlnsr���r���r���r������s ����  zmath.xml_startc�������������C���s���d|�j�j�gS�)Nz)rs���rt���)rm���r���r���r���r������s����z math.xml_endc�������������C���s&���g�}x|�j�D�]}||��q W�|S�)N)rh���extendr���)rm���r���rn���r���r���r���r������s���� z math.xml_body)NN)rt��� __module__ __qualname____doc__rx���ro���rv���ry���rk���r~���r���r���r���r���r���r���r���r���r���rg������s���    rg���c���������������@���s���e�Zd�Zdd�ZdS�)mrowc�������������C���s���d|�j�j�gS�)Nz <%s>)rs���rt���)rm���r���r���r���r������s����zmrow.xml_startN)rt���r���r���r���r���r���r���r���r������s���r���c���������������@���s���e�Zd�Zdd�ZdS�)mtablec�������������C���s���d|�j�j�gS�)Nz <%s>)rs���rt���)rm���r���r���r���r������s����zmtable.xml_startN)rt���r���r���r���r���r���r���r���r������s���r���c���������������@���s ���e�Zd�ZdS�)mtrN)rt���r���r���r���r���r���r���r�����s����r���c���������������@���s ���e�Zd�ZdS�)mtdN)rt���r���r���r���r���r���r���r�����s����r���c���������������@���s$���e�Zd�ZdZdZdd�Zdd�ZdS�)mxzBase class for mo, mi, and mnr���c�������������C���s ���||�_�d�S�)N)data)rm���r���r���r���r���ro�����s����z mx.__init__c�������������C���s���|�j�gS�)N)r���)rm���r���r���r���r��� ��s����z mx.xml_bodyN)rt���r���r���r���rx���ro���r���r���r���r���r���r�����s���r���c���������������@���s���e�Zd�ZdddZdd�ZdS�)moz<z>)<>c�������������C���s���|�j�|�j|�jgS�)N) translationgetr���)rm���r���r���r���r�����s����z mo.xml_bodyN)rt���r���r���r���r���r���r���r���r���r�����s��� r���c���������������@���s ���e�Zd�ZdS�)miN)rt���r���r���r���r���r���r���r�����s����r���c���������������@���s ���e�Zd�ZdS�)mnN)rt���r���r���r���r���r���r���r�����s����r���c���������������@���s���e�Zd�ZdZdS�)msub���N)rt���r���r���rx���r���r���r���r���r�����s���r���c���������������@���s���e�Zd�ZdZdS�)msupr���N)rt���r���r���rx���r���r���r���r���r�����s���r���c���������������@���s���e�Zd�ZdZdS�)msqrt���N)rt���r���r���rx���r���r���r���r���r�����s���r���c���������������@���s���e�Zd�ZdZdS�)mrootr���N)rt���r���r���rx���r���r���r���r���r�����s���r���c���������������@���s���e�Zd�ZdZdS�)mfracr���N)rt���r���r���rx���r���r���r���r���r���"��s���r���c���������������@���s"���e�Zd�ZdZdddZdd�ZdS�) msubsup���NFc�������������C���s���||�_�t|�|�d�S�)N)reversedrg���ro���)rm���rh���r���r���r���r���ro���'��s����zmsubsup.__init__c�������������C���s4���|�j�r*|�jd�|�jd�g|�jdd<�d|�_�t|�S�)Nr���r���r���F)r���rh���rg���r���)rm���r���r���r���r���+��s����z msubsup.xml)NF)rt���r���r���rx���ro���r���r���r���r���r���r���%��s��� r���c���������������@���s,���e�Zd�ZddddddZdd�Zd d �Zd S�) mfenced{u���〈}u���〉r���)z\{z\langlez\}z\rangle.c�������������C���s���||�_�t|��d�S�)N)openparrg���ro���)rm���parr���r���r���ro���6��s����zmfenced.__init__c�������������C���s2���|�j�|�j|�j}|�j�|�j|�j}d||f�gS�)Nz)r���r���r���closepar)rm���openr���r���r���r���r���:��s����zmfenced.xml_startN)rt���r���r���r���ro���r���r���r���r���r���r���2��s ���r���c���������������@���s���e�Zd�ZdZdS�)mspacer���N)rt���r���r���rx���r���r���r���r���r���?��s���r���c���������������@���s���e�Zd�ZdddZdd�ZdS�)mstyleNc�������������K���s$���|d�k r||�_�t|�|�||�_d�S�)N)rx���rg���ro���attrs)rm���rh���rx���kwargsr���r���r���ro���C��s���� zmstyle.__init__c�������������C���s$���dgdd�t�|�j�D��dg�S�)Nz.r���)rj���r���items)rm���r���r���r���r���I��s����zmstyle.xml_start)NN)rt���r���r���ro���r���r���r���r���r���r���B��s��� r���c���������������@���s"���e�Zd�ZdZdddZdd�ZdS�) moverr���NFc�������������C���s���||�_�t|�|�d�S�)N)r���rg���ro���)rm���rh���r���r���r���r���ro���O��s����zmover.__init__c�������������C���s ���|�j�r|�j��d|�_�t|�S�)NF)r���rh���reverserg���r���)rm���r���r���r���r���S��s���� z mover.xml)NF)rt���r���r���rx���ro���r���r���r���r���r���r���M��s��� r���c���������������@���s���e�Zd�ZdZdS�)munderr���N)rt���r���r���rx���r���r���r���r���r���Y��s���r���c���������������@���s���e�Zd�ZdZdddZdS�) munderoverr���Nc�������������C���s���t�|�|�d�S�)N)rg���ro���)rm���rh���r���r���r���ro���^��s����zmunderover.__init__)N)rt���r���r���rx���ro���r���r���r���r���r���\��s���r���c���������������@���s ���e�Zd�ZdZdd�Zdd�ZdS�)mtextr���c�������������C���s ���||�_�d�S�)N)text)rm���r���r���r���r���ro���c��s����zmtext.__init__c�������������C���s���|�j�gS�)N)r���)rm���r���r���r���r���f��s����zmtext.xml_bodyN)rt���r���r���rx���ro���r���r���r���r���r���r���a��s���r���Tc�������������C���sN��d�|��}�|r&t�}t|dd}nt�}ttt|dd}xt|�dkrHt|�}|�d�}d}|dkrx|�d�}nd}|dkrn|dkr|d kr|t |}d }n|dkr|t �}d }n|d kr|t �}d }n| �rDd }x$||k�r|�|� �r|d7�}qW�|�d|�} t | ||�|d �\}}||7�}nD|dkrxt�} t| } | � �| �| }d }ntd ||f�n| �r|t|}n|�r|t|}nv|dkr|t |}nZ|dkrH|�} t| trt| jdd} n*t| t r0| jtkr0t| } nt| } || �| }n|dkr|�} t| trrt| j}nTt| t r| jtkrt| }n2t| tr| jd�jtkrt| j}nt| }||�|}nd|dkrt�} || �| }nD|dkr | �}n0|dkr.t�} | �| �| }n td|�|�|d �}�qDW�|S�)zparse_latex_math(string [,inline]) -> MathML-tree Returns a MathML-tree parsed from string. inline=True is for inline math and inline=False is for displayed math. tree is the whole tree and node is the current element. T)rl���Fr���r���r���\z{}r���rp���NzSyntax error: "%s%s"z+-*/=()[]|<>,.!?':;@_)r���r���r���r���&zIllegal character: "%s")ru���splitr���rg���r���r���r���rw���rk���r���r���isalphahandle_keywordr��� SyntaxErrorr���isdigitr���r~��� isinstancer���r���rh���r��� sumintprodr���r���r���r���)stringrl���r|���treerY���rN���skipc2rT���nameentryrowrn���subr/���r���r���r���parse_latex_mathi��s����                              r���c�������������C���s��d}t�|dkr,|d�dkr,|dd��}d}|�dkrr|dsFtd|d7�}t�}tt|}||�|}n|�dkr|dstd |d7�}|���}nL|�d kr|d�d krtd |d }|dkrtd |t |d|�}||d�7�}n|�dkr(t �}||�|}n|�dkrJt �}||�|}n|�dkrx$dD�]} || rZP�qZW�tdt | } || �t �} | | �| }|t�| 7�}nD|�dkrx$dD�]} || rP�qW�td|�}| |_|�}|t�| 7�}n|�dkrXx$tD�]} || rP�qW�td|tt| �}|t�| 7�}n|�dkrtddd} || �| }nt|�dkr|d�d ks|d��r|d�d krtd|tt|d��}|d7�}n|�d kr,|d�d ks|d�d kr td!|tt|d��}|d7�}n|�d"krF|td#}n|�tkrd|tt|��}n|�tkr|tt|��}nr|�tkr|tt|��}nT|�tkr|t|�}n:|�tkrttt|��d$d%}||�|}n td&|��||fS�)'Nr���r���r���beginz{matrix}z;Environment not supported! Supported environment: "matrix".���endzExpected "\end{matrix}"!)r���Zmathrmr���zExpected "\text{...}"!r���r}���sqrtfracleft)([|z\{z\langler���zMissing left-brace!right))]r���z\}z\rangler���zMissing right-brace!notz)Expected something to negate: "\not ..."!ZmathbfZbold)rx���Z fontweightmathbbr���z%Expected something like "\mathbb{A}"!r���)mathscrZmathcalz&Expected something like "\mathscr{A}"!Zcolon:T)r���zUnknown LaTeX command: )rw��� startswithr���r���r���r���rk���r���findr���r���r���r���r���r��� negatablesr���r���isupperr���r���r���Greeklettersr��� functionsoverr���)r���r|���r���r���r���tablerT���r���r���r���Zfencedr���operatorstyleZovrr���r���r���r�����s����                           *           r���c�������������C���s���t�|�|d}d|�S�)zReturn string with MathML code corresponding to `tex_math`. `inline`=True is for inline math and `inline`=False for displayed math. )rl���r���)r���ru���r���)Ztex_mathrl���Z mathml_treer���r���r��� tex2mathml2��s���� r���)T)T)0r���Zdocutils.utils.math.tex2unicharutilsrg���Z tex2unicharr���r���Z mathalphar���Zmathbinr���updateZmathrelZmathordZmathopZmathopenZ mathcloseZ mathfenceru���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r���r������s��               [      ed