o !5p`4D@sdZddlmmmZddddddd d d d d ddd Zdddddddddddd ZejZej Z e ej e ej e eje eje eje ejdddd DZgd!Zid"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdM Zid"dNd$dOd&dPd(dQd*dRd,dSd.dTd0dUd2dVd4dWd6dXd8dYd:dZdd\d@d]dBd^id_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddiddddddddddddddddddddddddddddddddddddiZddddZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZ GdddeZ!GdddeZ"GdddeZ#Gdd„deZ$GddĄdeZ%GddƄdeZ&GddȄdeZ'GddʄdeZ(Gdd̄deZ)Gdd΄deZ*GddЄdeZ+Gdd҄deZ,GddԄdeZ-dddׄZ.ddلZ/dddۄZ0dS)z2Convert LaTex math code into presentational MathMLN´¯u˘uˇu˙¨u⃛`^u˚u⃡u˜u⃗) acutebarbrevecheckdotddotdddotgravehatmathringoverleftrightarrowtildevecuΦuΞuΣuΨuΔuΘuϒuΠuΩuΓuΛ) PhiXiSigmaPsiDeltaThetaUpsilonPiOmegaGammaLambdacCsg|]}t|qS)special).0symbolr r B/usr/lib/python3/dist-packages/docutils/utils/math/latex2mathml.py 8r%)sumintointprod)&arccosarcsinarctanargcoscoshcotcothcscdegdetdimexpgcdhominfkerlglimliminflimsuplnlogmaxminPrsecsinsinhsuptantanhinjlim varinjlim varlimsupprojlim varliminf varprojlimAu𝔸Bu𝔹CuℂDu𝔻Eu𝔼Fu𝔽Gu𝔾HuℍIu𝕀Ju𝕁Ku𝕂Lu𝕃Mu𝕄NuℕOu𝕆PuℙQuℚuℝu𝕊u𝕋u𝕌u𝕍u𝕎u𝕏u𝕐uℤ) RSTUVWXYZu𝒜uℬu𝒞u𝒟uℰuℱu𝒢uℋuℐu𝒥u𝒦uℒuℳu𝒩u𝒪u𝒫u𝒬rbuℛrcu𝒮rdu𝒯reu𝒰rfu𝒱rgu𝒲rhu𝒳riu𝒴rju𝒵au𝒶bu𝒷cu𝒸du𝒹euℯfu𝒻guℊhu𝒽iu𝒾ju𝒿ku𝓀lu𝓁mu𝓂nu𝓃ouℴpu𝓅qu𝓆ru𝓇su𝓈tu𝓉uu𝓊vu𝓋wu𝓌xu𝓍yu𝓎zu𝓏u≠u∉u≢)=z\inz\equivc@sheZdZdZdZ dddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)mathzBase class for MathML elements.i@BNcCsNg|_|durt|tr|D]}||qn|||dur%||_dSdS)z\math([children]) -> MathML element children can be one child or a list of children.N)children isinstancelistappendinline)selfrrchildr r r$__init__s    z math.__init__cCs4t|dr|jjdddd|jDS|jjS)Nrz(%s),cSsg|]}t|qSr )repr)r"rr r r$r%r&z!math.__repr__..)hasattr __class____name__joinrrr r r$__repr__s z math.__repr__cCst|j|jkS)zRoom for more children?)lenr nchildrenrr r r$fullsz math.fullcCs<|rJ|j|||_|}|r|j}|s|S)zvappend(child) -> element Appends child and returns self if self is not full or first non-full parent.)rrrparent)rrnoder r r$rs  z math.appendcCs|jd}|jd=|S)zAdelete_child() -> child Delete last child and return it.)r)rrr r r$ delete_childs zmath.delete_childcCs |j}|r|j}|s|S)zKclose() -> parent Close element and return first non-full element.)rr)rrr r r$closes z math.closecCs|||S)zxml() -> xml-string) xml_startxml_bodyxml_endrr r r$xmlszmath.xmlcCs6t|ds d|jjgSd}|jrd|gSd|gS)Nrz<%s>z"http://www.w3.org/1998/Math/MathMLzz )r���r���r���r���)r���xmlnsr ���r ���r$���r������s ���   zmath.xml_startc�����������������C������d|�j�j�gS�)Nzr���r���r���r ���r ���r$���r���������z math.xml_endc�����������������C���s"���g�}|�j�D�] }||��q|S�N)r���extendr���)r���r���r���r ���r ���r$���r������s��� z math.xml_bodyNN)r��� __module__ __qualname____doc__r���r���r���r���r���r���r���r���r���r���r���r ���r ���r ���r$���r������s����    r���c�������������������@������e�Zd�Zdd�ZdS�)mrowc�����������������C���r���Nz <%s>r���r���r ���r ���r$���r������r���zmrow.xml_startNr���r���r���r���r ���r ���r ���r$���r���������� r���c�������������������@���r���)mtablec�����������������C���r���r���r���r���r ���r ���r$���r������r���zmtable.xml_startNr���r ���r ���r ���r$���r������r���r���c�������������������@��� ���e�Zd�ZdS�)mtrNr���r���r���r ���r ���r ���r$���r�������� �r���c�������������������@���r���)mtdNr���r ���r ���r ���r$���r�����r���r���c�������������������@���s$���e�Zd�ZdZdZdd�Zdd�ZdS�)mxzBase class for mo, mi, and mnr���c�����������������C��� ���||�_�d�S�r���data)r���r���r ���r ���r$���r�������� z mx.__init__c�����������������C������|�j�gS�r���r���r���r ���r ���r$���r��� �����z mx.xml_bodyN)r���r���r���r���r���r���r���r ���r ���r ���r$���r�����s ���� r���c�������������������@���s���e�Zd�ZdddZdd�ZdS�)moz<z>)<>c�����������������C���s���|�j�|�j|�jgS�r���) translationgetr���r���r ���r ���r$���r�����s���z mo.xml_bodyN)r���r���r���r���r���r ���r ���r ���r$���r�����s����  r���c�������������������@���r���)miNr���r ���r ���r ���r$���r�����r���r���c�������������������@���r���)mnNr���r ���r ���r ���r$���r�����r���r���c�������������������@������e�Zd�ZdZdS�)msub���Nr���r���r���r���r ���r ���r ���r$���r���������r���c�������������������@���r���)msupr���Nr���r ���r ���r ���r$���r�����r���r���c�������������������@���r���)msqrt���Nr���r ���r ���r ���r$���r�����r���r���c�������������������@���r���)mrootr���Nr���r ���r ���r ���r$���r�����r���r���c�������������������@���r���)mfracr���Nr���r ���r ���r ���r$���r���"��r���r���c�������������������@���"���e�Zd�ZdZdddZdd�ZdS�) msubsup���NFc�����������������C������||�_�t|�|�d�S�r���reversedr���r���r���r���r���r ���r ���r$���r���'�����zmsubsup.__init__c�����������������C���s4���|�j�r|�jd�|�jd�g|�jdd<�d|�_�t|�S�)Nr���r���r���F)r���r���r���r���r���r ���r ���r$���r���+��s��� z msubsup.xmlNFr���r���r���r���r���r���r ���r ���r ���r$���r���%������  r���c�������������������@���s,���e�Zd�ZddddddZdd�Zd d �Zd S�) mfenced{u���〈}u���〉r���)\{\langle\}\rangle.c�����������������C���s���||�_�t|��d�S�r���)openparr���r���)r���parr ���r ���r$���r���6��s���zmfenced.__init__c�����������������C���s2���|�j�|�j|�j}|�j�|�j|�j}d||f�gS�)Nz)r���r���r���closepar)r���openr���r ���r ���r$���r���:��s���zmfenced.xml_startN)r���r���r���r���r���r���r ���r ���r ���r$���r���2��s���� r���c�������������������@���r���)mspacer���Nr���r ���r ���r ���r$���r���?��r���r���c�������������������@���s���e�Zd�ZdddZdd�ZdS�)mstyleNc�����������������K���s$���|d�ur||�_�t|�|�||�_d�S�r���)r���r���r���attrs)r���r���r���kwargsr ���r ���r$���r���C��s���  zmstyle.__init__c�����������������C���s ���dgdd�|�j��D��dg�S�)Nz.r���)r���itemsr���r ���r ���r$���r���I��s ��� zmstyle.xml_startr���)r���r���r���r���r���r ���r ���r ���r$���r���B��s����  r���c�������������������@���r���) moverr���NFc�����������������C���r���r���r���r���r ���r ���r$���r���O��r���zmover.__init__c�����������������C���s ���|�j�r |�j��d|�_�t|�S�r���)r���r���reverser���r���r���r ���r ���r$���r���S��s���  z mover.xmlr���r���r ���r ���r ���r$���r���M��r���r���c�������������������@���r���)munderr���Nr���r ���r ���r ���r$���r���Y��r���r���c�������������������@���s���e�Zd�ZdZdddZdS�) munderoverr���Nc�����������������C���s���t�|�|�d�S�r���)r���r���)r���r���r ���r ���r$���r���^��s���zmunderover.__init__r���)r���r���r���r���r���r ���r ���r ���r$���r���\��s����r���c�������������������@���s ���e�Zd�ZdZdd�Zdd�ZdS�)mtextr���c�����������������C���r���r���text)r���r���r ���r ���r$���r���c��r���zmtext.__init__c�����������������C���r���r���r���r���r ���r ���r$���r���f��r���zmtext.xml_bodyN)r���r���r���r���r���r���r ���r ���r ���r$���r���a��s���� r���Tc�����������������C���sL��d�|��}�|rt�}t|dd}n t�}ttt|dd}t|�dkrt|�}|�d�}d}|dkr:|�d�}nd}|dkrBnV|dkr|d v�rU|t |}d }nC|dkrc|t �}d }n5|d krq|t �}d }n'| �rd }||k�r|�|� �r|d7�}||k�r|�|� �s|�d|�} t | ||�|d �\}}||7�}n|dkrt�} t| } | � �| �| }d }ntd ||f�| �r|t|}n|�r|t|}n|dv�r|t |}n|dkr|�} t| trt| jdd} nt| t r| jtv�rt| } nt| } || �| }ny|dkrf|�} t| tr4t| j}n*t| t rE| jtv�rEt| }nt| trZ| jd�jtv�rZt| j}nt| }||�|}n2|dkrvt�} || �| }n"|dkr| �}n|dkrt�} | �| �| }ntd|�|�|d �}�t|�dks'|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. Tr���Fr���r���r���\z{}r���r���NzSyntax error: "%s%s"z+-*/=()[]|<>,.!?':;@_r���r���r���r���&zIllegal character: "%s")r���splitr���r���r���r���r���r���r���r���r���isalphahandle_keywordr��� SyntaxErrorr���isdigitr���r���r���r���r���r���r��� sumintprodr���r���r���r���)stringr���r���treerx���rm���skipc2rs���nameentryrowr���subrH���r ���r ���r$���parse_latex_mathi��s���                         Or��c�����������������C���s0��d}t�|dkr|d�dkr|dd��}d}|�dkr;|ds#td|d7�}t�}tt|}||�|}||fS�|�dkrX|dsHtd |d7�}|���}||fS�|�d v�r|d�d krftd |d }|dkrstd |t |d|�}||d�7�}||fS�|�dkrt �}||�|}||fS�|�dkrt �}||�|}||fS�|�dkrdD�] } || r�nqtdt | } || �t �} | | �| }|t�| 7�}||fS�|�dkrdD�] } || r�nqtd|�}| |_|�}|t�| 7�}||fS�|�dkr1tD�] } || r�nqtd|tt| �}|t�| 7�}||fS�|�dkrGtddd} || �| }||fS�|�dkrx|d�d ksa|d��ra|d�d kretd|tt|d��}|d7�}||fS�|�d v�r|d�d ks|d�d krtd!|tt|d��}|d7�}||fS�|�d"kr|td#}||fS�|�tv�r|tt|��}||fS�|�tv�r|tt|��}||fS�|�tv�r|tt|��}||fS�|�tv�r|t|�}||fS�|�tv�rttt|��d$d%}||�|}||fS�td&|��)'Nr���r���r���beginz{matrix}z;Environment not supported! Supported environment: "matrix".���endzExpected "\end{matrix}"!)r���mathrmr���zExpected "\text{...}"!r���r���sqrtfracleft)([|r���r���r���zMissing left-brace!right))]r��r���r���r���zMissing right-brace!notz)Expected something to negate: "\not ..."!mathbfbold)r��� mathvariantmathbbr���z%Expected something like "\mathbb{A}"!r���)mathscrmathcalz&Expected something like "\mathscr{A}"!colon:Tr���zUnknown LaTeX command: )r��� startswithr���r���r���r���r���r���findr���r���r���r���r���r��� negatablesr���r���isupperr���r��r��Greeklettersr!��� functionsoverr���)r��r���r���r��r��tablers���r ��r��r���fencedr��operatorstyleovrr ���r ���r$���r�����s���    U P   H D @    4   *   "   *         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. r���r���)r��r���r���)tex_mathr��� mathml_treer ���r ���r$��� tex2mathml1��s��� r.��)T)1r���docutils.utils.math.tex2unicharutilsr��� tex2unicharr&��r#�� mathalphar$��mathbinr!���updatemathrelmathordmathopmathopen mathclose mathfencer���r���r%��r��r��r!��objectr���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��                   !"#$%&'()*+,-./012347[      dd