jf(dZddlZddlZddlmZmZejZded<dddd d d d d dddd Zdddddddddd Z e ddDdddddZ ddd d!d"d#d$d%d&d'd(d)d$d* Z id+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdBdFdDdGdDZ e eje eje ejidHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdcdgdcdeddhdidjdkdlZe eje eje eje eje eje e dmdndoZdpdqdrdsdtdudvdwZdxZdydzd{d{d|d}d}d~d~ddddd Zddddddddddddd ZddddddddZddddddZddddZddddddZdddddddddZ dddddddddddddZ!iifddddife!dife!difiddife!dddife!dddifdZ"gdZ#ddddddddddd Z$GddZ%Gdde%Z&Gdde%Z'GdÄde%Z(Gdńde(Z)GdDŽde(Z*GdɄde(Z+Gd˄de(Z,Gd̈́de(Z-Gdτde(Z.Gdфde%Z/Gdӄde/Z0GdՄde/Z1Gdׄde/Z2Gdلde/Z3Gdۄde%Z4Gd݄de4Z5Gd߄de4Z6Gdde4Z7Gdde5Z8Gdde6Z9Gdde7Z:Gdde4Z;Gdde%Z<Gdde%Z=dZ>dZ?dZ@dZAdZBdZCdZDdZEddZFdZGdZHdZIdZJddZKdS(zConvert LaTex maths code into presentational MathML. This module is provisional: the API is not settled and may change with any minor Docutils version. N) tex2unichar toplevel_codeuℏhbaruΦuΞΣuΨuΔuΘuϒΠuΩΓuΛ) PhiXiSigmaPsiDeltaThetaUpsilonPiOmegaGammaLambdau lim infu lim supu inj limu proj limlim) liminflimsupinjlimprojlim varlimsup varliminf varprojlim varinjlim operatornamec#K|]}||fV dSN).0names /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/docutils/utils/math/latex2mathml.py r$Bs>AA$$AAAAAA)arccosarcsinarctanargcoscoshcotcothcscdegdetdimexpgcdhomkerlglnlogPrsecsinsinhtantanh)TTFz0.278em)FTT0.444em)FTFz0.667em)FFTr?)bmodpmodmodpodbolditalic monospacenormalz sans-serifscriptz bold-italicz double-struckfrakturzsans-serif-italiczsans-serif-bold-italic) boldsymbolmathbfmathitmathttmathrmmathsfmathcalmathbfitmathbbmathfrakmathsfit mathsfbfitmathscr backslash\uparrowu↑ downarrowu↓ updownarrowu↕Uparrowu⇑ Downarrowu⇓ Updownarrowu⇕ lmoustacheu⎰ rmoustacheu⎱ arrowvertu⏐ bracevertu⎪lvert|lVert‖rvertrVert Arrowvertnleqqu≦̸ngeqqu≧̸ nleqslantu⩽̸ ngeqslantu⩾̸ngtrlessu≹nlessgtru≸ nsubseteqqu⫅̸ nsupseteqqu⫆̸ centerdotu⬝ varnothingu⌀ varproptou∝triangleu△ triangledownu▽dotsb⋯dotscu…dotsidotsmsupinfmaxmin)dotsorr|r}r~ru∼u≈)thicksim thickapproxu∣u∥u∤u∦u⌢u⌣u∫)shortmid shortparallel nshortmidnshortparallel smallfrown smallsmilesmallint)bigcapbigcupbigodotbigoplus bigotimesbigsqcupbiguplusbigveebigwedgecoprodintopointopprodsumrr~rr|r}2em1emz0.2778emz0.25emz0.2222emz0.1667emz -0.1667emz -0.2222emz -0.2778em) qquadquad thickspace; medspace: thinspace, negthinspace! negmedspace negthickspace)´ú)uˉū)u˘ŭ)uˇǔ)u˙u̇)¨ü)rxu⃛)`ù)uˆû)u˚ů)u˜ũ)→u⃗) acutebarbrevecheckdotddotdddotgravehatmathringtildevec)u⏞皙ɿ)←r)u↔r)_r)rr)^g)~g333333ӿ) overbrace overleftarrowoverleftrightarrowoverlineoverrightarrowwidehat widetilde)u⏟g?)rg) underbraceunderleftarrowunderleftrightarrow underlineunderrightarrowu−u∶ )-rruℾuℿ⅀uℽuℼ)rrruγuπ)r)())[]){})rdrd)rfrf)rr)matrix smallmatrixpmatrixbmatrixBmatrixvmatrixVmatrixcasesT) displaystyle scriptlevelF)r textstyle scriptstylescriptscriptstylecfrac)rrCLASSrr linethickness)fracrdfractfracbinomdbinomtbinom)rz1.2emz1.623emz2.047emz2.470em) leftrightbiglbigrBiglBigrbigglbiggrBigglBiggrceZdZdZdZ dZ dZeddeddedd d d iZd d dZ dZ dZ dZ dZ dZdZdZdZdZdZdZdZddZdZddZdZdS) mathz8Base class for MathML elements and root of MathML trees.Nrz>&z&ia z⁡truefalse)TFspancg|_||i|_|D]$}|||j|<%dS)aSet up node with `children` and `attributes`. Attributes are downcased: Use CLASS to set "class" value. >>> math(mn(3), CLASS='test') math(mn(3), class='test') >>> math(CLASS='test').toprettyxml() ' ' N)childrenextend attributeskeyslower)selfrrkeys r#__init__z math.__init__Zsd  H??$$ ; ;C,6c?DOCIIKK ( ( ; ;r%cdt|dgD}t|dr'|t|jt |t r|jr|d|d|j Dz }|j j dd |zzS)Nc,g|]}t|Sr )repr)r!items r# z!math.__repr__..nsHHH$4::HHHr%rdataz switch=Truec&g|]\}}||d|S)N=r r!kvs r#r z!math.__repr__..ss2&&&tq!}QQN$}}r%z(%s)z, ) getattrhasattrappendr r  isinstance MathSchemaswitchritems __class____name__join)rcontents r#__repr__z math.__repr__msHH'$ B*G*GHHH 4  , NN4 ?? + + + dJ ' ' *DK * NN= ) ) )&&t/D/D/F/F&&& &~&$))G2D2D)DDDr%c*t|jSr)lenrrs r#__len__z math.__len__xs4=!!!r%c|j|Srr)rrs r# __getitem__zmath.__getitem__}ss##r%c||j|<dSrr#)rrr s r# __setitem__zmath.__setitem__s#r%c&|jj|i|Sr)rget)rargskwargss r#r(zmath.gets"t"D3F333r%cD|jduot||jkS)z;Return boolean indicating whether children may be appended.N) nchildrenrr s r#fullz math.fulls&d*0II/ 1r%c|rtd|z|j|||_|r|S|S)zAppend child and return self or first non-full parent. If self is full, go up the tree and return first non-full node or `None`. zNode %s already full!)r- SyntaxErrorrrparentclose)rchilds r#rz math.appendsh 99;; >5<== = U### 99;; ::<<  r%c:|D]}|||Sr)r)rrr2s r#rz math.extends+  E KK     r%cz|j}|1|r|j}|||S)z7Close element and return first non-full parent or None.)r0r-)rr0s r#r1z math.closes= V[[]] ]F V[[]]  r%cPd|S)z,Return XML representation of self as string.r)r_xmlr s r# toprettyxmlzmath.toprettyxmlswwtyy{{###r%cz|g||zd|jjzgzS)Nz) xml_starttag _xml_bodyrrrlevels r#r6z math._xmlsB""$$%..''(T^4456 7r%cd|jD}dd|jjg|RzS)Nc3K|]F\}}||dt|dddddVGdS)Nz="TruerFalser")strreplacers r#r$z$math.xml_starttag..sh##QM aaQ!?!?!G!GQX!Y!Y!Y!YZ!MMM##r%z<%s>r)rrrrr)rattrss r#r9zmath.xml_starttagsW##!_2244###$."9!BE!B!BCCCCr%cg}|jD]J}|dd|dzzg|||dzK|dd|zg|S)N z r)rrr6)rr<xmlr2s r#r:zmath._xml_bodys}] , ,E JJdeAg./ 0 0 0 JJuzz%'** + + + + D$,'((( r%c |ddkS#t$r/ |jcYS#t$rYYdSwxYwwxYw)z;Return true, if `self` or a parent has ``display='block'``.displayblockF)KeyErrorr0is_blockAttributeErrorr s r#rLz math.is_blockst  ?g- -    {++-----!   uuu  s(  A4A AAAAr)r __module__ __qualname____doc__r,r0_levelord xml_entities _boolstrings html_tagnamerrr!r$r&r(r-rrr1r7r6r9r:rLr r%r#rrDspBBI- F) F C& C& C'# L!11LCL+;;;& E E E""" $$$$$$444111    $$$7777 DDD r%rceZdZdS)mtableNrrOrPr r%r#rXrXr%rXc"eZdZdZfdZxZS)mrowz*Group sub-expressions as a horizontal row.c|j}t|trU|jdkrJt |j|_|j|_|jD] }||_ |St |dkre |jd|j|j|<||jd_n$#ttf$r|jdcYSwxYwtS)zClose element and return first non-full parent or None. Remove , if it is single child and the parent infers an mrow or if it has only one child element. rr) r0r MathRowSchemar,rrr1indexrM ValueErrorsuper)rr0r2rs r#r1z mrow.closes  fm , , "1AQ1F1F"6?33F "mFO & &% <<>> ! t99>> (?C}Q?O 5 5d ; ;<*0 a ''"J/ ( ( (}Q'''' (ww}}s?CC('C()rrOrPrQr1 __classcell__rs@r#r\r\s>44r%r\ceZdZdZdS)r^zCBase class for elements treating content as a single inferred mrow.N)rrOrPrQr r%r#r^r^ sMMMMr%r^ceZdZdS)mtrNrYr r%r#rfrfrZr%rfceZdZdS)mtdNrYr r%r#rhrhrZr%rhceZdZdZdS)mencloserNrrOrPr,r r%r#rjrjIIIr%rjceZdZdZdS)mphantomrNrkr r%r#rnrnrlr%rnceZdZdZdS)msqrtrNrkr r%r#rprprlr%rpceZdZdZdS)mstylerNrkr r%r#rrrrrlr%rrc.eZdZdZdZfdZddZxZS) MathTokenzbToken Element: contains textual data instead of children. Base class for mo, mi, and mn. rc H||_tjdi|dS)Nr )r rar)rr rrs r#rzMathToken.__init__)s- &&:&&&&&r%c\t|j|jgSr)rBr  translaterTr;s r#r:zMathToken._xml_body-s$DI(():;;<>> tex_cmdname('mymacro2') # up to first non-letter ('mymacro', '2') >>> tex_cmdname('name 2') # strip trailing whitespace ('name', '2') >>> tex_cmdname('_2') # single non-letter character ('_', '2') z([a-zA-Z]+) *(.*)Nz(.?)(.*)rrrematchgroupstringms r# tex_cmdnamersK %v..Ay H[& ) ) 771::qwwqzz !!r%ctjd|}|d|fS|d|dfS)zmReturn leading number literal and remainder of `string`. >>> tex_number('123.4') ('123.4', '') z([0-9.,]*[0-9]+)(.*)Nrrrrrs r# tex_numberrsD (&11Ay6z 771::qwwqzz !!r%ctjd|tj}|dddd\}}}}|p|p||fS)zReturn first simple TeX token and remainder of `string`. >>> tex_token('\command{without argument}') ('\command', '{without argument}') >>> tex_token('or first character') ('o', 'r first character') a%((?P\\[a-zA-Z]+)\s* # TeX command, skip whitespace |(?P\\.) # one-character TeX command |(?P.?)) # first character (or empty) (?P.*$) # remaining part of string cmdchcmdch remainder)rrVERBOSEr)rrrrrrs r# tex_tokenrsZ bj  * *A !"wk J JCI  % 2y ((r%cd}d}d}|ds|dd|ddfS|D]4}|dz }|rd}n |dkrd}n|dkr|dz }n |dkr|dz}|dkrn5td |d|dz ||dfS) zReturn first TeX group or token and remainder of `string`. >>> tex_group('{first group} returned without brackets') ('first group', ' returned without brackets') rFrNrrXTrzGroup without closing bracket) startswithr/)r split_index nest_levelescapecs r# tex_grouprsKJ F   S ! !&bqbz6!"":%%  ; ;q  FF $YYFF #XX !OJJ #XX !OJ ?? E 9::: !KM/ "F;<<$8 88r%ct|\}}|dkr$t|\}}||fS)aReturn first TeX group or token and remainder of `string`. >>> tex_token_or_group('\command{without argument}') ('\command', '{without argument}') >>> tex_token_or_group('first character') ('f', 'irst character') >>> tex_token_or_group(' also whitespace') (' ', 'also whitespace') >>> tex_token_or_group('{first group} keep rest') ('first group', ' keep rest') r)rrlstrip)rr)rs r#tex_token_or_grouprsAv&&NC czz"6==??33Y  >r%ctjd|tj}||dsd|fS |d|dfS#t $rt d|zwxYw)a$Return optional argument and remainder. >>> tex_optarg('[optional argument] returned without brackets') ('optional argument', ' returned without brackets') >>> tex_optarg('{empty string, if there is no optional arg}') ('', '{empty string, if there is no optional arg}') z\s* # leading whitespace \[(?P(\\]|[^\[\]]|\\])*)\] # [group] without nested groups (?P.*$) Nrroptargrz+Could not extract optional argument from %r)rrrrrrMr/rs r# tex_optargr&s bj * *A y**3//y6zRwwx  !''+"6"666 RRRG&PQQQRs )A''BcBd|}|}t|dkra|d|dd}}|dkr-|dkr(t|\}}t |||\}}n|dvrt ||}n|dkr't }|||}n|dkr|}n|d kr9t}|||}nh| r$|t|}n0| r8t|\}}|t||z}n|tvryi}|d krE|jr>|jd }t#|d d d vs|ddkrd|d<|t't|fi|}nb|dvr%|t'|d}n9|dvr#|t'|}nt)d|zt|dka|S)uAppend MathML conversion of `string` to `node` and return it. >>> parse_latex_math(math(), r'lpha') math(mi('α')) >>> parse_latex_math(mrow(), r'x_{n}') mrow(msub(mi('x'), mi('n'))) rrrNrX_^rrrrrr z([=classmathopenprefixformz/()[]|Fstretchyz +*=<>,.!?`';@zUnsupported character: "%s")rsplitrr handle_cmdhandle_script_or_limitr\rr1rhisalphar{isdigitrranomalous_charsrrr(r}r/) nodertreercmdnamenew_nodenumberr previous_nodes r#parse_latex_mathrEsXXfllnn % %F D f++//1Ivabbz6 88  99)&11OGV%gtV<ks|d?r|}||fS|d@krtA|\}}|dAkr|dB|zfS|dr7 t*|dd }n #t6$rt9dC|zwxYwtCj"dD|dEz}|t|}||fS|dFvrt |\}}|#dG}tI|D]W\}}|dHzdkr9tKj&dIdJ|}|tO|}Gt||X||fS|tPvr5|tdKtP|z}||fS|dLvrntS|\}}|dMrdNtU|d dOdPz z}|tdK|z}||fS|dQkr'tW}||||fS|dRkr)tYdST}||||fS|dUkrt[|\}}|rDt=}t]|d0V}t|||nt_}||||fS|t`vrt`|\}}|dWkrHt[|\}}d;d>dX}||vr-|1}|||dY<dZ||z|d<tedmi|x}}|d[r4t=td|tdd[\}d]|_3|r t%|fi|}||||fS|dkrZti}tk|}||||fS|tlvrgtttl|dd d0V}|d^krd |j7dd_<||_8||||fS|trvrRtttr|dd0 d0d `}||_8||||fS|dakr)td0V}||||fS|ttvrOt ttt|dd0V}||_8||||fS|dbkr)t d0V}||||fS|dcvrt[|\}}tt*dd|dd z}|ratw|}tt=|}ty|dkr |j7d}||nt|}||||fS|tzvrt%dmitz|}d |_3t}|t<rLty|dkr9||j?j7|j?j7@|<|j?|_?n8|jAjBdekr||nt9df|z||fS|dgr.tA|\}} |dhvr| }t|||i}||fS|djkrt||S|dkkrt||St9dl|z)nujProcess LaTeX command `name` followed by `string`. Append result to `node`. If needed, parse `string` for command argument. Return new current node and remainder of `string`: >>> handle_cmd('hbar', math(), r' rac') (math(mi('ℏ')), ' \frac') >>> handle_cmd('hspace', math(), r'{1ex} (x)') (math(mspace(width='1ex')), ' (x)') z capital-greekrrrG) mathvariantrrr¯F)accentrrrrr)rru⁡rB)lspacerspacer)widthrr0.333emrrJrrVrXrNrRrcolonrpostfix0z0.28em)rrridotsintz\int\dotsi\intzfont-weight: bold)stylez75%)mathsizez _^T movablelimits)rcrerz()[]/|.zUnsupported "\z " delimiter "z"!maxsizeminsize symmetricrl.rrnotrz{\not z\not: Cannot negate: "%s"!NFCu̸)textmboxtextrm$rz(^ | $)rz%s)hspacermuz%semrphantomboxedbox)notationsqrt)rr)rrnumalignz numalign-r)rrrr)rroversetunderset) xleftarrow xrightarrowlongrz3Declaration "\%s" must be first command in a group.limitsr)rbeginendzUnknown LaTeX command: \r )Flettersr{greek_capitalsr functionsrrr}rmodulo_functionsrLrrmath_alphabetsrr(rRrrrthick_operatorssmall_operators operatorsr bigdelimitersdelimiter_sizes stretchablesrrKr/endswithr\r1r unicodedata normalizer enumeratersubryspacesrfloatrnrjrrrp fractionscopyrr,rhrfaccentsrtex_cmdoverunderrr layout_stylesrr0r_rrrbegin_environmentend_environment)r"rrrr)binarynamed parenthesespaddingrrrdelimiter_attributessize delimiterrowpartsipartradix indexnode style_atts frac_attsroptargsrentry subscriptbasesub_nodes r#rrs& wgdm$$ > ! !!0HW {{8$$V| y > ! !-V44KC#8444HH)D/**H ;  h300HH [ Xr$xx>>>HH \ ! !h8 55HH [ h8 55H{{8$$  -fQiz11;;r(||,,DV| 0@0F- W  ;;r%HHHIID<  ==?? G{{600011  8;;r#66677D  8;;r%yy))D;;vI66677D(00 Vc**  8;;r#66677DV| ~ <  !<0JJ')=>J 9  "+Jw +F33Y >>$   ,++c!""gs++C 8  **S#&&C ;;== #C8OO;;r#444455D? "$$$$ Ef} w{{2c #hOOOPPV| z&788V| {{2od3;NOOOPPV| {{2od3eDDDEEV| y = V q U0B0B*.J ' ' ' ' '",Jw {{2io<<<<==V| }!}T23.v66 6 I % % 7()9)9$)?)?@  7 7 7!k%)TT999#6777 7  5.2  +.2  +04  - 6>>T]]3//>&&C KK   D    KK9==(<== > > > 7??dmmC00?::<>$   E EABB( E E E!"?"CDDD E#E3x<88{{2c77##V| )))(00 V # '' - -GAt1uzzvi488{{5;;// t,,,,V| v~~{{6VD\(9:::;;V| ###'' V <<   0E#crc(OOB./C{{6S11122V| y:: H wU+++ H  v~~"6** v  IYt444H Y . . . OO    wwH H y"+D/Y 7??'//NFF"11G  %NN,, (/ *%%076?%B '",,),,,4 == ! ! #BsGGXr#wwgFFFH!"H   6h55*55H HV| t||u:: ##H---f} wGDM!,u===dKKK 5==-2H a  * H t||DJqM$777 $U444 H y%%% H u}}"U4[^,,T::: H z&&& H ,,,&v.. 6)F48O,--  #!$''H' ::H8}}!!#,Q/ OOH % % % %T{{H H }00M$/00! dD ! ! 4c$ii1nnEMDK !5!;!;D!A!A B"kHOO ^ $ . . KK ! ! ! !,.2344 4 }}X"6**Y $;;F)$DAAADV| w v... u}}tV,,, 1D8 9 99s T""!U+YYrc|j}|dkrd|d<n#|dkst|ddtvrd|d<|dkrt |t rt |jddi}nt |trt|jddi}n|d vs|dkr&| dd rt|}nt|}n|d krt |trt |j}nct |trt|j}n?|d vs|dkr&| dd rt |}nt|}| ||S) z)Append script or limit element to `node`.rFrr rTrr)rrNr) rrrrrrrrrr(rrr)rrrr2rs r#rrs M    E !&o O # # UFB ' '= 8 8!%oCxx eU # # #!5>?$??HH t $ $ #2HH t $ $ #/HH3332%))OT"B"BU||HHE{{HKK Or%c0t|\}}|tvrt|d}i}|r]tt|}|dkr#tt|d}d|d<|||}n7|dkr1d|d <d |d <t d }|||}t }|tt|fi||}ntd||fS)Nrrz0.17em)rr columnalignrz0.02em rowspacingr columnspacing1)rEnvironment not supported!) rmatricesr\r}rrrrhrXrfr/)rrr"left_delimiterrwrapperr$s r#rrs-V$$LD& x!$*  2n--..Gwr.BBBCC,2 =) KK DD ] " "'/J| $*3J '---G KK D F3u::44445556777 <r%ct|\}}|tvr|}t|d}|r7|t |}|}n*|dkr|}nt d||fS)Nrrr.)rr/r1rr}r/)rrr"right_delimiters r#rr6sV$$LD& xzz||!!##))++"4.+  ;;r/2233D::<
.H=AASsyy~~ % 0 00AAAAAAr%rrr)r~int)rowstabss r#tex_equation_columnsr>Gs@ AADAAA A AD qyyq tAvz??r%cddd}td|D}|rQddg|z}ddg|z}d |d|d z|d <d |d||d <|S) NalignT)rrc3lK|]/}|d|dz V0dSr6r7r9s r#r$z#align_attributes..[r:r%rrrrrrr*r,)r~r)r<attsr=alignsspacings r#align_attributesrEXs  " "D AADAAA A AD 96"T),%!hhvgtAvg77] #$ 8 8_ Kr%c vtd}|}|sd|d<t|d}t|dkrHt }|t t|fit|t||| S)zoReturn string with MathML code corresponding to `tex_math`. Set `inline` to False for displayed math. z"http://www.w3.org/1998/Math/MathML)xmlnsrJrIz\\r) rrrrrhrrXrfrErr7)tex_mathinline math_treerr<s r# tex2mathmlrKms ?@@@I D ?& )X&&,,U33 t99q==55D   VCII>>&6t&<&<>> ? ? ?T8$$$  " ""r%)r)T)LrQrrdocutils.utils.mathrr mathalpharrrupdaterrr mathfencer mathclosermathbinmathrelmathord mathpunctmathoprrrr r rrrrRr/rr rrrrXr\r^rfrhrjrnrprrrtryr{r}rrrrrrrrrrrrrrrrrrrrrrr>rErKr r%r#rVsL   ::::::::   8h hx(  ++    AA@AAAAAA - , , , !%*.488  8  8 888888 # ( #  (!"(# & K)*** K())) K)***   .  . .   .   .  . . .  (   H " X# $ X% & X' ( X) *     7    : $%%% $%%% $%%% &''' #$$$   4 ! %%#%%%%&&&& $!     !   !  (-,,,,,,  !1 0 0 0 0   !      #  +/BB*/BB*/BB*/BB  2h $a ""#%'^,b1[)2.OQ'(^,.BC[)OQ+?@   A@@   @@@@@@@@|T4>NNNNNDNNN--}}M] = = = = = = = =I,::jTD" JDT""": " " "6)))>999b,RRR>777f{:{:{:B B8   ""   *######r%