B \ @s ddlZGdddeZddlZddlZGdddeZGdddeZGdd d eZGd d d eZGd d d eZ GdddeZ GdddeZ GdddeZ GdddeZ GdddeZGdddeZGdddeZGdddeZGdddeZGd d!d!eZGd"d#d#eZGd$d%d%eZGd&d'd'eZddlZddlZddlZGd(d)d)eZGd*d+d+eZGd,d-d-eZGd.d/d/eZGd0d1d1eZGd2d3d3eZ Gd4d5d5e Z!Gd6d7d7eZ"Gd8d9d9eZ#Gd:d;d;e!Z$Gdd?d?e%Z&Gd@dAdAe%Z'GdBdCdCe%Z(GdDdEdEe(Z)GdFdGdGe(Z*GdHdIdIe%Z+ddlZddl,Z,GdJdKdKeZ-GdLdMdMeZ.GdNdOdOeZ/GdPdQdQeZ0GdRdSdSeZ1GdTdUdUe/Z2GdVdWdWe2Z3GdXdYdYe2Z4GdZd[d[eZ5Gd\d]d]e5Z6Gd^d_d_e6Z7Gd`dadae5Z8Gdbdcdce8Z9Gdddedee5Z:GdfdgdgeZ;GdhdidieZGdndodoe>Z?Gdpdqdqe9Z@Gdrdsdse>ZAGdtdudue>ZBGdvdwdwe>ZCGdxdydye>ZDGdzd{d{e>ZEGd|d}d}e>ZFGd~ddeFZGGdddeZHGdddeZIGddde5ZJGddde>ZKGdddeZLddlMZMddlNZNGdddeZOeOeO_PGdddeZQGdddeQZRGdddeZSGdddeSZTeTeS_UeSeS_VGdddeZWGddde5ZXGddde5ZYGddde:ZZGddde:Z[Gddde:Z\Gddde:Z]Gddde:Z^Gddde:Z_Gddde:Z`Gddde:ZaGddde:ZbGddde:ZcGddde6ZdGddde5ZeGddde5ZfGddde5ZgGddde5ZhGdddehZiGddde5ZjGddde:ZkGddde6ZlGddde5ZmGddÄdemZnGddńdenZoGddDŽde%ZpGddɄdeZqGdd˄deZrGdd̈́demZsGddτdemZtGddфde>ZuGddӄdeuZvGddՄdevZwGddׄdevZxGddلdewZyGddۄdevZzGdd݄devZ{Gdd߄devZ|GdddevZ}GdddezZ~eLjeue{g7_eyeweze~e}e|exgeu_GdddeZGdddeZGdddevZGdddeuZGdddeuZGdddevZGdddeZGdddeZGdddeZGdddeZGdddevZeujeg7_ddlZGdddezZGdddezZGdddewZGdddeZGdddeHZGdddezZGdddeHZGdd d ewZeujeeeeg7_eIjeeg7_Gd d d eZGd d d evZGdddeZGdddeZeujeg7_GdddeZGdddeZGdddeZGdddevZGddde>ZGdddevZGdddeJZeLjeg7_eujeg7_d d!Zd"d#Zed$k r|edS(%Nc@speZdZdZdZdZdZdZddZddZ dd Z d d Z d d Z e eZe e Z e e Z e e Z e e Z dS)TracezA tracing classFNcCs"tjr tjrdSt|tjdS)zShow a debug messageN)r debugmode quietmodeshowsysstdout)clsmessager A/tmp/pip-build-uw_ogi45/docutils/docutils/utils/math/math2html.pydebug%s z Trace.debugcCs2tjr dStjr tjr tj|}t|tjdS)zShow a trace messageN)rrprefix showlinesmoderrr)rr r r r r +s   z Trace.messagecCs0d|}tjrtjrtj|}t|tjdS)zShow an error messagez* N)rr rrrstderr)rr r r r error3s  z Trace.errorcCstd|tddS)z#Show an error message and terminatezFATAL: N)rrexit)rr r r r fatal:sz Trace.fatalcCs&tjdkr|d}||ddS)zShow a message out of a channel)rzutf-8 N)r version_infoencodewrite)rr Zchannelr r r r?s  z Trace.show)__name__ __module__ __qualname____doc__rrrr r r rrr classmethodr r r r rsrc@seZdZdZddddZddddZd d d d d Zd ddd dddddddd dddddZddddZddddd Z dddd dd!d"Z d#d$dd%d Z d&S)'BibStylesConfigz+Configuration class from elyxer.config filezy$authors. $title. $journal,{ {$volume:}$pages,} $month $year.{ doi: $doi.}{ URL $url.}{ $note.}z$surname($year)zS$authors. $title. $publisher, $year.{ URL $url.}{ $note.})z@articlecitedefaultz$authors. $title.{ $journal{, {$volume}{($number)}}{: $pages}{, $year}.}{ $url.}{ $filename.}{ $note.}z$Sur$YYzt$authors. $title.{ $journal,} $year.{ $url.}{ $filename.}{ $note.}zr$authors. $year. $title. $journal, $volume($number), $pages.{ URL $url.}{ $note.}zS$authors. $year. $title. $publisher.{ URL $url.}{ $note.}z$surname, $year)z@articlez@bookrr ue$authors: “$title”, $journal,{ pp. $pages,} $year.{ URL $url.}{ $note.}zj{$authors: }$title{ ($editor, ed.)}.{{ $publisher,} $year.}{ URL $url.}{ $note.}zW$authors: $title.{{ $publisher,} $year.}{ URL $url.}{ $note.}z$authors: $title{ in $booktitle{ ($editor, ed.)}}.{{ $publisher,} $year.}{ URL $url.}{ $note.}ug$authors: “$title”, $booktitle,{ pp. $pages,} $year.{ URL $url.}{ $note.}zh$authors: $title.{{ $publisher,}{ $howpublished,} $year.}{ URL $url.}{ $note.}zG$authors: $title, $year.{ URL $url.}{ $note.}uW$authors: “$title”, $journal, $year.{ URL $url.}{ $note.}z$index)z@articlez@bookz@bookletz @conferencez@inbookz @incollectionz@inproceedingsz@manualz@mastersthesisz@miscz @phdthesisz @proceedingsz @techreportz @unpublishedrr z??)ZYYZauthorssurnameu~$authors, “$title”, $journal, vol. $volume, no. $number, pp. $pages, $year.{ URL $url.}{ $note.}zS$authors, $title. $publisher, $year.{ URL $url.}{ $note.}uF$authors, “$title”. $year.{ URL $url.}{ $note.}zv$authors. $title.{ $journal{, {$volume}{($number)}}{:$pages}{, $year}.}{ URL $url.}{ $note.}z\$authors. $title. $publisher,{ $month} $year.{ URL $url.}{ $note.}z~$authors. $title.{ In $booktitle {($editor, ed.)}.} $publisher,{ $month} $year.{ URL $url.}{ $note.}zy$authors. $title. { $booktitle{, {$volume}{($number)}}{:$pages}{, $year}.}{ URL $url.}{ $note.}zR{$authors. }$title.{{ $publisher,} $year.}{ URL $url.}{ $note.})z@articlez@bookz @incollectionz@inproceedingsrr zy$authors. $title. $journal, $year{;{$volume}{($number)}{:$pages}}.{ URL: $url.}{ $note.}zO$authors. $title. {$publisher, }$year.{ URL: $url.}{ $note.}z`$authors. $title; {$publisher, }$year.{ $howpublished.}{ URL: $url.}{ $note.}N) rrrrZabbrvnatalphaZ authordate2r Z defaulttagsZieeetrplainZ vancouverr r r r rRsT rc@seZdZdZdddZdS) BibTeXConfigz+Configuration class from elyxer.config fileu—.)z--z..N)rrrrreplacedr r r r r%sr%c@seZdZdZddddddddd d dd d d ddddddZdddgdgddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2gd3Zd4d dd5Zdd6d6d7d8d9ddd6d6d6d:d6d;ddd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdNdOdPdQdRd#dSdTdUdVd?d@dAdAdAdAdBdUdEdHdIdDdGdIdJdBdIdNdWdXdYd r(c @sdeZdZdZddddddZddddd d d d d ddd ZddddZddiZddddZddiZ dS) EscapeConfigz+Configuration class from elyxer.config filer!u — u’u‘)rz -- z --- '` u r&u…u ▷ -/rj) z\InsetSpace \space{}z\InsetSpace \thinspace{}z \InsetSpace ~z\SpecialChar \-z\SpecialChar \@.z\SpecialChar \ldots{}z\SpecialChar \menuseparatorz\SpecialChar \nobreakdash-z\SpecialChar \slash{}z \SpecialChar \textcompwordmark{}z \backslashz&z<z>)&<>z/>ryz z z )rtu u u u N) rrrrcharscommandsentitieshtml iso885915 nonunicoder r r r rq#s   rqcS@steZdZdZdddddddd d d d d dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@d%dAdBdCdDdEdFdGIZdHdIdJdKdLZdMdNdOgdPdQdRgdSdTdUgdVdWdXgdYdZd[d\gd]gd^dZd_d`gdagdbZdcddgdedfgdgZdhdidhdhdjdkZdldmdndodmdpdqdrdsdtdldudodndvdwdxdvdydzd{d|dsdxd|d}Z d~dddddIdddddddddddddddddddddddddddddddddddd4dddddd5ddddddddddd6dd7d8dd9ddddddddddd:ddddd;dddd?d@dAdBdCdDdEdFdGdHdIddJdKdLdMdNdOdPdQdRdSdTdUdVdWdVdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdedkdldmddndodpdqdrdsddtduddvdwdxdydzdzd{d|d<d}dXd~ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddÐdĐdddŐddːdǐdȐdɐdʐdːdːd̐d͐dΐdϐdАdddddϐdҐdɐdӐdԐdՐd֐dאdؐdِdڐdېdܐdݐdސdߐddddddddddddddddddddddadddddddddddddddddddddddddddddd d d d d ddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d#d+d,d-d.d/d0d1d2dd3d4d5d6dd7d8d9d:dd;d<d=d>d?d@dAdAdBdCdDdEdFdGdHdIdJdKdLdMdNdd5dݐdOdPd<dQdQddRdSdTdUdVdWdXdd ddYdZdd[d\d]ddd^d_d`dadbdcdddedfd^dadadgdhdidjddkdldmddnd4dfdFdodpdqdddrddsdtdudddvdwdxdydzdaddzRZ iZ dddd{Z dd|dd}dd~Z ddgdddgddgdZddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd:ZdddgdddgdddgdddddgdddgddddddgdddgdddgddŐdƐdǐdgddddɐddgdddgdːddgdːddgdddgd͐ddgd͐ddgdΐddgdddАdɐddgdѐddgdddgdӐdԐdgd͐d֐dgd͐d֐dgdddgdddgd͐ddgddِdАdڐdېdgdܐdݐdgddߐdgddgdddgdddgdddgdddddddgdddddgddŐdƐdǐdgdddgdddgd͐ddgdddgdddАddgd͐d֐dgdddgd͐d֐dgd,ZdddddddZddiZdddddddddd d d d d ddddZddddddddZdddddXdddddddd ddd!Zdd"d#d$dhd%ddd&d'd(d)d*d+d(d,d-d(d.Zd/d:d0d1d2d3d4d5dd6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdʐdEdFdGdHddIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]ddd^d_d`dadbdcdddedfdgdhdidjdVdVdkdldmdndodpdqdrddXdsdtdudvdwdxdydzd{d|dd}d~dddddddddҐdҐdȐdΐdՐdԐddddddߐddddddddd ddddd}dd5ddddddddddddd ddddd dZdddzddddd{dd ZdEddZddddddddddddd Zddddddd{ddddd]ddg iZddiZdS( FormulaConfigz+Configuration class from elyxer.config fileÅÆz#AmSuÅÐ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ϱuςuϑuξuζ)Iz\AAz\AEz\AmSz \Angstroemz\DHz\Koppaz\Lz\Microz\Oz\OEz\Sampiz\Stigmaz\THz\aaz\aez\alphaz\betaz\deltaz\dhz\digammaz\epsilonz\etaz\ethz\gammaz\iz\imathz\iotaz\jz\jmathz\kappaz\koppaz\lz\lambdaz\muz\nuz\oz\oez\omegaz\phiz\piz\psiz\rhoz\sampiz\sigmaz\ssz\stigmaz\tauz\tcohmz\textcrhz\thz\thetaz\upsilonz \varDeltaz \varGammaz \varLambdaz \varOmegaz\varPhiz\varPiz\varPsiz \varSigmaz \varThetaz \varUpsilonz\varXiz\varbetaz \varepsilonz \varkappaz\varphiz\varpiz\varrhoz \varsigmaz \varthetaz\xiz\zetaz\beginrwz\endz\\)begin cellseparatorend rowseparatoru⎛u⎜u⎝u⎞u⎟u⎠u⎡u⎢u⎣u⎤u⎥u⎦u⎧u⎪u⎨u⎩|u⎫u⎬u⎭u∥)()[]{r}u∥u⎲u⎳u⌠u⌡)u∑u∫zspan class="symbol"zz)z\leftz\left.z\middlez\rightz\right.üúûùūŭu̧ǔu⃛u̇ůu⃖u⃗u̩u⃝u̥ũ)z\"z\'z\^z\`z\acutez\barz\brevez\cz\checkz\dddotz\ddotz\dotz\gravez\hatz \mathringz\overleftarrowz\overrightarrowz\rz\sz \textcircledz \textsubringz\tildez\vz\vecz\~rtr!#$% 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|⇒¶ZPruϘu▶u◗u◑u⟆uℜu⦆u⇛u↱§u☐u⋐u☉u⋑u⇑u⇕u⊩u⊪u☒u⅄z
_uℵu∐u⚓u∠u♒ZarccosZarcsinZarctanargu♈u➢u∗u≍u∍u‵u⋍rju✗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↻®u⊛u⦸u⊚u⊝u⧁u⧀u♣z: u≔u∁u≅©coscoshZcotZcothZcscu⋎u⋏u↶u↷u†uℸu⇠u⊣u‡u⋱degZdetu╲u╱u⌀u♦Zdim÷u⋇u∸u≐u≑u∔u…u⌆u↓u⇊u⇃u⇂u⩤u♁u♪uℓu∅u≖u≕u≂u∃expu≒u⨾u♀u♭u∀u⁗u⌢u☹gcdu♊u≥u≧u←u≫u⋙uℷu≩u⋧u⋗u⋚u⪌u≷u≳«»uℏu♥z Zhomu↩u↪u(∫⋯∫u"u"infu∞u⊺u⫴u⅋u⌐u♃Zkeru"u⟪u⟨u⦉rru⌈u⇝u↢u⇤u↽u↼u⇇u⥢u☾u↔u⇆u⇋u⋋u♌u≤u≦u⋖u⋛u⪋u≶u≲u⌊Zlgu⟮u⊲u♎u↯u⦇ZliminfZlimsupu≪u⟦u⌞u⋘lnu≨¬u⋦logu⟵u⟷u⟼u⟶u↫u↬u◊u⌟u⋉u♂u✠u↤u↦^maxu∡u⚫u⚪u☿u℧u∣minu⊨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"u"u⊖u⊘u∂u✎u♓u⋔u♇±u➪u☞£u≺u≼u≾u′u∝uϙz u♩u☢u⟫u⟩u⦊rru⌉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↘secu″u∖u♯u≃sinsinhu♬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☼supu⫆u⫌u√u↙u⚔u⫾tantanhu♉u©'°u—ryrxªº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☯(Rz\ z\!z\#z\$z\%z\&z\,z\:z\;z\ACz \APLcommentz\APLdownarrowboxz \APLinputz\APLinvz\APLleftarrowboxz\APLlogz\APLrightarrowboxz\APLuparrowboxz\Boxz\Bumpeqz\CIRCLEz\Capz\CapitalDifferentialDz \CheckedBoxz\Circlez \Coloneqqz \ComplexIz \ComplexJz \Correspondsz\Cupz\Deltaz\Diamondz \Diamondblackz \Diamonddotz\DifferentialDz \Downarrowz\EURz\Eulerz \ExponetialEz\Finvz\Gamez\Gammaz\Imz\Joinz \LEFTCIRCLEz \LEFTcirclez\LHDz\Lambdaz\Lbagz \Leftarrowz \Lleftarrowz\Longleftarrowz\Longleftrightarrowz\Longrightarrowz\Lparenz\Lshz \Mapsfromz\Mapstoz\Omegaz\Pz\Phiz\Piz\Prz\Psiz\Qoppaz\RHDz \RIGHTCIRCLEz \RIGHTcirclez\Rbagz\Rez\Rparenz \Rrightarrowz\Rshz\Sz\Sigmaz\Squarez\Subsetz\Sunz\Supsetz\Thetaz\Uparrowz \Updownarrowz\Upsilonz\Vdashz\Vertz\Vvdashz\XBoxz\Xiz\Yupz\\z\_z\alephz\amalgz\anchorz\anglez \aquariusz\arccosz\arcsinz\arctanz\argz\ariesz \arrowbulletz\astz\asympz \backepsilonz \backprimez \backsimeqz \backslashz\ballotxz \barwedgez\becausez\bethz\betweenz\bigcapz\bigcircz\bigcupz\bigodotz \bigoplusz \bigotimesz \bigsqcupz\bigstarz\bigtriangledownz\bigtriangleupz \biguplusz\bigveez \bigwedgez \biohazardz \blacklozengez \blacksmileyz \blacksquarez\blacktrianglez\blacktriangledownz\blacktriangleleftz\blacktrianglerightz\blacktriangleupz\botz\bowtiez\boxz\boxastz\boxbarz\boxboxz \boxbslashz \boxcirclez\boxdotz \boxminusz\boxplusz \boxslashz \boxtimesz\bulletz\bumpeqz\cancerz\capz \capricornusz\catz\cdotz\cdotsz\centz \centerdotz \checkmarkz\chiz\circz\circeqz\circlearrowleftz\circlearrowrightz \circledRz \circledastz\circledbslashz \circledcircz \circleddashz \circledgtrz \circledlessz \clubsuitz\colonz \coloneqqz \complementz\congz\coprodz \copyrightz\cosz\coshz\cotz\cothz\cscz\cupz \curlyveez \curlywedgez\curvearrowleftz\curvearrowrightz\dagz\daggerz\dalethz\dashleftarrowz\dashvz\ddagz\ddaggerz\ddotsz\degz\detz \diagdownz\diagupz \diameterz\diamondz \diamondsuitz\dimz\divz\divideontimesz\dotdivz\doteqz \doteqdotz\dotplusz\dotsz\doublebarwedgez \downarrowz\downdownarrowsz\downharpoonleftz\downharpoonrightz\dsubz\earthz \eighthnotez\ellz \emptysetz\eqcircz\eqcolonz\eqsimz\euroz\existsz\expz\fallingdotseqz\fcmpz\femalez\flatz\forallz\fourthz\frownz\frowniez\gcdz\geminiz\geq)z\geqqz \geqslantz\getsz\ggz\gggz\gimelz\gneqqz\gnsimz\gtrdotz \gtreqlessz \gtreqqlessz\gtrlessz\gtrsimz\guillemotleftz\guillemotrightz\hbarz \heartsuitz\hfillz\homz\hookleftarrowz\hookrightarrowz\hslashz \idotsintz\iiintz\iintz\imathz\infz\inftyz \intercalz \interleavez\invampz\invnegz\jmathz\jupiterz\kerz\landz \landupintz\langz\langlez\lblotz\lbracez\lbrace)z\lbrackz\lceilz\ldotsz\leadstoz \leftarrow)z\leftarrowtailz\leftarrowtobarz\leftharpoondownz\leftharpoonupz\leftleftarrowsz\leftleftharpoonsz \leftmoonz\leftrightarrowz\leftrightarrowsz\leftrightharpoonsz\leftthreetimesz\leoz\leq)z\leqqz \leqslantz\lessdotz \lesseqgtrz \lesseqqgtrz\lessgtrz\lesssimz\lfloorz\lgz\lgroupz\lhdz\libraz \lightningz\limgz\liminfz\limsupz\llz \llbracketz \llcornerz\lllz\lnz\lneqqz\lnotz\lnsimz\logz\longleftarrowz\longleftrightarrowz \longmapstoz\longrightarrowz\looparrowleftz\looparrowrightz\lorz\lozengez \lrcornerz\ltimesz\lyxlockz\malez\maltesez \mapsfromz\mapstoz\mathcircumflexz\maxz\measuredanglez \medbulletz\medcircz\mercuryz\mhoz\midz\minz\modelsz\mpz \multimapz \nLeftarrowz\nLeftrightarrowz \nRightarrowz\nVDashz\nablaz\napproxz\naturalz\ncongz\nearrowz\negz\neg)z\neptunez\nequivz\newlinez\nexistsz \ngeqslantz\ngtrz \ngtrlessz\niz\ni)z \nleftarrowz\nleftrightarrowz \nleqslantz\nlessz \nlessgtrz\nmidz \nolimitsz \nonumberz\notz\notz \notbackslashz\notinz\notniz \notslashz \nparallelz\nprecz \nrightarrowz\nsimz\nsimeqz \nsqsubsetz \nsubseteqz\nsuccz \nsucccurlyeqz\nsupsetz \nsupseteqz\ntriangleleftz\ntrianglelefteqz\ntrianglerightz\ntrianglerighteqz\nvDashz\nvdashz\nwarrowz\odotz \officialeuroz\oiiintz\oiintz\ointz\ointclockwisez\ointctrclockwisez\ominusz\oplusz\oslashz\otimesz\ownsz \parallelz\partialz\pencilz\perpz\piscesz \pitchforkz\plutoz\pmz\pointerz \pointrightz\poundsz\precz \preccurlyeqz\preceqz\precsimz\primez\promptoz\qoppaz\qquadz\quadz \quarternotez \radiationz\rangz\ranglez\rblotz\rbracez\rbrace)z\rbrackz\rceilz\recyclez\rfloorz\rgroupz\rhdz \rightanglez \rightarrow)z\rightarrowtailz\rightarrowtobarz\rightharpoondownz\rightharpoonupz\rightharpooondownz\rightharpooonupz\rightleftarrowsz\rightleftharpoonsz \rightmoonz\rightrightarrowsz\rightrightharpoonsz\rightthreetimesz\rimgz \risingdotseqz \rrbracketz\rsubz\rtimesz \sagittariusz\saturnz\scorpioz\searrowz\secz\secondz \setminusz\sharpz\simeqz\sinz\sinhz\sixteenthnotez\skullz\slashz\smallsetminusz\smalltriangledownz\smalltriangleleftz\smalltrianglerightz\smalltriangleupz\smilez\smileyz \spadesuitz\spddotz\sphatz\sphericalanglez\spotz\sptildez\sqcapz\sqcupz \sqsubsetz \sqsubseteqz \sqsupsetz \sqsupseteqz\squarez\sslashz\starz \steamingz \subseteqqz \subsetneqqz\succz \succcurlyeqz\succeqz \succnsimz\succsimz\sunz\supz \supseteqqz \supsetneqqz\surdz\swarrowz\swordsz \talloblongz\tanz\tanhz\taurusz\textasciicircumz\textasciitildez\textbackslashz\textcopyrightz \textdegreez \textellipsisz \textemdashz \textendashz \texteuroz \textgreaterz \textlessz\textordfemininez\textordmasculinez\textquotedblleftz\textquotedblrightz\textquoterightz\textregisteredz\textrightarrowz \textsectionz\texttrademarkz\texttwosuperiorz\textvisiblespacez \thereforez\thirdz\topz \trianglez \triangleleftz\trianglelefteqz \triangleqz\trianglerightz\trianglerighteqz\twoheadleftarrowz\twoheadrightarrowz \twonotesz\udotz \ulcornerz\unlhdz\unrhdz\unrhlz\uparrowz \updownarrowz\upharpoonleftz\upharpoonrightz\uplusz \upuparrowsz\uranusz \urcornerz\vDashz \varclubsuitz\vardiamondsuitz \varheartsuitz \varnothingz \varspadesuitz\vdashz\vdotsz\veez\vee)z\veebarz\vertz\virgoz\warningz \wasylozengez\wedgez\wedge)z\wpz\wrz\yenz\yinyangz\{z\|z\})z\overleftarrowz\overrightarrowz\widehatz\]z\end{)bracketcomplexendafter endbefore squarebracketrlc)ZalignZeqnarrayZgatheredbzspan class="blackboard"u𝔸u𝔹uℂu𝔻u𝔼u𝔽u𝔾uℍu𝕁u𝕂u𝕃uℕu𝕆uℙuℚuℝu𝕊u𝕋u𝕎uℤzspan class="scriptfont"uℬuℰuℱuℋuℐuℒuℳuℛzspan class="fraktur"uℭu𝔉uℌuℨiuŮuůuẘuẙzspan class="mathrm"zspan class="mathsf"tt):z \boldsymbolz\mathbbz \mathbb{A}z \mathbb{B}z \mathbb{C}z \mathbb{D}z \mathbb{E}z \mathbb{F}z \mathbb{G}z \mathbb{H}z \mathbb{J}z \mathbb{K}z \mathbb{L}z \mathbb{N}z \mathbb{O}z \mathbb{P}z \mathbb{Q}z \mathbb{R}z \mathbb{S}z \mathbb{T}z \mathbb{W}z \mathbb{Z}z\mathbfz\mathcalz \mathcal{B}z \mathcal{E}z \mathcal{F}z \mathcal{H}z \mathcal{I}z \mathcal{L}z \mathcal{M}z \mathcal{R}z \mathfrakz \mathfrak{C}z \mathfrak{F}z \mathfrak{H}z \mathfrak{I}z \mathfrak{R}z \mathfrak{Z}z\mathitz \mathring{A}z \mathring{U}z \mathring{a}z \mathring{u}z \mathring{w}z \mathring{y}z\mathrmz\mathscrz \mathscr{B}z \mathscr{E}z \mathscr{F}z \mathscr{H}z \mathscr{I}z \mathscr{L}z \mathscr{M}z \mathscr{R}z\mathsfz\mathttz{$p!}{$q!}{$r!}zf0{}ignoredz {$p!}{$q!}z{$1}{$2}zf2{(}f0{f1{$1}f1{$2}}f2{)}zspan class="binom"zspan class="binomstack"zspan class="bigsymbol"z{$1}zf0{$1}zspan class="boxed"z [$p!]{$1}{$2}z!f0{f3{(}f1{$1}f3{)/(}f2{$2}f3{)}}zspan class="fullfraction"zspan class="numerator align-$p"zspan class="denominator"zspan class="ignored"z {$p!}{$1}zspan style="color: $p;"z-span class="colorbox" style="background: $p;"u%(f0{f1{f2{$1}}f1{f2{ }}f1{f2{$2}}})zspan class="binomial"zspan class="binomrow"zspan class="binomcell"zspan class="numerator"zspan class="displaystyle"z [$p!]{$q!}zspan class="fbox"z{$p!}z{$p!}{$q!}{$1}zg0d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPgdQZdRS)S HeaderConfigz+Configuration class from elyxer.config filez\begin_preamblez\branchz \textclassz \end_branchz \end_preamblez \languagez\lstsetz\output_changesz\paragraph_separationz \pdf_titlez \secnumdepthz \tocdepth) beginpreamblebranchZ documentclass endbranch endpreamblelanguagelstset outputchangesZparagraphseparationpdftitleZ secnumdepthtocdeptharticleZaastexZaapaperZ acmsiggraphZ sigplanconfZachemsoZamsartZapaz arab-articlezarmenian-articlezarticle-beamerZchessZdtkZ elsarticlez heb-articleZIEEEtranZiopartZkluwerzscrarticle-beamerZscrartclZ extarticleZpaperZmwartZrevtex4ZspieZ svglobal3Zltugboatzagu-dtdZjgrgaZagumsZentcsZegsZijmpcZijmpdz singlecol-newz doublecol-newZisprsZtarticleZ jsarticleZjarticleZjsszliterate-articleZsiamltexZcl2emultZllncsZsvglobalZsvjogZsvprobthbookZamsbookZscrbookZextbookz tufte-bookreportZ extreportZscrreprtZmemoirZtbookZjsbookZjbookZmwbkZsvmonoZsvmultZtreportZjreportZmwrep)r r N)rrrr parametersZstylesr r r r rsbrc@s6eZdZdZddddZddddZd d d gd Zd S) ImageConfigz+Configuration class from elyxer.config filezOconvert[ -density $scale][ -define $format:use-cropbox=true] "$input" "$output"z(inkscape "$input" --export-png="$output"zlyx -C "$input" "$output") imagemagickZinkscapeZlyxZpsZpdf)z.epsz.pdfz.psz.pngz.svgz.eps)r ZvectorN)rrrr convertersZcropboxformatsformatsr r r r r 2s  r c @s0eZdZdZdddddddd d d d d dg iZdS) LayoutConfigz+Configuration class from elyxer.config filerQr<r=r@r)r:r0r;r*r8r/rBrCN)rrrrZ groupabler r r r rDsrc@s eZdZdZddddddZdS) NewfangleConfigz+Configuration class from elyxer.config filez chunkref{rz>rjz=<)ZchunkrefZ endcommandZendmarkriZ startmarkN)rrrr constantsr r r r rLsrc @sDeZdZdZdddddgddgd Zd d d d dddddddg iZdS)NumberingConfigz+Configuration class from elyxer.config fileChapterSection Subsection Subsubsection ParagraphPartBook)orderedromansymbolsrz**u†u‡ru§§ru¶¶rz##N)rrrrlayoutssequencer r r r rTs  rc@seZdZdZdddddddddddd Zd d d d ddddd d d d dddddddddddZdddddddd Zd!d"d#d$d%d&d'giZd(d)d*d+d,d-Zd.S)/ StyleConfigz+Configuration class from elyxer.config fileu z u r!u  rtu ) z \enskip{}z\hfill{}z\hspace*{\fill}z \hspace*{}z \hspace{}z\negthinspace{}z\qquad{}z\quad{}z\space{}z \thinspace{}rru›ru‹z“z‘z”z’u„u‚u“u‘u”u’)ZaldZalsZardZarsZeldZelsZerdZersZfldZflsZfrdZfrsZgldZglsZgrdZgrsZpldZplsZprdZprssldZsrdu(@↕)u¶↕u$↕u#↕u@↕u on-page#↕u @on-page#↕)Zeqref formattedZnamerefZpagerefrefZvpagerefZvref ignoredtextscoltextlinepageZtheightZpheightz
z
z
z
z
)ZbigskipZdefskipZmedskipZ smallskipZvfillN) rrrrhspacesquotesreferenceformatssizevspacesr r r r r!as$      r!c @sfeZdZdZdddddddd d d d d g dgdgdZdddgdddd d d d d gddddddgdZdS) TOCConfigz+Configuration class from elyxer.config filer<r=r@r)r:r0r;r*r8r/rBrCr!)rQrRrSr^r?rArbrXN)rrrrZ extractplainZ extracttitler r r r r/s r/c @seZdZdZddiZdddZddddd d d Zd d dgiZddddddddddd ZdddZ ddddZ dddZ dddd Z d!S)" TagConfigz+Configuration class from elyxer.config fileZunderrzspan class="sans"r)ZsansZ typewriterzspan class="code"zspan class="menuitem"zspan class="noun"zspan class="strong")zCharStyle:CodezCharStyle:MenuItemZCodeZMenuItemZNounZStrongr QuotationQuotedivzh?h2h1 blockquote) ZCenterrDaterrr1r2rrrolul)Z EnumerateZItemizer!zspan class="greyedout")CommentZ Greyedoutr[rr) subscript superscriptrzspan class="versalitas")ZitalicZslantedZ smallcapsN) rrrrbarredfamilyZflexgroupr listitemsZnotesscriptshapedr r r r r0s       r0c%@sveZdZdZdddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&$Zd'd'd(d)d'd*d(d+d,d- Zd.S)/TranslationConfigz+Configuration class from elyxer.config fileAppendixrrrrrrrr_r`figurez Algorithm zFigure zListing zTable zTableau Z FootnoteszDocument generated by z on Indexz)Please enable JavaScript on your browser.zH requires JavaScript to correctly process the mathematics on this page. z Warning: zList of AlgorithmszList of FigureszList of TableszList of Tableauxz Main pageZNextZ Nomenclaturez on page ZPrevZ ReferenceszTable of Contentsz Contents for ZUp)$rDrrrrrrrZabstract bibliographyrEzfloat-algorithmz float-figurez float-listingz float-tablez float-tableau footnotesz generated-byz generated-onindexz jsmath-enablezjsmath-requireszjsmath-warningzlist-algorithmz list-figurez list-tablez list-tableauz main-pagenextZ nomenclaturezon-pageprev referencestocztoc-forZupendenlfrrues) americanZbritishdeutschdutchenglishfrenchZngermanrussianspanishN)rrrrr languagesr r r r rCs* rCc@s8eZdZdZddZddZddZdd Zd d Zd S) CommandLineParserzA parser for runtime optionscCs ||_dS)N)options)selfr]r r r __init__szCommandLineParser.__init__cCspt|dkrdSxZt|dkrj|ddrj||\}}|sJd|dS|sZd|dSt|j||qWdS)zParse command line optionsrNz--zOption z not recognizedz needs a value)len startswith readoptionsetattrr])r^argskeyvaluer r r parseoptionss   zCommandLineParser.parseoptionscCs|ddd}|d=d|kr,|||}n |dd}t|j|sLd|fSt|j|}t|trj|dfSt|dkr~|dfS|ddr|d}|d=|| ||fS|d d }|d=t|t r| |||fS||fS) z$Read the key and value for an optionrNrrur!Trzutf-8) readequalskeyreplacehasattrr]getattr isinstanceboolr`ra readquoteddecodelistappend)r^rdrrecurrentinitialrfr r r rbs,       zCommandLineParser.readoptioncCstd|dd}xTt|dkrj|ddsj|ddsjtd|d|d|d7}|d=qWt|dks|ddrdS|d|dd 7}|S) zRead a value between quotesZOopsNrrz--z Appending rr)rrr`endswithra)r^rdrtrfr r r ros  * zCommandLineParser.readquotedcCs,|dd}|d}|d}|d||S)zRead a key using equalsrrur)splitinsert)r^rrdrwrerfr r r ris   zCommandLineParser.readequalskeyN) rrrrr_rgrbrorir r r r r\s   r\c@s*eZdZdZdZdZdZdZdZdZ dZ dZ dZ dZ dZdZdZdZgZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5gZ6e7Z8ddZ9d d Z:d d Z;d dZddZ?ddZ@ddZAdS)OptionszA set of runtime optionsNFTr!rcCsD|dt_|d=tt}||}|r8t|||dS)zParse command line optionsrN)rylocationr\rgrrusageprocessoptions)r^rdparserresultr r r rg`s   zOptions.parseoptionsc Cstjr|tjr|tjr*|tjr8|tj rF| tj ry,t tj t_ tj dkrvt d|Wn$t dtj |YnXtjstjstjrdt_|tjrtjstjt_tjdkrdt_tjgkrdgt_tjdkrtjr dt_tjr.tjs.t d tjt_tjr@t d tjrRt d x8tt D],}|d r\t t |t!||d dq\Wd S)zProcess all options parsed.rz.--splitpart requires a number bigger than zeroz*--splitpart needs a numeric argument, not FcopyTz http://elyxer.nongnu.org/lyx.cssr!z7Option --toc is deprecated; use --tocfor "page" insteadz5Option --nocopy is deprecated; it is no longer neededz4Option --jsmath is deprecated; use --mathjax insteadmodeN)"ryhelpr{r showversion hardversionshowhardversion versiondateshowversiondater showlyxformat splitpartintrrlowmemrMtocformemoryparsefootnotes forceformat imageformat copyimagescssfaviconr} simplemath toctargetnocopyjsmathdirrvrcrl)r^paramr r r r|ksR            zOptions.processoptionscCsFtdtjtjdtdtdtd|dS)zShow correct usagezUsage: z [options] [filein] [fileout]z7Convert LyX input file "filein" to HTML file "fileout".zCIf filein (or fileout) is not given use standard input (or output).z?Main program of the eLyXer package (http://elyxer.nongnu.org/).N)rrospathbasenameryrz showoptions)r^r r r r{s    z Options.usagecCstjs dSdt_dt_dt_tjd}x:|D]2}|d}tt|rRtt|dq.t d|q.Wtj s|tjs|tjs|dt_tj stj sdt_dS)zParse footnotes options.NFrZfootTzUnknown footnotes option: ) ryrH marginfoot letterfoot hoverfootrwrkrcrrendfoot numberfoot symbolfoot)r^r]optionZ footoptionr r r rs    zOptions.parsefootnotescCstdtdtdtdtdtdtdtdtd td td td td tdtdtdtdtdtdtdtdtdtdtdtdtdtdtdtdtdtdtd td!td"td#td$td%td&td'td(td)td*td+td,td-td.td/td0td1td2td3td4td5S)6zShow all possible optionsz Common options:z1 --help: show this online helpz9 --quiet: disables all runtime messagesr!z Advanced options:zF --debug: enable debugging messages (for developers)z@ --version: show version number and release datezD --lyxformat: return the highest LyX version supportedz Options for HTML output:z8 --title "title": set the generated page titlez1 --css "file.css": use a custom CSS filezH --embedcss "file.css": embed styles from a CSS file into the outputzG --favicon "icon.ico": insert the specified favicon in the header.zH --html: output HTML 4.0 instead of the default XHTMLz/ --unicode: full Unicode outputzG --iso885915: output a document with ISO-8859-15 encodingzC --nofooter: remove the footer "generated by eLyXer"zD --simplemath: do not generate fancy math constructionsz Options for image output:zF --directory "img_dir": look for images in the specified directoryzD --destdirectory "dest": put converted images into this directoryzI --imageformat ".ext": image output format, or "copy" to copy imageszL --noconvert: do not convert images, use in original locationszH --converter "inkscape": use an alternative program to convert imagesz Options for footnote display:zJ --numberfoot: mark footnotes with numbers instead of letterszB --symbolfoot: mark footnotes with symbols (*, **...)zE --hoverfoot: show footnotes as hovering text (default)z= --marginfoot: show footnotes on the page marginzA --endfoot: show footnotes at the end of the pagezJ --supfoot: use superscript for footnote markers (default)zA --alignfoot: use aligned text for footnote markerszM --footnotes "options": specify several comma-separated footnotes optionszJ Available options are: "number", "symbol", "hover", "margin", "end",z "sup", "align"z Advanced output options:zJ --splitpart "depth": split the resulting webpage at the given depthzH --tocfor "page": generate a TOC that points to the given pagezC --target "frame": make all links point to the given framezL --notoclabels: omit the part labels in the TOC, such as ChapterzJ --lowmem: do the conversion on the fly (conserve memory)zC --raw: generate HTML without header or footer.zE --mathjax remote: use MathJax remotely to display equationszO --mathjax "URL": use MathJax from the given URL to display equationszH --googlecharts: use Google Charts to generate formula imageszM --template "file": use a template, put everything in z@ --copyright: add a copyright notice at the bottomz Deprecated options:zC --toc: (deprecated) create a table of contentszJ --toctarget "page": (deprecated) generate a TOC for the given pagezO --nocopy: (deprecated) maintained for backwards compatibilityzN --jsmath "URL": use jsMath from the given URL to display equationsN)rrrr)r^r r r rsj                                                    zOptions.showoptionscCs:dtjd}|dtjdd7}t|tdS)z(Return the current eLyXer version stringzeLyXer version rz (rrN)rrrrrr)r^ror r r rs zOptions.showversioncCsttjdtdS)zReturn just the version stringrN)rr rrrr)r^r r r rszOptions.showhardversioncCsttjdtdS)zReturn just the version dterN)rr rrrr)r^r r r rszOptions.showversiondatecCsttjdtdS)z#Return just the lyxformat parameterrN)rr rrrr)r^r r r rszOptions.showlyxformat)Brrrrinstancerzr copyrightr quietrrrr}rZ showlinesstrr~rrtitle directoryZ destdirectoryrMrrrrtargetrrrZnobib converterrawrmathjaxZnofooterrtemplateZ noconvertZ notoclabelsrrrrrrZsupfootZ alignfootrHrrrZembedcssdictbranchesrgr|r{rrrrrrr r r r ry&s| .8ryc@s0eZdZdZddZddZddZdd Zd S) BranchOptionszA set of options for a branchcCs||_ddi|_dS)Ncolorz#ffffff)namer])r^rr r r r_szBranchOptions.__init__cCsB|tjds"td|dS|tjdd}||j|<dS)zSet a branch optionrizInvalid branch option Nr!)rar(rorrrjr])r^rerfr r r set s zBranchOptions.setcCsd|jkrdS|jddkS)z Return if the branch is selectedselectedF1)r])r^r r r isselecteds zBranchOptions.isselectedcCsd|jdt|jS)zString representationz options for z: )rrr])r^r r r __unicode__szBranchOptions.__unicode__N)rrrrr_rrrr r r r rs rc@s0eZdZdZddZddZeeZeeZdS)Clonerz&An object used to clone other objects.cCs ||jS)z"Return an exact copy of an object.)create __class__)roriginalr r r clone*sz Cloner.clonecCs||}||S)z"Create an object of a given class.)__new__r_)rtyperr r r r/s z Cloner.createN)rrrrrrrr r r r r's rc@s0eZdZdZddZddZddZdd Zd S) ContainerExtractorz&A class to extract certain containers.cCs"|d|_|d|_|d|_dS)zTThe config parameter is a map containing three lists: allowed, copied and extracted.rQrRrSN)rQrRrS)r^configr r r r_;s  zContainerExtractor.__init__cs<gfdd}fdd}fdd}||||S)z?Extract a group of selected containers from elyxer.a container.cs|jjjjkS)N)rrrQrR)r)r^r r Iz,ContainerExtractor.extract..cs|jjjkS)N)rrrS)r)r^r r rJrcs |S)N)process)r)rqr^r r rKr)recursivesearch)r^ containerlocate recursiverr )rqr^r extractFs   zContainerExtractor.extractcCsL|jj}||jkr||n*||jkr:|||ntd|dS)zBAdd allowed containers, clone cloned containers and add the clone.zUnknown container class N)rrrQrrrR safeclonerr)r^rrqrr r r rOs    zContainerExtractor.processcCs"t|}|j|_|||_|S)zFReturn a new container with contents only in a safe list, recursively.)rroutputrcontents)r^rrr r r rYs  zContainerExtractor.safecloneN)rrrrr_rrrr r r r r8s    rc@sHeZdZdZddZddZddZdd Zd d Zd d Z ddZ dS)ParserzA generic parsercCsd|_t|_dS)Nr)rrr )r^r r r r_hszParser.__init__cCs |}||j|_|S)zParse the header) currentlinerwnextline linenumberr)r^readerheaderr r r parseheaderls zParser.parseheadercCs|dr.||\}}||j|<dS|dd}|t|dkrZdS|d}t|dkr|d|j|<dSd|dkr|d|j|<dS|dd}|d|j|<dS)zParse a parameterrxNrrurTr)rstripraparsexmlr rwrr`)r^rrerfrwZ doublesplitr r r parseparameterss"     zParser.parseparameterc Cs|}||ds0td|d|dd}t|dkrZtddS|d}|d=t|dkr~|tfSt}x^|D]V}d |krtd |d ||d 7}|d }|d}|dd d} | ||<qW||fS)z5Parse a parameter in xml form: ryzXML parameter z should be <...>rurrzEmpty XML parameter <>)NNrzErroneous attribute for z: z="0"r) rrrrvrrrwr`r) r^rrrwreattrsattrpartsZattrkeyrfr r r rs,         zParser.parsexmlcCs<|jstdt|dSx||js6|qWdS)z'Parse until the current ending is foundzNo ending for N)endingrrrrra)r^rrr r r parseendings zParser.parseendingcCs&|j|}|r"|j|_||dS)N)factorycreatecontainerparentrr)r^rrrr r r parsecontainers zParser.parsecontainercCs|jjdt|jdS)zReturn a descriptionz (r)rrrr)r^r r r rszParser.__unicode__N) rrrrr_rrrrrrr r r r resrc@seZdZdZddZdS) LoneCommandz"A parser for just one command linecCsgS)z Read nothingr )r^rr r r parseszLoneCommand.parseN)rrrrrr r r r rsrc@s,eZdZdZgZddZddZddZdS) TextParserz(A parser for a command and a bit of textcCs8t|d|_|jjtjkr.tj|jj|_g|_dS)N)rr_rrrr(rl)r^rr r r r_s  zTextParser.__init__cCsRtj|jtjtjdtjd|jg|_g}x||sL|||q4W|S)z$Parse lines as long as they are textr3r2)rstackrrrr(rlisendingr)r^rrr r r rs  zTextParser.parsecCsX|}t|dkrdS|d|jkrT|dtjkrJtj|dngt_dSdS)zCheck if text is endingrFT)rrwr`rlrrremove)r^rrsr r r rs  zTextParser.isendingN)rrrrrr_rrr r r r rs  rc@seZdZdZddZdS)ExcludingParserz%A parser that excludes the final linecs gfddS)z5Parse everything up to (and excluding) the final linecs S)N)rr )rrr^r r rrz'ExcludingParser.parse..)r)r^rr )rrr^r rszExcludingParser.parseN)rrrrrr r r r rsrc@seZdZdZddZdS) BoundedParserzA parser bound by a final linecCst||}||S)z*Parse everything, including the final line)rrr)r^rrr r r rs zBoundedParser.parseN)rrrrrr r r r rsrc@seZdZdZddZdS) BoundedDummyz&A bound parser that ignores everythingcs |fddgS)z#Parse the contents of the containercsS)N)rr )rr r rrz$BoundedDummy.parse..)rr)r^rr )rr rszBoundedDummy.parseN)rrrrrr r r r rsrc@s eZdZdZddZddZdS) StringParserzParses just a stringcCs|jd|_gS)zDo nothing, just take noteru)rr)r^rr r r rs zStringParser.parseheadercCs|}||S)zParse a single line)rr)r^rrr r r rszStringParser.parseN)rrrrrrr r r r rsrc@seZdZdZddZdS) InsetParserzParses a LyX insetcCs@tjd}x(|dkr2||s2||q Wt||S)z(Parse inset parameters into a dictionaryrir!)r(rorrarrr)r^rrir r r r s zInsetParser.parseN)rrrrrr r r r rsrc@s eZdZdZddZddZdS)ContainerOutputz(The generic HTML output for a container.cCstdt|dS)zShow an error.zgethtml() not implemented for N)rrr)r^rr r r gethtmlszContainerOutput.gethtmlcCsdS)z5Decide if the output is empty: by default, not empty.Fr )r^r r r isemptyszContainerOutput.isemptyN)rrrrrrr r r r rsrc@seZdZddZddZdS) EmptyOutputcCsgS)zReturn empty HTML code.r )r^rr r r r#szEmptyOutput.gethtmlcCsdS)z"This output is particularly empty.Tr )r^r r r r'szEmptyOutput.isemptyN)rrrrrr r r r r!src@seZdZdZddZdS) FixedOutputz Fixed outputcCs|jS)zReturn constant HTML code)r})r^rr r r r.szFixedOutput.gethtmlN)rrrrrr r r r r+src@seZdZdZddZdS)ContentsOutputz&Outputs the contents converted to HTMLcCs^g}|jdkr|SxF|jD]<}t|dsJtd|jjdt||S||7}qW|S)zReturn the HTML codeNrz No html in z: )rrkrrrrrr)r^rr}elementr r r r5s   zContentsOutput.gethtmlN)rrrrrr r r r r2src@sVeZdZdZdZdZdZdddZddZdd Z d d Z d d Z ddZ ddZ dS) TaggedOutputz-Outputs an HTML tag surrounding the contents.NFcCs||_|r||_|r||_|S)z/Set the value for the tag and other attributes.)tag breaklinesempty)r^rrrr r r settagHs zTaggedOutput.settagcCs ||_|S)zSet the value for breaklines.)r)r^rr r r setbreaklinesQszTaggedOutput.setbreaklinescCsB|jr||gS||g}|t||7}||||S)zReturn the HTML code.)r selfclosingopenrrrrclose)r^rr}r r r rVs   zTaggedOutput.gethtmlcCs,|s dSd|jd}|jr(|dS|S)zGet opening line.r!rxryr)checktagrr)r^rrr r r r_s zTaggedOutput.opencCs8|s dSd|jdd}|jr4d|dS|S)zGet closing line.r!zr)rrr)r^rrr r r rqs zTaggedOutput.selfclosingcCs.|jstdttdS|jdkr*dSdS)zCheck that the tag is valid.z No tag in Fr!T)rrrrr)r^r r r rzs  zTaggedOutput.checktag)FF)rrrrrrrrrrrrrrr r r r rAs     rc@s0eZdZdZddZddZddZdd Zd S) FilteredOutputz1Returns the output in the contents, but filtered:cCs g|_dS)zInitialize the filters.N)filters)r^r r r r_szFilteredOutput.__init__cCs|j||fdS)z:Add a new filter: replace the original by the replacement.N)rrr)r^r replacementr r r addfilterszFilteredOutput.addfiltercCs2g}t||}x|D]}|||qW|S)zReturn the HTML code)rrrrfilter)r^rr~r}r(r r r rs   zFilteredOutput.gethtmlcCs,x&|jD]\}}||kr|||}qW|S)z0Filter a single line with all available filters.)rrj)r^r(rrr r r rszFilteredOutput.filterN)rrrrr_rrrr r r r rs rc@seZdZdZddZdS) StringOutputzReturns a bare string as outputcCs|jgS)zReturn a bare string)ro)r^rr r r rszStringOutput.gethtmlN)rrrrrr r r r rsrc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS) LineReaderzReads a file line by linecCst|tr||_nt|dd|_d|_d|_d|_d|_d|_y | Wn2t k r~ddl }||d|_| YnXdS)NZrUzutf-8ruTFrrb) rmfilecodecsrrlastlinersmustreaddepletedreadlineUnicodeDecodeErrorgzip)r^filenamer r r r r_s  zLineReader.__init__cCs&xt|D]}|jq W||_dS)zSet the first line to read.N)rangerr r)r^ firstlinerr r r setstartszLineReader.setstartcCs ||_dS)zSet the last line to read.N)r)r^rr r r setendszLineReader.setendcCs|jr||jS)zGet the current line)rr rs)r^r r r rszLineReader.currentlinecCs|jrtdd|_dS)zGo to next linezRead beyond file endTN)r rrr)r^r r r rs zLineReader.nextlinecCs|j|_t|jtjs(|jd|_t|jdkrGlob a bit of text that satisfies a check on the current char.r!)rr)r^Z currentcheckglobr r r r%Hsz Globable.globcsfddS)zGlob a bit of alpha textcs S)N)rsisalphar )r^r r rQrz$Globable.globalpha..)r%)r^r )r^r globalphaOszGlobable.globalphacsfddS)zGlob a row of digits.cs S)N)rsisdigitr )r^r r rUrz%Globable.globnumber..)r%)r^r )r^r globnumberSszGlobable.globnumbercCs |s|dkrdSdS)z5Return if the current character is alphanumeric or _.rTF)rsisalnum)r^r r r isidentifierWszGlobable.isidentifiercCs ||jS)z Glob alphanumeric and _ symbols.)r%r+)r^r r r globidentifier]szGlobable.globidentifiercCs$|rdS|dkr dSdS)z5Return if the current character is a value character:Fz{}()T)rsisspace)r^r r r isvalueas   zGlobable.isvaluecCs ||jS)z'Glob a value: any symbols but brackets.)r%r.)r^r r r globvaluejszGlobable.globvaluecsfddS)z(Skip all whitespace at current position.cs S)N)rsr-r )r^r r rprz$Globable.skipspace..)r%)r^r )r^r skipspacenszGlobable.skipspacecs&fdd}|S)z4Glob a bit of text up to (including) the magic char.cs kS)N)rsr ) magiccharr^r r rtrz(Globable.globincluding..)r%skip)r^r1r%r )r1r^r globincludingrs zGlobable.globincludingcsfddS)z?Glob a bit of text up until (excluding) any excluded character.cs kS)N)rsr )excludedr^r r rzrz(Globable.globexcluding..)r%)r^r4r )r4r^r globexcludingxszGlobable.globexcludingcCs|j||dS)zPush a new ending to the bottomN)radd)r^roptionalr r r pushending|szGlobable.pushendingNcCsN|r|jr|S|j|}|r@||kr@td|d||||S)z,Pop the ending found at the current positionzExpected ending z, got )r r"rpoprrr2)r^expectedrr r r popendings   zGlobable.popendingcCs|j|}|sdS|jS)z$Return the next ending in the queue.N)r findendingr)r^ nextendingr r r r=s zGlobable.nextending)F)N)rrrrr"r_rr rsr!rrr%r'r)r+r,r.r/r0r3r5r8r;r=r r r r rs,   rc@sReZdZdZddZdddZddZd d Zd d Zd dZ ddZ ddZ dS)rzA list of position endingscCs g|_dS)N)rl)r^r r r r_szEndingList.__init__FcCs|jt||dS)zAdd a new ending to the listN)rlrrPositionEnding)r^rr7r r r r6szEndingList.addcCs|j|jj7_dS)z/Pick any pending endings from a parse position.N)rlr)r^posr r r pickpendingszEndingList.pickpendingcCs||rdSdS)zSearch for an endingTF)r<)r^r?r r r r$s zEndingList.checkincCs|rtddS||}|s:td|dSx@t|jD]2}|j|||krd|jS|j sFtd|qFWtddS)z)Remove the ending at the current positionzNo ending out of boundsr!z No ending at zRemoved non-optional ending zNo endings left) r rrr<rsreversedrlrrr7)r^r?rZeachr r r r9s    zEndingList.popcCsJt|jdkrdSx2tt|jD] \}}||r8|S|js"dSq"WdS)z'Find the ending at the current positionrN)r`rl enumeraterAr$r7)r^r?rIrr r r r<s zEndingList.findendingcCs(t|jdkr$tdt|ddS)z&Check if there are any pending endingsrzPending z left openN)r`rlrrr)r^r r r r#szEndingList.checkpendingcCsFd}x|jD]}|t|d7}q Wt|jdkr>|dd}|dS)zPrintable representationz endings [rrNrr)rlrr`)r^rorr r r rs   zEndingList.__unicode__N)F) rrrrr_r6r@r$r9r<r#rr r r r rs  rc@s(eZdZdZddZddZddZdS) r>z An ending for a parsing positioncCs||_||_dS)N)rr7)r^rr7r r r r_szPositionEnding.__init__cCs ||jS)zCheck for the ending)r!r)r^r?r r r r$szPositionEnding.checkincCsd|j}|jr|d7}|S)zPrintable representationzEnding z (optional))rr7)r^ror r r rs zPositionEnding.__unicode__N)rrrrr_r$rr r r r r>sr>c@s`eZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ dS)PositionzA position in a text to parse. Including those in Globable, functions to implement by subclasses are: skip(), identifier(), extract(), isout() and current().cCst|dS)N)rr_)r^r r r r_szPosition.__init__cCstddS)z Skip a stringzUnimplemented skip()N)rr)r^ror r r r2sz Position.skipcCstddS)z.Return an identifier for the current position.zUnimplemented identifier()Error)rr)r^r r r identifiers zPosition.identifiercCstddS)zHExtract the next string of the given length, or None if not enough text,zUnimplemented extract()N)rr)r^lengthr r r rs zPosition.extractcCs||t|kS)z)Check for a string at the given position.)rr`)r^ror r r r!szPosition.checkforcCs0|t|}|sdS||t|kS)z!Check for a string in lower case.F)rr`lower)r^rorSr r r checkforlowerszPosition.checkforlowercCs|}|||S)z)Return the current character and skip it.)rsr2)r^rsr r r rs zPosition.skipcurrentcCs||S)z3Advance the position and return the next character.)rrs)r^r r r __next__ szPosition.__next__cCs||sdS||dS)z;Check for a string at the given position; if there, skip itFT)r!r2)r^ror r r checkskips  zPosition.checkskipcCst|d|dS)z2Show an error message and the position identifier.z: N)rrrE)r^r r r r rszPosition.errorN)rrrrr_r2rErr!rHrrIrJrr r r r rCsrCc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS) TextPositionz%A parse position based on a raw text.cCs"t|d|_||_|dS)z*Create the position from elyxer.some text.rN)rCr_r?r'r)r^r'r r r r_s zTextPosition.__init__cCs|jt|7_dS)zSkip a string of characters.N)r?r`)r^ror r r r2&szTextPosition.skipcCsFd}|j|t|jkr(t|j|j}d|j|j|j|dS)z&Return a sample of the remaining text.r)r?r`r')r^rFr r r rE*szTextPosition.identifiercCs|jt|jkS)z'Find out if we are out of the text yet.)r?r`r')r^r r r r 1szTextPosition.isoutcCs |j|jS)z6Return the current character, assuming we are not out.)r'r?)r^r r r rs5szTextPosition.currentcCs.|j|t|jkrdS|j|j|j|S)zHExtract the next string of the given length, or None if not enough text.N)r?r`r')r^rFr r r r9szTextPosition.extractN) rrrrr_r2rEr rsrr r r r rKsrKc@sXeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ dS) FilePositionz-A parse position based on an underlying file.cCs&t|t||_d|_|dS)z Create the position from a file.rN)rCr_rrr?r)r^r r r r r_Bs  zFilePosition.__init__cCs\t|}x@|j|t|jkrH|t|j|jd8}|q W|j|7_dS)zSkip a string of characters.ruN)r`r?rrr)r^rorFr r r r2Is  zFilePosition.skipcCs |jS)z,Get the current line of the underlying file.)rr)r^r r r rQszFilePosition.currentlinecCs|jd|_dS)zGo to the next line.rN)rrr?)r^r r r rUs zFilePosition.nextlinecCs |jjdS)z#Return the line number of the file.ru)rr)r^r r r rZszFilePosition.linenumbercCsL|jd|jd}|j|jd}dt|d|d|S)z4Return the current line and line number in the file.Nruzline z: r)rrr?rZ getlinenumber)r^beforeafterr r r rE^szFilePosition.identifiercCs`|jt|jkrV|jt|jdkrNtd|jdt|j||jS)z'Find out if we are out of the text yet.ruzOut of the line z: ) r?r`rrrrrrr)r^r r r r ds "zFilePosition.isoutcCsb|jt|jkrdS|jt|jkrRtd|jdt|jdS|j|jS)z6Return the current character, assuming we are not out.rzOut of the line z: r)r?r`rrrrr)r^r r r rsls "zFilePosition.currentcCs6|j|t|jkrdS|j|j|j|S)zHExtract the next string of the given length, or None if not enough text.N)r?r`rr)r^rFr r r ruszFilePosition.extractN) rrrrr_r2rrrrEr rsrr r r r rM?s rMc@seZdZdZdZdZdZddZddZddZ d d Z e j fd d Z d dZddZddZddZddZddZddZddZddZd*d d!Zd"d#Zd$d%Zd&d'Zd(d)ZdS)+ Containerz.A container for text and objects in a lyx fileNcCs t|_dS)N)rqr)r^r r r r_szContainer.__init__cCsdS)zProcess contentsNr )r^r r r rszContainer.processcCs4|j|}t|tr*td||g}||S)zGet the resulting HTMLz Raw string )rrrmrrr escapeall)r^r}r r r rs   zContainer.gethtmlcCshg}x^|D]V}tjr"||tj}tjrB||tj}||}ntjsV||tj}||q W|S)z=Escape all lines in an array according to the output options.) ryr}escaperqr~escapeentitiesrrrr)r^linesr~r(r r r rQs  zContainer.escapeallcCs>t|}|x$|D]}||kr||||}qW|S)z1Escape a line with replacements from elyxer.a map)rqkeyssortrj)r^r( replacementspiecespiecer r r rRs   zContainer.escapecCsd}t|}xv|st|dkrltt|}|dkrRttt|d}|d|ddd7}n ||7}|qW|S) z/Escape all Unicode characters to HTML entities.r!Z0xd835iz&#ruNr)rKrrrshexrJr)r^r(r~r? codepointr r r rSs   zContainer.escapeentitiescsg||fddS)z2Search for all embedded containers of a given typecs |S)N)rr)r)rqr r rrz%Container.searchall..) searchprocess)r^rr )rqr searchallszContainer.searchallcCs*||}x|D]}|jj|qW|S)z3Search for all containers of a type and remove them)r^rrr)r^rrqrr r r searchremoves  zContainer.searchremovecs|fdd|dS)z4Search for elements of a given type and process themcs t|S)N)rm)r)rr r rrz)Container.searchprocess..N) locateprocess)r^rrr )rr r]szContainer.searchprocesscCs0x*|jD] }|||||r||qWdS)z3Search for all embedded containers and process themN)rr`)r^rrrr r r r`s  zContainer.locateprocesscCs:x4|jD]*}||r"||||||r||qWdS)z,Perform a recursive search in the container.N)rr)r^rrrrr r r rs  zContainer.recursivesearchcCs0d}ttj|}x|D]}||j7}qW|S)z0Extract all text from elyxer.allowed containers.r!)rr(rmrro)r^r~rconstantr r r rms  zContainer.extracttextcCs|t|jkrdSt|j|dr&dSxJ|t|jkrp||j|rpd|j|_|j|j||j|q(W|j||dS)z*Group some adjoining elements into a groupNgroupedT)r`rrkrbrrr9rx)r^rIr?Z isingroupr r r r?s zContainer.groupcCsB|j|}|j|x&t|jdkr<|j||jqWdS)z)Remove a container but leave its contentsrN)rr9r`rx)r^rIrr r r rs  zContainer.removercCs8td|t|x|jD]}||dqWdS)zShow in a treez ruN)rr rrtree)r^levelrr r r rcs zContainer.treecCs||jkrdS|j|S)z)Get the value of a parameter, if present.N)r )r^rr r r getparameters zContainer.getparametercCs||}|sgS|dS)z7Get the value of a comma-separated parameter as a list.r)rerw)r^r paramtextr r r getparameterlist s zContainer.getparameterlistcCs(|j}x|r"|jrdS|j}qWdS)z&Check if the parent's output is empty.TF)rrr)r^rsr r r hasemptyoutput s   zContainer.hasemptyoutputcCs$|js|jjS|jjdt|jS)zGet a descriptionr)rrrr)r^r r r r szContainer.__unicode__)r)rrrrpartkeyrrr_rrrQrqr|rRrSr^r_r]r`rrmr?rrcrergrhrr r r r rP}s.    rPc@seZdZdZddZdS)rTz)A container that does not output anythingcCst|_t|_g|_dS)N)rr}rrr)r^r r r r_ szBlackBox.__init__N)rrrrr_r r r r rT srTc@seZdZdZddZdS)rdzRead the lyxformat commandcCsPt|jd}|dkr(tdt||ttjdkrLtdt|dS)zShow warning if version < 276ruiz(Warning: unsupported old format version rz(Warning: unsupported new format version N)rrrrrrr)r^rr r r r" s zLyXFormat.processN)rrrrrr r r r rd srdc@sDeZdZdZdZddZddZddZd d Zd d Z d dZ dS)r<zA container for a single stringNcCst|_t|_d|_dS)Nr!)rr}rrro)r^r r r r_/ szStringContainer.__init__cCs|jr||j|_d|_dS)z/Replace special chars from elyxer.the contents.N)parsedreplacespecialro)r^r r r r4 szStringContainer.processcCsf||tj}||}tjd|krbt|dkrb|jrLdt|jd}nd}t || |S)z,Replace all special chars from elyxer.a lineriruzUnknown command at z: zUnknown command: ) rRrqr| changeliner(ror`rrrrr)r^r(r'r r r r rk: s zStringContainer.replacespecialcCs2||tj}tjd|kr |S||tj}|S)Nri)rRrqrzr(ror{)r^r(r r r rlG s zStringContainer.changelinecCs|jS)zReturn all text.)ro)r^r r r rmN szStringContainer.extracttextcCsXd}|jr|dt|j7}d}t|jdkr6d}|d|jdd|dS) z"Return a printable representation.r<rz...r!z (Nr)rrr`ror)r^r~Zellipsisr r r rR szStringContainer.__unicode__) rrrrrjr_rrkrlrmrr r r r r<* s r<c@s eZdZdZddZddZdS)r=zA constant stringcCsg|_||_t|_dS)N)rrorr)r^r'r r r r__ szConstant.__init__cCs d|jS)Nz Constant: )ro)r^r r r rd szConstant.__unicode__N)rrrrr_rr r r r r=\ sr=c@s8eZdZdZdZddZd ddZd dd Zd d ZdS)r@zText inside a tagNcCst||_t|_dS)N)rr}rr)r^r r r r_l s zTaggedText.__init__FcCs||_||j_||j_|S)z&Complete the tagged text and return it)rrrr)r^rrrr r r completep szTaggedText.completecCst|}||g||S)z(Complete the tagged text with a constant)r=rn)r^r'rrrar r r raw szTaggedText.constantcCs,t|jdsdS|jjsdSd|jjdS)z"Return a printable representation.rzEmtpy tagged textzTagged zTagged : sz*FormulaBit.computesize..)r`rrr-)r^r r r computesize6 szFormulaBit.computesizecCs|j|jS)zReturn a copy of itself.)rr{r)r^r r r r= szFormulaBit.clonecCs|jjd|jS)zGet a string representationz read in )rrr)r^r r r rA szFormulaBit.__unicode__)rrrrrr-rr_rr6rrrrr r r r r src@s*eZdZdZddZd ddZddZd S) TaggedBitzA tagged string in a formulacCs t||_|t||S)zSet the constant and the tag)rrrr6r>)r^rarr r r raH szTaggedBit.constantFcCs||_t|||_|S)zSet the constant and the tag)rrrr)r^rrrr r r rnN szTaggedBit.completecCstj|dd|_|S)z4Set the self-closing tag, no contents (as in
).T)r)rrr)r^rr r r selfcompleteT szTaggedBit.selfcompleteN)F)rrrrrarnrr r r r rE s rc@s0eZdZdZddZddZddZdd Zd S) r>zA constant string in a formulacCs"t||||_d|_d|_dS)zSet the constant stringruN)r=r_rr-r)r^ror r r r_\ s zFormulaConstant.__init__cCs|jS)z+Compute the size of the constant: always 1.)r-)r^r r r rc szFormulaConstant.computesizecCs t|jS)zReturn a copy of itself.)r>r)r^r r r rg szFormulaConstant.clonecCs d|jS)z"Return a printable representation.zFormula constant: )ro)r^r r r rk szFormulaConstant.__unicode__N)rrrrr_rrrr r r r r>Y s r>c@s eZdZdZddZddZdS)rEzA bit of text inside a formulacCs |S)zDetect a bit of raw text)rsr&)r^r?r r r detectr szRawText.detectcCs |}|t|d|_dS)zParse alphabetic textr#N)r'r6r>r)r^r?r#r r r parsebitv szRawText.parsebitN)rrrrrrr r r r rEo srEc@s8eZdZdZejZejdZddZddZddZ d S) rOzA symbol inside a formularcCs(|tjkrdS|tjkr$dSdS)zDetect a symbolTF)rsrOrr)r^r?r r r r s zFormulaSymbol.detectcCsd|tjkr"|||dS|tjkrJ|tj||dStd|ddS)zParse the symbolNzSymbol z not found)rsrOr addsymbolrrr)r^r?r r r r szFormulaSymbol.parsebitcCs$||||jt|dS)z Add a symbolN)rrsrrrr>)r^symbolr?r r r r szFormulaSymbol.addsymbolN) rrrrrrrrrrr r r r rO| s   rOc@s eZdZdZddZddZdS)rFzA string of digits in a formulacCs |S)zDetect a digit)rsr()r^r?r r r r szFormulaNumber.detectcs*fdd}|t|d|_dS)zParse a bunch of digitscs S)N)rsr(r )r?r r r rz(FormulaNumber.parsebit..rN)r%r6r>r)r^r?digitsr )r?r r szFormulaNumber.parsebitN)rrrrrrr r r r rF srFc@s*eZdZdZejdZddZddZdS)r:z*A LaTeX comment: % to the end of the line.rcCs||jkS)z Detect the %.)rsr)r^r?r r r r szComment.detectcCs|j|d7_dS)zParse to the end of the line.rN)rr3)r^r?r r r r szComment.parsebitN) rrrrrrnrrrr r r r r: s r:c@s(eZdZdZddZddZddZdS) WhiteSpacez"Some white space inside a formula.cCs |S)zDetect the white space.)rsr-)r^r?r r r r szWhiteSpace.detectcCs|j|7_dS)zParse all whitespace.N)rr0)r^r?r r r r szWhiteSpace.parsebitcCsd|jdS)z"Return a printable representation.z Whitespace: *r)r)r^r r r r szWhiteSpace.__unicode__N)rrrrrrrr r r r r src@sleZdZdZejdZejdZddZ ddZ ddZ d d Z d d Z d dZddZddZddZdS)rDzA {} bracket inside a formularcCst|d|_dS)z'Create a (possibly literal) new bracketN)rr_inner)r^r r r r_ s zBracket.__init__cCs ||jS)zDetect the start of a bracket)r!r)r^r?r r r r szBracket.detectcCs|||j|S)zParse the bracket) parsecomplete innerformula)r^r?r r r r szBracket.parsebitcCs|||j|S)zParse a text bracket)r innertext)r^r?r r r parsetext szBracket.parsetextcCs|||j|S)zParse a literal bracket)r innerliteral)r^r?r r r parseliteral szBracket.parseliteralcCsp||js,td|jd|dS||j|||j|||j| |j7_| dS)zParse the start and end markszBracket should start with z at N) r!rrrrErr8rrr;r)r^r?Z innerparserr r r r s  zBracket.parsecompletecCs$x|s||j|qWdS)z(Parse a whole formula inside the bracketN)rr6rparseany)r^r?r r r r s zBracket.innerformulacCsttj}|tjd|tjd|tjxV|s| |kr|| |j || dr|jd7_q<| t|qr)r^r?Z specialcharsr r r r s    zBracket.innertextcCsbd|_xF|sL||jksL||jkr8||q|j|7_qW|j|j7_dS)zAParse a literal inside the bracket, which does not generate HTML.r!N)literalrrsrrrrr)r^r?r r r r s  zBracket.innerliteralN)rrrrrrnrrlrr_rrrrrrrrr r r r rD s   rDc@s,eZdZdZejdZejdZddZ dS) SquareBracketzA [] bracket inside a formularcCst}|j|_|S)z3Return a new square bracket with the same contents.)rr)r^rr r r r szSquareBracket.cloneN) rrrrrrnrrlrrr r r r r s  rc@s eZdZdZddZddZdS)MathsProcessorzAA processor for a maths construction inside the FormulaProcessor.cCstdt|dS)z$Process an element inside a formula.zUnimplemented process() in N)rrr)r^rrIr r r r szMathsProcessor.processcCs d|jjS)zReturn a printable description.zMaths processor )rr)r^r r r r szMathsProcessor.__unicode__N)rrrrrrr r r r r src@sDeZdZdZgZddZddZddZdd Zd d Z d d Z dS)FormulaProcessorz&A processor specifically for formulas.cCs"||||||dS)z7Process the contents of every formula bit, recursively.N)processcontentsprocessinsides traversewhole)r^rr r r r& s  zFormulaProcessor.processcCs4t|tsdS|x|jD]}||qWdS)z&Process the contents of a formula bit.N)rmrrrr)r^rrr r r r, s   z FormulaProcessor.processcontentscCsRt|tsdSx>t|jD]0\}}x|jD]}||j|q*W||qWdS)z8Process the insides (limits, brackets) in a formula bit.N)rmrrBr processorsrr)r^rrIr processorr r r r4 s   zFormulaProcessor.processinsidescCsfd}x\||D]N\}}|jdkr0|||n*|jdkrZ|rZ|jdkrZ|jdtd|}qWdS)z>Traverse over the contents to alter variables and space units.Nr#fontrru )traverser italicizerrxr>)r^r|lastrrr r r r> s zFormulaProcessor.traversewholeccsVxP|jD]F}t|dr*|jr*||jfVqt|trx||D] }|Vq@WqWdS)zHTraverse a formula and yield a flattened structure of (bit, list) pairs.rN)rrkrrmrr)r^rrpairr r r rH s   zFormulaProcessor.traversecCs"||}t|gd||<dS)z Italicize the given bit of text.rN)rIrrn)r^rrrIr r r rQ s zFormulaProcessor.italicizeN) rrrrrrrrrrrr r r r r! s   rc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZdS)rCzA LaTeX formulacCst|_td|_dS)Nzspan class="formula")rtr}rrr)r^r r r r_\ szFormula.__init__cCsf|jddkrdt_ndt_|jddtjr:|n(tjrJ|ntjrZ|n| dS)zConvert the formula to tagsrrwFTzdiv class="formula"N) rrorsrrryrrrclassic)r^r r r r` s   zFormula.processcCs>|jddkrtd|_ntd|_t|jg|_dS)zMake the contents for jsMath.rrwzdiv class="math"zspan class="math"N)rrrrr=rjr)r^r r r rp szFormula.jsmathcCs@d|j_d}|jddkr"|d7}t|j|ddg|_dS) zMake the contents for MathJax.zspan class="MathJax_Preview"zscript type="math/texrrwz ;mode=displayrTN)rrrr@rarjr)r^rr r r rx s zFormula.mathjaxcCs>tjdtj|j}d|d|jd}t|g|_dS)zIMake the contents using Google Charts http://code.google.com/apis/chart/.rzzN)rrurllibr quote_plusrjr=r)r^urlimgr r r r szFormula.googlechartscCs,t|j}t|||_|g|_dS)zEMake the contents using classic output generation with XHTML and CSS.N)FormulaFactoryr{rjrrrr)r^wholer r r r s zFormula.classiccCsr|dr||nP|dr,||n:|drD||dn"|dr\||dn |d||S)z4Parse using a parse position instead of self.parser.z$$rz\(z\)z\[z\]zUnparseable formula)rJparsedollarblockparsedollarinline parseinlineto parseblocktorr)r^r?r r r r s       z Formula.parsecCsdg|_||dS)zParse a $...$ formula.rwN)r parsedollar)r^r?r r r r szFormula.parsedollarinlinecCs*dg|_|||ds&|ddS)zParse a $$...$$ formula.rxrz1Formula should be $$...$$, but last $ is missing.N)rrrJr)r^r?r r r r s  zFormula.parsedollarblockcCs$|d|d|_|ddS)zParse to the next $.rN)r8r5rjr;)r^r?r r r r s  zFormula.parsedollarcCsdg|_|||dS)zParse a \(...\) formula.rwN)r parseupto)r^r?limitr r r r szFormula.parseinlinetocCsdg|_|||dS)zParse a \[...\] formula.rxN)rr)r^r?rr r r r szFormula.parseblocktocCs(|||dd|_||dS)z1Parse a formula that ends with the given command.cSsdS)NTr r r r r r rz#Formula.parseupto..N)r8r%rjr;)r^r?rr r r r s zFormula.parseuptocCs"|jr|jjrd|jjdSdS)z"Return a printable representation.z Formula (rzUnnumbered formula)rir)r^r r r r szFormula.__unicode__N)rrrrr_rrrrrrrrrrrrrr r r r rCY srCc@s eZdZdZddZddZdS) WholeFormulazParse a whole formulacCs | S)z"Not outside the formula is enough.)r)r^r?r r r r szWholeFormula.detectcCs$x|s||j|qWdS)zParse with any formula bitN)rr6rr)r^r?r r r r s zWholeFormula.parsebitN)rrrrrrr r r r r src@steZdZdZeeeeee gZ ee gZ dZ ddZ ddZddZd d Zd d Zd dZddZddZddZdS)rzConstruct bits of formulaFcCs t|_dS)z Initialize the map of instances.N)r instances)r^r r r r_ szFormulaFactory.__init__cCs|r dS|||S)zDetect a bit of a given type.F)rrr)r^rr?r r r detecttype szFormulaFactory.detecttypecCs.||jks|j|s$|||j|<|j|S)z"Get an instance of the given type.)rr)r^rr r r r szFormulaFactory.instancecCst||S)z+Create a new formula bit of the given type.)rrr)r^rr r r r szFormulaFactory.createcCs x|s||sdSqWdS)zClear any skipped types.N)rskipany)r^r?r r r clearskipped s  zFormulaFactory.clearskippedcCs0x*|jD] }|||r|||SqWdS)zSkip any skipped types.N) skippedtypesrrrv)r^r?rr r r r s zFormulaFactory.skipanycCsLx,|j|jD]}|||r|||SqWtd|t|S)z.Parse any formula bit at the current location.zUnrecognized formula at ) typesrrrvrrrEr>r)r^r?rr r r r s  zFormulaFactory.parseanycCs0||}d|j|<||}|r,||S|S)z#Parse the given type and return it.N)rrrr)r^rr?rZ returnedbitr r r rv s     zFormulaFactory.parsetypecCs\t|}|t}||r*|||S|sXtd|| t |d|S)z5Parse a string of text that contains a whole formula.zUnknown formula at: zspan class="unknown") rKrrrrrrrrEr6rra)r^r|r?rr r r r{ s   zFormulaFactory.parseformulaN)rrrrrOrErFrDr:rrrdefiningr_rrrrrrrvr{r r r r r s rc@sDeZdZdZdZddZeeZddZddZd d Z d d Z dS) Translatorz=Reads the configuration file and tries to find a translation.NcCs |j|S)z%Get the translated message for a key.)r getmessage)rrer r r translate1 szTranslator.translatecCsd|_d|_dS)NT) translationfirst)r^r r r r_7 szTranslator.__init__cCsd|_tjstddStjtjkr:tdtjdStjtjdkrNdStjtjg}ytdd||_Wn&t k rtdt |YnXdS)z/Find the translation for the document language.NzNo language in documentzUnknown language rNZelyxerzNo translation for ) langcodesrorrrrCr[gettextrIOErrorr)r^rr r r findtranslation; s  zTranslator.findtranslationcCsR|jr|d|_||}|js(|Sy|j|}Wntk rLYnX|S)z-Get the translated message for the given key.F)rrgetuntranslatedrZugettextr)r^rer r r r rL s zTranslator.getmessagecCs&|tjkrtd||Stj|S)zGet the untranslated message.zCannot translate )rCrrr)r^rer r r rZ s zTranslator.getuntranslated) rrrrrrrr_rrrr r r r r+ src @seZdZdZdZdZdZdZdZe j dZ ddddd d d d d ddddg Z ddZ ddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)ZdS)* NumberCounterz#A counter for numbers (by default).NABCDEFGHIJKLMNOPQRSTUVWXYZr)Mi)ZCMi)Di)ZCDi)Cd)ZXCZ)L2)ZXL()Xrp)ZIX )V)ZIV)IrucCs ||_dS)zGive a name to the counter.N)r)r^rr r r r_v szNumberCounter.__init__cCs ||_|S)z0Set the counter mode. Can be changed at runtime.)r)r^rr r r setmodez szNumberCounter.setmodecCs ||_dS)zSet an initial value.N)rf)r^rfr r r init szNumberCounter.initcCs t|jS)z$Get the next value as a text string.)rrf)r^r r r r szNumberCounter.gettextcCs ||jS)zGet the next value as a letter.) getsequenceletters)r^r r r getletter szNumberCounter.getlettercCs ||jS)zGet the next value as a symbol.)rr)r^r r r getsymbol szNumberCounter.getsymbolcCs||jdt|S)z*Get the next value from elyxer.a sequence.ru)rfr`)r^r r r r r szNumberCounter.getsequencecCsBd}|j}x2|jD](\}}||kr||||7}||}qW|S)z%Get the next value as a roman number.r!)rf romannumerals)r^r~rZnumeralrfr r r getroman s zNumberCounter.getromancCs||jr|jdkr|S|jdkr*|S|jdkr@|S|jdkrR|S|jdkrd|Std|j|S)z8Get the current value as configured in the current mode.)r'rAarrzUnknown counter mode )rrrrGrrrr)r^r r r getvalue s     zNumberCounter.getvaluecCs"|js d|_|jd7_|S)z@Increase the current value and get the next value as configured.rru)rfr)r^r r r getnext szNumberCounter.getnextcCs d|_dS)zReset the counter.rN)rf)r^r r r reset szNumberCounter.resetcCs"d|j}|jr|d|j7}|S)z"Return a printable representation.zCounter z in mode )rr)r^r~r r r r s zNumberCounter.__unicode__)rrrrrrfrmasterrrr rrr_rrrrrrrrrrrr r r r re s,    rc@s(eZdZdZddZddZddZdS) DependentCounterz4A counter which depends on another one (the master).cCs||_|j|_|S)zSet the master counter.)rrr)r^rr r r setmaster s zDependentCounter.setmastercCs2|j|jkr|t|}|j|_|S)z8Increase or, if the master counter has changed, restart.)rrrrrr)r^rfr r r r s   zDependentCounter.getnextcCs|jdt|S)z8Get the value of the combined counter: master.dependent.r&)rrr)r^r r r r szDependentCounter.getvalueN)rrrrrrrr r r r r src@seZdZdZdZdZddejdDZddejdDZ e Z dZ dd Z d d Zd d ZddZddZddZddZddZddZddZddZddZd d!Zd"d#ZdS)$NumberGeneratorzMA number generator for unique sequences and hierarchical structures. Used in:NcCsg|] }|qSr )rG)rxr r r r szNumberGenerator.rcCsg|] }|qSr )rG)rrr r r r srcCs |ddS)z.Remove the possible asterisk in a layout type.rr!)rj)r^rr r r deasterisk szNumberGenerator.deasteriskcCs ||S)z9Find out if the layout type corresponds to a unique part.)isroman)r^rr r r isunique szNumberGenerator.isuniquecCs|||jkS)z9Find out if the layout type should have roman numeration.)rrG romanlayouts)r^rr r r r szNumberGenerator.isromancCs|||jkS)z?Find out if the layout type corresponds to an (un)ordered part.)rrGorderedlayouts)r^rr r r isinordered szNumberGenerator.isinorderedcCs@d|kr dS||rdS||s(dS||tjkr|s>||7}d}q|SqW|S)z+Extract the first number in the given text.r!Fr&T)r()r^r'r~decimalcharr r r r  s   zContainerSize.extractnumbercCs||r*t|d|_|jr*|js*|||_|rTt|d|_|jrT|jsT|||_|jrf|jsfd|_|jrx|jsxd|_dS)z-Check image dimensions, set them if possible.pxautoN)rrrr scalevaluerr)r^rrr r r checkimage s      zContainerSize.checkimagecCs"|t|jd}tt|dS)zFScale the value according to the image scale and return it as unicode.rr)rrr)r^rfZscaledr r r r szContainerSize.scalevaluecCs8|js dSd|jkrdS|j}d|_|jdkr4d|_|S)z?Remove percent width if present, to set it at the figure level.Nrr)rr)r^rr r r removepercentwidth s  z ContainerSize.removepercentwidthcCst|jtstdt||js:|js:|js:|j s:dSd}|| d7}|| d7}|| d7}|| d7}|dd kr|dd}|d 7}|jj |7_ dS) z1Add the proper style attribute to the output tag.zNo tag to add style, in Nz style="rrrrrrr) rmrrrrrrrrrstyleparameterr)r^rrr r r addstyle s   zContainerSize.addstylecCs*t||}|r&|ddd|dSdS)z%Get the style for a single parameter.rzmax-z: z; r!)rlrj)r^rrfr r r r s zContainerSize.styleparameter)NN)NN)rrrrrrrrrrrr rrrr r rrrrrr r r r rV s&    rc@s eZdZdZddZddZdS)r\zA container for a pretty quotecCst|_t|_dS)N)rr}rr)r^r r r r_ szQuoteContainer.__init__cCsL|jd|_|jtjkr8td|jddg|_dStj|jg|_dS)zProcess contentsrhz Quote type z not foundrN)rrr!r+rrr})r^r r r r s   zQuoteContainer.processN)rrrrr_rr r r r r\ sr\c@s eZdZdZddZddZdS)rez A Lyx linecCst|_t|_dS)N)rr}rr)r^r r r r_ szLyXLine.__init__cCs dg|_dS)Nz
)r})r^r r r r szLyXLine.processN)rrrrr_rr r r r re srec@seZdZdZddZdS)r0zText with emphatic modecCs d|j_dS)Nr)rr)r^r r r r szEmphaticText.processN)rrrrrr r r r r0 sr0c@seZdZdZddZdS)r7zText shaped (italic, slanted)cCsL|jd|_|jtjkr8td|jdd|j_dStj|j|j_dS)NruzUnrecognized shape span)rrr0rBrrrr)r^r r r r s   zShapedText.processN)rrrrrr r r r r7 sr7c@seZdZdZddZdS)r;zText in versalitascCs d|j_dS)Nzspan class="versalitas")rr)r^r r r rszVersalitasText.processN)rrrrrr r r r r;sr;c@seZdZdZddZdS)r/z Colored textcCs"|jd|_d|jd|j_dS)Nruz span class="r)rrrr)r^r r r r s zColorText.processN)rrrrrr r r r r/sr/c@seZdZdZddZdS)r8z Sized textcCs"|jd|_d|jd|j_dS)Nruz span class="r)rr-rr)r^r r r rs zSizeText.processN)rrrrrr r r r r8sr8c@seZdZdZddZdS)r+z Bold textcCs d|j_dS)Nr)rr)r^r r r rszBoldText.processN)rrrrrr r r r r+sr+c@seZdZdZddZdS)r:z,A bit of text from elyxer.a different familycCsF|jd|_|jtjkr2tdtd|j_dStj|j|j_dS)zParse the type of familyruzUnrecognized family rN)rrr0r>rrrr)r^r r r rs   zTextFamily.processN)rrrrrr r r r r:sr:c@seZdZdZddZdS)r1zHorizontall fillcCs d|j_dS)Nzspan class="hfill")rr)r^r r r r+sz Hfill.processN)rrrrrr r r r r1(sr1c@seZdZdZddZdS)r*zText with a bar somewherecCsH|jd|_|jtjkr4td|jd|j_dStj|j|j_dS)zParse the type of barruzUnknown bar type rN)rrr0r=rrrr)r^r r r r1s   zBarredText.processN)rrrrrr r r r r*.sr*c@seZdZdZddZdS)rBz A line with language informationcCsF|jd}|tjkr t|_dStj|}td|dd|_dS)zDOnly generate a span with lang info when the language is recognized.ruNz span lang="rF)rrCr[rrrr)r^langZisolangr r r r=s    zLangLine.processN)rrrrrr r r r rB:srBc@seZdZdZddZdS)rcz!A length measure inside an inset.cCs|jd|_dS)Nru)rrF)r^r r r rIszInsetLength.processN)rrrrrr r r r rcFsrcc@s(eZdZdZddZddZddZdS) r^zA space of several typescCst|_t|_dS)N)rr}rr)r^r r r r_OszSpace.__init__cCsz|jd|_|jtjkr4td|jdg|_dStj|jg|_|}|sTdSt dd|_ t | |dS)NrhzUnknown space type rzspan class="hspace"F)rrr!r*rrr} getlengthrrrrrr)r^rFr r r rSs  z Space.processcCs.t|jdkst|jdts"dS|jdjS)z.N) instantiater stagedict)r^classesr(rr r r r_Gs zStageDict.__init__cCs.dd|D}x|D]}|||_qW|S)z-Instantiate an element from elyxer.each classcSsg|]}||qSr )r)rrr r r rNsz)StageDict.instantiate..)r_r()r^r-r(r$rr r r r+Ls   zStageDict.instantiatecCs|j|jkrdS|j|jS)z=Get the stage for a given element, if the type is in the dictN)rr,)r^rr r r r*Ts zStageDict.getstageN)rrrrr_r+r*r r r r r#Dsr#c@sLeZdZdZeZdZddZddZdddZ d d Z d d Z d dZ dS)rVzA label to be referencedNcCst|d|_dS)N)rr_ lastnumbered)r^r r r r_bs zLabel.__init__cCs"|d}|d|tj|_dS)zProcess a label container.rrN)rerrV lastlayoutr.)r^rer r r rfs  z Label.processcCsH||_|j|||d|tj|<|tjkrDxtj|D] }||_q6W|S)z!Create the label for a given key.)rr)rernrVnamesrWrLr)r^r'rer referencer r r rls   z Label.createcCs||}|r|jr|jSdS)z8Get the part key for the latest numbered container seen.r!)ryri)r^ryr r r findpartkeyvs  zLabel.findpartkeycCs,|jr |S|js |jr|jSdS||jS)z)Get the numbered container for the label.N)rirr.ry)r^rr r r ry}szLabel.numberedcCst|dsdSd|jS)z"Return a printable representation.rez Unnamed labelzLabel )rkre)r^r r r rs zLabel.__unicode__)rV) rrrrrr0r/r_rrr2ryrr r r r rV\s  rVc@s:eZdZdZeZdZddZddZddZ d d Z d S) rWzA reference to a label.nonecCs|d|_|jtjkr,d|_tj|j}nd|_td|jd}||_||jtj krjgtj |j<tj |j |dS)z%Read the reference and set the arrow.r1u↑u↓rZprerefN) rererVr0 directionrnrformatcontentsrWrLrr)r^labelr r r rs    zReference.processcCs|d}|sd}d|_|tjkr0tj||_ntd||d|j|dd|dt d|j }|d|o|j |d |o|j d |jks|r|jst|jg|_d S|jd }t|d g|_x4|d d D]$}|j|j7_|jt|qWd S)zFormat the reference contents.Z LatexCommandr$u↕zUnknown reference format rrzon-pagerrrNrru)rer#r!r,rrrjr4rrrr2rZtocentryZ titlecontentsr=rrwrr)r^Z formatkeyrirXrYr r r r5s*     zReference.formatcontentscCs*||jkrdS|sd}|j|||_dS)z2Replace a key in the format template with a value.Nr!)r#rj)r^rerfr r r rjs  zReference.replacecCs d|jS)z"Return a printable representation.z Reference )re)r^r r r rszReference.__unicode__N) rrrrrrLrerr5rjrr r r r rWsrWc@sZeZdZdZgZejdZdZddZ ddZ dd Z d d Z d d Z ddZddZdS)FormulaCommandz A LaTeX command inside a formularNcCs |tjS)zFind the current command.)r!r7r)r^r?r r r rszFormulaCommand.detectcCs|||}|||}|r|S|ds2|drF|||}|rF|S|jjs\td|t d|_ | t |dS)zParse the command.z\upz\UpzUnknown command zspan class="unknown"N) extractcommandparsewithcommandra parseupgreekrrrrrrrr6r>)r^r?rrupgreekr r r rs   zFormulaCommand.parsebitcCs,x&tjD]}||jkr||||SqWdS)z0Parse the command type once we have the command.N)r7r commandmapparsecommandtype)r^rr?rr r r r9s  zFormulaCommand.parsewithcommandcCs,|j|}||||}|r(|S|S)zParse a given command type.)rr setcommandr)r^rrr?rZreturnedr r r r=s    zFormulaCommand.parsecommandtypecCsh|tjs |dtjdS|r2||S|rZtj|}|d|Stj| S)z5Extract the command from elyxer.the current position.zMissing command start Nr) rJr7rrr emptycommandrsr&r'r)r^r?rr r r r8s    zFormulaCommand.extractcommandcCs0d}|s&|}|r&||r&|}tj|S)zqCheck for an empty command: look for command disguised as ending. Special case against '{ \{ \} }' situation.r!)r r=rJr7r)r^r?rrr r r r?s zFormulaCommand.emptycommandcCst|dkrdS|dr,d|dd}n>|drXd|dd|dd}ntd|dS|||}|rd|_|S) zParse the Greek \up command..rNz\uprjrz\UpzImpossible upgreek command: r)r`rarJupperrrr9r)r^rr?Z upcommandr;r r r r:s   " zFormulaCommand.parseupgreek)rrrrrrrnrr<rrr9r=r8r?r:r r r r r7s   r7c@s@eZdZdZddZddZddZdd Zd d Zd d Z dS) CommandBitz%A formula bit that includes a commandcCs,||_|jr(|j|7_|j|j|_dS)zSet the command in the bitN)rr<r translated)r^rr r r r>#szCommandBit.setcommandcCs2|j||rdS|j|}|||S)z)Parse a parameter at the current positionN)rrrrr6)r^r? parameterr r r r*s    zCommandBit.parseparametercCs:|j||jt|sdS|jt|}|||S)zParse a square bracketN)rrrrrvr6)r^r?rr r r parsesquare3s   zCommandBit.parsesquarecCsd|j||jt|s@|s8td|dS|St |j}| | ||j S)zParse a literal bracket.zNo literal parameter found at: N) rrrrDr.rrrEr/rr6rr)r^r?rr r r r<s zCommandBit.parseliteralcCsB|j||jt|sdSt|j}||||jS)z!Parse a square bracket literally.N)rrrrrr6rr)r^r?rr r r parsesquareliteralHs  zCommandBit.parsesquareliteralcCsP|j||jt|s.td|jdSt|j|}| ||S)zParse a text parameter.zNo text parameter for N) rrrrDrrrrrr6)r^r?rr r r rQs  zCommandBit.parsetextN) rrrrr>rrDrrErr r r r rA s    rAc@seZdZdZejZddZdS)rHz%An empty command (without parameters)cCst|jg|_dS)z"Parse a command without parametersN)r>rBr)r^r?r r r r`szEmptyCommand.parsebitN)rrrrrr{r<rr r r r rH[srHc@seZdZdZejZddZdS) SpacedCommandzrBr)r^r?r r r riszSpacedCommand.parsebitN)rrrrrrr<rr r r r rFdsrFc@seZdZdZejZddZdS)rGz8A command without paramters whose result is alphabeticalcCst||d|_dS)z'Parse the command and set type to alphar#N)rHrr)r^r?r r r rrs zAlphaCommand.parsebitN)rrrrrrr<rr r r r rGmsrGc@s*eZdZdZejZdZddZddZ dS)rIzA function of one parameterFcCs&t|j|_|||dS)z#Parse a function with one parameterN)rrrBrrsimplifyifpossible)r^r?r r r r}s zOneParamFunction.parsebitcCs.|j|jkr*t|_|j|jg|_d|_dS)z&Try to simplify to a single character.TN)rr<rrr} simplified)r^r r r rGs z#OneParamFunction.simplifyifpossibleN) rrrrrrr<rHrrGr r r r rIws rIc@s&eZdZdZejZddZddZdS)rJz>Find a function which is represented by a symbol (like _ or ^)cCs|tjkS)zFind the symbol)rsrJr<)r^r?r r r rszSymbolFunction.detectcCs8||||jt|j|_||dS)zParse the symbolN) r>rsr2rrrrBrr)r^r?r r r rs zSymbolFunction.parsebitN) rrrrrrr<rrr r r r rJsrJc@s&eZdZdZejZddZddZdS)rKz-A function where parameters are read as text.cCst|j|_||dS)zParse a text parameterN)rrrBrr)r^r?r r r rszTextFunction.parsebitcCs d|_dS)zSet the type to fontrN)r)r^r r r rszTextFunction.processN) rrrrrrr<rrr r r r rKsrKc@s&eZdZdZejZddZddZdS) LabelFunctionzA function that acts as a labelcCs|||_dS)zParse a literal parameterN)rre)r^r?r r r rszLabelFunction.parsebitcCs8d|_tjd|jdd|_|jg|_|jtj|j<dS)z&Add an anchor with the label contents.rrZeqnumber)rN)rrVrrer6rr0)r^r r r rs zLabelFunction.processN) rrrrrrr<rrr r r r rIsrIc@seZdZdZejZddZdS)rLz1A function of one parameter that changes the fontcCsd|_|dS)z.Simplify if possible using a single character.rN)rrG)r^r r r rszFontFunction.processN)rrrrrrr<rr r r r rLsrLc@s.eZdZdZejZddZddZddZ dS) BigSymbolzA big symbol generator.cCs ||_dS)zCreate the big symbol.N)r)r^rr r r r_szBigSymbol.__init__cCs0|j|jkr|jgS|r$|jgS|j|jS)zGet an array with all pieces.)rr smalllimit)r^r r r getpiecess  zBigSymbol.getpiecescCs(tjs dSt|j|jdkr"dStjS)z7Decide if the limit should be a small, one-line symbol.Tru)rorsr`rrryr)r^r r r rKs zBigSymbol.smalllimitN) rrrrrrrr_rLrKr r r r rJs rJc@sReZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ dS) BigBracketzA big bracket generator.rcCs2||_||_||_d|_|tjkr.tj||_dS)z(Set the size and symbol for the bracket.N)r-r alignmentrXrr)r^r-rrNr r r r_s  zBigBracket.__init__cCs t|dtt|j}||S)z%Return the nth piece for the bracket.getpiece)rlrr`rX)r^rIfunctionr r r rOszBigBracket.getpiececCs |jdS)z1Return the only piece for a single-piece bracket.r)rX)r^rIr r r getpiece1szBigBracket.getpiece1cCs4|dkr|jdS||jdkr*|jdS|jdS)zGGet the nth piece for a 3-piece bracket: parenthesis or square bracket.rrur)rXr-)r^rIr r r getpiece3s   zBigBracket.getpiece3cCsP|dkr|jdS||jdkr*|jdS||jddkrF|jdS|jdS)z7Get the nth piece for a 4-piece bracket: curly bracket.rrurrh)rXr-)r^rIr r r getpiece4 s   zBigBracket.getpiece4cCs&||}d|jd}t||S)z'Get the bracket piece as an array cell.zspan class="bracket align-r)rOrNrra)r^rIrYrr r r getcells zBigBracket.getcellcCs`|jdks|js|Sg}x2t|jD]$}||}|t|gdq(Wt|dgS)z3Get the bracket as an array or as a single bracket.ruzspan class="arrayrow"zspan class="array")r-rXgetsinglebracketrrTrrrrn)r^rowsrIcellr r r getcontentss zBigBracket.getcontentscCs,|jdkrtddgSt|jdgS)z$Return the bracket as a single sign.r&r!zspan class="emptydot"zspan class="symbol")rrra)r^r r r rU$s zBigBracket.getsinglebracketN)r) rrrrr_rOrQrRrSrTrXrUr r r r rMs   rMc@seZdZdZdZddZdS)FormulaEquationzA simple numbered equation.ZequationcCs t|_||jt|dS)zParse the arrayN)rrr6rrvr)r^r?r r r r4szFormulaEquation.parsebitN)rrrrrYrr r r r rY/srYc@s eZdZdZddZddZdS) FormulaCellzAn array cell inside a rowcCs"||_td|dd|_|S)Nzspan class="arraycell align-rT)rNrrr)r^rNr r r setalignment<szFormulaCell.setalignmentcCs0|j||rdS||jt|dS)N)rrrr6rvr)r^r?r r r rAs zFormulaCell.parsebitN)rrrrr[rr r r r rZ9srZc@s2eZdZdZejdZddZddZddZ d S) FormulaRowzAn array row inside an arrayrcCs||_tdd|_|S)Nzspan class="arrayrow"T) alignmentsrrr)r^r]r r r setalignmentsLszFormulaRow.setalignmentscCsnd}|j|jddx>|sR||}|||||d7}||jqWt|jdkrjt |_ dS)zParse a whole rowrT)r7ruN) r8rr createcellrr6rJr`rrr)r^r?rIrWr r r rQs    zFormulaRow.parsebitcCs&|j|t|j}|jt|S)z4Create the cell that corresponds to the given index.)r]r`rrrZr[)r^rIrNr r r r_^szFormulaRow.createcellN) rrrrrrrr^rr_r r r r r\Gs   r\c@s0eZdZdZddZddZddZdd Zd S) MultiRowFormulazA formula with multiple rows.cCsTg|_d}x8||D]*}|r$d}n|||||qWt|j|_dS)z,Parse all rows, finish when no more row endsTFN)rV iteraterowsaddemptyraddrowr`r-)r^r?rrowr r r parserowsfs zMultiRowFormula.parserowsccs^tjd}xN||d|jt}||jV||rR|j | |7_ q dSq WdS)z0Iterate over all rows, end when no more row endsrTN) rrr8rrr\r^r]r!rr;)r^r?rrdr r r rats    zMultiRowFormula.iteraterowscCsb|jt|j}x>t|jdjD]*\}}||}| t d| |q&W| |dS)zAdd an empty row.ru N) rrr\r^r]rBrVrr_r6r>rc)r^rdrIZ originalcellrWr r r rbs  zMultiRowFormula.addemptycCs|j|||dS)z2Add a row to the contents and to the list of rows.N)rVrrr6)r^rdr r r rcs zMultiRowFormula.addrowN)rrrrrerarbrcr r r r r`cs   r`c@s$eZdZdZdZddZddZdS) FormulaArrayzAn array within a formularcCs(tdd|_||||dS)zParse the arrayzspan class="array"FN)rrrparsealignmentsre)r^r?r r r rs zFormulaArray.parsebitcCsHd|_||}|r||_||}g|_x|D]}|j|q0WdS)zParse the different alignmentsrN)valignrErr]rr)r^r?rrr r r rgs   zFormulaArray.parsealignmentsN)rrrrrYrrgr r r r rfsrfc@seZdZdZdZddZdS) FormulaMatrixz'A matrix (array with center alignment).ZmatrixcCs,tdd|_d|_dg|_||dS)z(Parse the matrix, set alignments to 'c'.zspan class="array"FrN)rrrrhr]re)r^r?r r r rszFormulaMatrix.parsebitN)rrrrrYrr r r r risric@seZdZdZdZddZdS) FormulaCaseszA cases statementZcasescCst|_ddg|_||x<|jD]2}x,|jD]"}|jdd|jtdq0Wq$Wt |jdd}t t |jdd}| |g|_dS)zParse the casesrzspan class="case align-l"Tu zspan class="bracketcases"rN) rrr]rerrrrr>rrnrMr`rX)r^r?rdrWrZbracer r r rs    zFormulaCases.parsebitN)rrrrrYrr r r r rjsrjc@seZdZdZddZdS)EquationEnvironmentz;A \begin{}...\end equation environment with rows and cells.cCs\tdd|_|jdd}|tjkr6tj||_nt d|jdg|_| |dS)zParse the whole environment.zspan class="environment"Frr!zUnknown equation environment rN) rrrrYrjrrr]rrre)r^r? environmentr r r rs zEquationEnvironment.parsebitN)rrrrrr r r r rksrkc@s:eZdZdZejddiZeee e gZ ddZ ddZ dS) BeginCommandzEA \begin{}...\end command and what it entails (array, cases, aligned)rr!cCsh||}||}tjdd|d}|||||||j||7_|j |_ dS)zParse the begin commandrrrN) rfindbitrrr8rr6rr;r-)r^r?rrrr r r rs     zBeginCommand.parsebitcCsDx,tjD]"}|dd|jkr|j|SqW|jt}||_|S)z7Find the command bit corresponding to the \begin{piece}rr!)rmrrjrYrrrk)r^rYrrr r r rns   zBeginCommand.findbitN)rrrrrrr<rYrfrjrirrrnr r r r rms   rmc@s"eZdZejZddZddZdS)rMcCspd|_|j}||}|s,td|jn0t|dkr\td|jd|d|j t |dS)zParse a combining function.r#z'Empty parameter for combining function ruzApplying combining function z to invalid string "rN) rrBparsesingleparameterrrrr`rmrrrr=)r^r? combiningrCr r r rs  zCombiningFunction.parsebitcCsj|j||r*td|dS|jt|sF|jt|rP| |St | }| ||S)z&Parse a parameter, or a single letter.z(Error while parsing single parameter at N) rrrrrrErrDr7rr>rr6)r^r?letterr r r ros    z&CombiningFunction.parsesingleparameterN)rrrrrr<rror r r r rMs rMc@seZdZdZejZddZdS)rNz*A function that decorates some bit of textcCsbd|_|j}t|d|_|||_td|_ |j d|jtd|j_ | dS)zParse a decorating functionr#zspan class="symbolover"zspan class="withsymbol"rzspan class="undersymbol"N) rrBrrarrrCrrrrrxrG)r^r?rr r r rs zDecoratingFunction.parsebitN)rrrrrrr<rr r r r rNsrNc@seZdZdZejZddZdS) LimitCommandz@A command which accepts limits above and below, in display mode.cCsDt|j}td|_x"|D]}|jt |dq"WdS)zParse a limit command.zspan class="limits"zspan class="limit"N) rJrBrLrrrrrrrra)r^r?rXrYr r r r$s zLimitCommand.parsebitN)rrrrrrr<rr r r r rrsrrc@s$eZdZdZdZddZddZdS)rz(A command to limit the previous command.NcCstd|_|j|dS)z Do nothing.zspan class="limits"N)rrrrr)r^r?r r r r0szLimitPreviousCommand.parsebitcCsdS)z"Return a printable representation.zLimit previous commandr )r^r r r r5sz LimitPreviousCommand.__unicode__)rrrrr<rrr r r r r+src@sXeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ dS)LimitsProcessorz)A processor for limits inside an element.cCsNtjr dS|||r"||||||rJ|||drJ|||dS)z"Process the limits for an element.Nru)ryr checklimits modifylimits checkscript modifyscripts)r^rrIr r r r<s   zLimitsProcessor.processcCsNtjs dS|||dtr,|||dSt||ts>dS|||dS)z3Check if the current position has a limits command.Fru)rors checkcommandr limitsaheadrmrrrv)r^rrIr r r rtEs zLimitsProcessor.checklimitscCs*||d||t||_dS)z,Limit the current element based on the next.ruN)r6rrr)r^rrIr r r ryPszLimitsProcessor.limitsaheadcCsf||}|||d}|j||||drF|||d}ntdd}|jd|dS)zCModify a limits commands so that the limits appear above and below.ruu zsup class="limit"rN)getlimitrrrrvrrarx)r^rrIZlimitedr;r<r r r ruUs zLimitsProcessor.modifylimitscCs$|||}|jjdd|j_|S)z#Get the limit for a limits command.rAr) getscriptrrrj)r^rrIrr r r rz`s zLimitsProcessor.getlimitcCs:|||}|||}t||gd}|||dS)z=Modify the super- and subscript to appear vertically aligned.zspan class="scripts"N)r{rrnrx)r^rrIr;r<scriptsr r r rwfs  zLimitsProcessor.modifyscriptscCs|||tS)z6Check if the current element is a sub- or superscript.)rxrJ)r^rrIr r r rvnszLimitsProcessor.checkscriptcCst||krdSt|||S)z0Check for the given type as the current element.F)r`rm)r^rrIrr r r rxrs zLimitsProcessor.checkcommandcCs"||}|jjd7_||=|S)zGet the sub- or superscript.z class="script")rr)r^rrIrr r r r{xszLimitsProcessor.getscriptN) rrrrrrtryrurzrwrvrxr{r r r r rs9s   rsc@s&eZdZdZejZddZddZdS)rPz"A command which defines a bracket.cCst||dS)zParse the bracket.N)rIr)r^r?r r r rszBracketCommand.parsebitcCs ||_d||_t|g|_|S)z+Create the bracket for the given character.rj)rrr>r)r^r4 characterr r r rs  zBracketCommand.createN) rrrrrrr<rrr r r r rPsrPc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)BracketProcessorz!A processor for bracket commands.cCs&tjr dS|||r"|||SdS)z6Convert the bracket using Unicode pieces, if possible.N)ryr checkleft processleft)r^rrIr r r rs zBracketProcessor.processcCsJ|||d}|sdS||||}||||||||dS)zProcess a left bracket.ruN) findrightfindmaxresize)r^rrI rightindexr-r r r rs zBracketProcessor.processleftcCs|||dS)z0Check if the command at the given index is left.z\left)checkdirection)r^rrIr r r rszBracketProcessor.checkleftcCs|||dS)z1Check if the command at the given index is right.z\right)r)r^rrIr r r checkrightszBracketProcessor.checkrightcCst|tsdS|j|kS)z6Check if the given bit is the desired bracket command.F)rmrPr)r^rrr r r rs zBracketProcessor.checkdirectioncCsVd}xL|t|krP|||r&|d7}|||r:|d8}|dkrF|S|d7}qWdS)z9Find the right bracket starting at the given index, or 0.rurN)r`rr)r^rrIdepthr r r rs   zBracketProcessor.findrightcCs|||}tdd|DS)z@Find the max size of the contents between the two given indices.cSsg|] }|jqSr )r-)rrr r r rsz,BracketProcessor.findmax..)r)r^rZ leftindexrZslicedr r r rs zBracketProcessor.findmaxcCs8|}|jdd}t|||}t|_||_dS)z+Resize a bracket command to the given size.rjr!N)rmrrjrMrrrXr)r^rr-r}rNrr r r rs  zBracketProcessor.resizeN) rrrrrrrrrrrrr r r r r~s  r~c@seZdZdZdZddZdS)rzShows today's date.NcCs t|_tjdg|_dS)z"Parse a command without parametersz %b %d, %YN)rrdatetimertodaystrftimer})r^r?r r r rszTodayCommand.parsebit)rrrrr<rr r r r rsrc@s8eZdZdZddgZddZddZdd Zd d Zd S) ParameterDefinitionz3The definition of a parameter in a hybrid function.)rr)rrcCs"d|_d|_d|_d|_d|_dS)NF)rrr7rf literalvalue)r^r r r r_s zParameterDefinition.__init__cCsxtjD]\}}||r|dkr(d|_|dsLtd|ddS||_|drfd|_ ||std|dS|SqWtd |dS) z2Parse a parameter definition: [$0], {$x}, {$1!}...rTrz$Wrong parameter name, did you mean $?NrzWrong parameter closing z'Wrong character in parameter template: ) r parambracketsrJr7rrrsrrr)r^r?Zopeningclosingr r r rs      zParameterDefinition.parsecCs^|jr:|jr|||_n |||_|jrZt|j|_n |jrN|||_n |||_dS)z/Read the parameter itself using the definition.N) rr7rErrr>rfrDr)r^r?rPr r r reads zParameterDefinition.readcCs0d|j}|jr$|dt|j7}n|d7}|S)z"Return a printable representation.zparam z: z (empty))rrfr)r^r~r r r rs  zParameterDefinition.__unicode__N) rrrrrr_rrrr r r r rs rc@s8eZdZdZddZddZddZdd Zd d Zd S) ParameterFunctionzFA function with a variable number of parameters defined in a template.cCs<t|_x.||D] }|||||jd|j<qWdS)z*Read the params according to the template.rN)rparams paramdefsrr)r^ readtemplater?paramdefr r r readparamss zParameterFunction.readparamsccs0t|}x"|s*t|}|r |Vq WdS)z*Read each param definition in the templateN)rKrrr)r^rr?rr r r r$s   zParameterFunction.paramdefscCs||jkrdS|j|S)zGet a parameter as parsed.N)r)r^rr r r getparam,s zParameterFunction.getparamcCs ||jS)zGet the value of a parameter.)rrf)r^rr r r r2szParameterFunction.getvaluecCs||}|r|jsdS|jS)z%Get the literal value of a parameter.N)rr)r^rrr r r getliteralvalue6s  z!ParameterFunction.getliteralvalueN) rrrrrrrrrr r r r rs rc@sVeZdZdZejZddZddZddZ dd Z d d Z d d Z ddZ ddZdS)HybridFunctiona A parameter function where the output is also defined using a template. The template can use a number of functions; each function has an associated tag. Example: [f0{$1},span class="fbox"] defines a function f0 which corresponds to a span of class fbox, yielding $1. Literal parameters can be used in tags definitions: [f0{$1},span style="color: $p;"] yields $1, where $p is a literal parameter. Sizes can be specified in hybridsizes, e.g. adding parameter sizes. By default the resulting size is the max of all arguments. Sizes are used to generate the right parameters. A function followed by a single / is output as a self-closing XHTML tag: [f0/,hr] will generate
. cCs8|jd}|jd}||||||_|dS)z*Parse a function with [] and {} parametersrruN)rBr writeparamsrcomputehybridsize)r^r?r writetemplater r r rQs     zHybridFunction.parsebitcCs|t|S)z*Write all params according to the template)writeposrK)r^rr r r rYszHybridFunction.writeparamscCsg}x|s|dr2||}|r||q|dr\||}|rd|_||q|drz||ddq|dr||ddq|t|qW|S)z/Write all params as read in the parse position.rfNrleftrright) rrJ writeparamrr writefunctionr writebracketr>r)r^r?r~rrPr r r r]s"         zHybridFunction.writeposcCs^d|}||jkr(td|dS|j|s6dS|drR||j|j_|j|jS)z*Write a single param of the form $0, $x...rzUnknown parameter Nr&)rrrrrJr'rfr)r^r?rr r r rrs    zHybridFunction.writeparamcCsz||}|sdS|dr(t|S|ds@tddS|d||}|t |dkrldSt ||S)z"Write a single function f0,...,fn.Nrvrz Function should be defined in {}rr) readtagrJrrrrr8rr;r`rn)r^r?rrr r r r~s        zHybridFunction.writefunctioncCs|s"td|dSt|}d|t|jkrZtdt|ddS|jd|}d|krt|Sx`|j D]V}||kr||j |}|j std|d|d q||j r|j }nd }| ||}q|W|S) zJGet the tag corresponding to the given index. Does parameter substitution.zFunction should be f0,...,f9: fNrhz Function fz is not definedrzParameters in tag z should be literal: {z!}r!) rsr(rrrrr`rBrrrrrj)r^r?rIrvariablerrfr r r rs*    zHybridFunction.readtagcCs|jt||S)z4Return a new bracket looking at the given direction.)rrrP)r^r4r}r r r rszHybridFunction.writebracketcCsB|jtjkr|dSt||_x|jD] }|j|_q.WdS)z(Compute the size of the hybrid function.N)r HybridSize configsizesrgetsizer-r)r^rr r r rs   z HybridFunction.computehybridsizeN)rrrrrrr<rrrrrrrrr r r r r=s rc@seZdZdZejZddZdS)rz+The size associated with a hybrid function.cCsf|j|j}x6|jD],}||kr|j|j}||t|}qWd|kr^td|dSt |S)z*Read the size for a function and parse it.rz%Unconverted variable in hybrid size: ru) rrrrfrrjrrreval)r^rPZ sizestringrr-r r r rs  zHybridSize.getsizeN)rrrrrrrrr r r r rsrc@s0eZdZdZddZddZddZdd Zd S) HeaderParserzParses the LyX headercs(gfddS)z?Parse header parameters into a dictionary, return the preamble.cs S)N) parseliner )rrr^r r rrz$HeaderParser.parse..)rr)r^rr )rrr^r rszHeaderParser.parsecCsz|}|tjdr&||dS|tjdrFt|dS|tjdrl||j |dS| |dS)z0Parse a single line as a parameter or as a startrNrr) rrarr  parsebranch LstParser parselstsetrrrrr)r^rrr(r r r rs  zHeaderParser.parselinecCsl|d}|ttjd}||t|}x |jD]}| ||j|qDW|t j |<dS)zParse all branch definitions.rurN) rrwrrrnrr rrrryr)r^rrZ subparserr]rer r r rs  zHeaderParser.parsebranchcCs ||_|S)z*Complete the parser with the given ending.)r)r^rr r r rnszHeaderParser.completeN)rrrrrrrrnr r r r rs  rc@s$eZdZdZgZddZddZdS)PreambleParserzA parser for the LyX preamble.cs&tjd_fddgS)z,Parse the full preamble with all statements.rcs S)N)parsepreambleliner )rr^r r rrz&PreambleParser.parse..)rr rr)r^rr )rr^r rs zPreambleParser.parsecCstj||dS)zParse a single preamble line.N)rpreamblerrrr)r^rr r r rsz PreambleParser.parsepreamblelineN)rrrrrrrr r r r rsrc@s6eZdZdZeZddZddZddZdd Z d S) rz!Parse global and local lstparams.cCsN||}d|kr$td|dS|dd}|dd}||t_dS)z+Parse a declaration of lstparams in lstset.rz#Missing opening bracket in lstset: Nrur) extractlstsetrrrwparselstparamsr globalparams)r^rrfZlefttextZ croppedtextr r r rs  zLstParser.parselstsetcCsBd}x.|s2||7}||dr|SqWtddS)z%Extract the global lstset parameters.r!rz0Could not find end of \lstset settings; abortingN)rrrrvrr)r^rrfr r r rs   zLstParser.extractlstsetcCs,tj|_|d}|j||dS)z-Parse some lstparams from elyxer.a container. lstparamsN)rrrrrgupdater)r^r paramlistr r r r&s  zLstParser.parsecontainercCsXt}xL|D]D}d|kr8t|dkrPtd|q |dd\}}|||<q W|S)z1Process a number of lstparams from elyxer.a list.rrzInvalid listing parameter ru)rr`rrrrw)r^rZ paramdictrrerfr r r r,s  zLstParser.parselstparamsN) rrrrrrrrrrr r r r r s   rc@s6eZdZdZeZddZddZddZdd Z d S) rz0A function that defines a new command (a macro).cCs`t|_d|_g|_d|j_||d|j_td|j dt |jd||j |j <dS)z*Parse the function that defines the macro.rTFz New command z (z parameters)N) rrparameternumberdefaultsrrparseparametersrr newcommandrmacros)r^r?r r r r@s zMacroDefinition.parsebitcCs^|||_||}|r$t||_||}x|rL|j|||}q0W|||_ dS)zDParse all optional parameters (number of parameters, default values)N) parsenewcommandrrErrrDrrrr definition)r^r?rrr r r rLs     zMacroDefinition.parseparameterscCsZ|j||jt|r$||S|jt|rD|jt|St d| dS)z"Parse the name of the new command.z,Unknown formula bit in defining function at ru) rrrrDrr7rr8rrrE)r^r?r r r r\s  zMacroDefinition.parsenewcommandcCs |jS)z Return an instance of the macro.)rr)r^r r r r+fszMacroDefinition.instantiateN) rrrrrrrrrr+r r r r r;s   rc@s eZdZdZddZddZdS)MacroParameterz A parameter from elyxer.a macro.cCs |dS)zFind a macro parameter: #n.r)r!)r^r?r r r rmszMacroParameter.detectcCsV|dstddSt||_dt|j|_t dt|jdg|_ dS)zParse the parameter: #n.rzMissing parameter start #.Nzspan class="unknown") rJrrrrrrrrrar)r^r?r r r rqs   zMacroParameter.parsebitN)rrrrrrr r r r rjsrc@sVeZdZdZejZddZddZddZ dd Z d d Z d d Z ddZ ddZdS) MacroFunctionz*A function that was defined using a macro.cCs.t|_g|_|j}|||||dS)z#Parse a number of input parameters.N)rrvaluesrBr completemacro)r^r?macror r r rs  zMacroFunction.parsebitcCsP||t|j|||jt|jt|j|jkrLtdt |dS)z'Parse as many parameters as are needed.zMissing parameters in macro N) parseoptionalrqrparsemandatoryrr`rrrr)r^r?rr r r rszMacroFunction.parseparameterscCsg}x4|jt|r8|||t|t|krPqWx<|D]4}|}t|jdkrh|j|q@|j|q@W|j|7_dS)zParse optional parameters.rN) rrrrrrDr`r9rr)r^r?rr7rfr r r r rs zMacroFunction.parseoptionalcCs:x4t|D](}||||}|s&dS|j|q WdS)z'Parse a number of mandatory parameters.N)rparsemacroparameterrrr)r^r?rrIrCr r r rs zMacroFunction.parsemandatorycCs<|j||rdS|jt|r2|||S||S)z?Parse a macro parameter. Could be a bracket or a single letter.N)rrrrrF parsenumbersr)r^r? remainingr r r rs   z!MacroFunction.parsemacroparametercCs`|jt|}t|j|ks |Sx:|jD]0}|jt}|t|||_|j |q(WdS)z3Parse the remaining parameters as a running number.N) rrvrFr`rrr6r>rrrr)r^r?rrdigitrfr r r rs  zMacroFunction.parsenumberscCs|g|_dgt|j}xZ|tD]L}|jd}|t|jkrZtdt |dSd||<|j| g|_q(Wx0t t|jD]}||s| ||j|qWdS)z,Complete the macro with the parameters read.Fruz%Macro parameter index out of bounds: NT) r+rr`rr^rrrrrrrr)r^rr'rCrIr r r rs  zMacroFunction.completemacrocCs6dt|d}d|jd}|j||dS)z@Add a filter for the given parameter number and parameter value.rrur!rN)rjoinrrrr)r^rIrfrr r r rszMacroFunction.addfilterN)rrrrrrr<rrrrrrrrr r r r rzs  rc@s eZdZdZddZddZdS)rZz!A math macro defined in an inset.cCst|_t|_dS)N)rr}rr)r^r r r r_szFormulaMacro.__init__cCsdS)z"Return a printable representation.z Math macror )r^r r r rszFormulaMacro.__unicode__N)rrrrr_rr r r r rZsrZcCs2t}||}t||d|S)zConvert some TeX math to HTML.r!)rr{rrrr)r|rrr r r math2htmls   rcCsHtj}t|t|dkr.tdtt|d}t |dS)z=Main function, called if invoked from elyxer.the command lineruz"Usage: math2html.py escaped_stringrN) rargvryrgr`rrrrr )rdr~r r r mains    r__main__)robjectros.pathrrr%r(rqrrrr rrrr!r/r0rCr\ryrurllib.requestr urllib.parse urllib.errorrrrrrrrrrrrrrrrrrrrrrrr>rCrKrMrPrTrdr<r=r@rortrrrr>rErOrFr:rrDrrrrCrr unicodedatarrrrrrrrrrr\rer0r7r;r/r8r+r:r1r*rBrcr^r]r)rfrgrr9rhrrUrYrr"r#rVrWr7rArHrFrGrIrJrKrIrLrrJrMrYrZr\r`rfrirjrkrmrrMrNrrrrsrPr~rrrrrrrrrrrrrZrrrr r r r s`2K X #,"E] -M#     B D(v?8#> 2 "h,   F 8k K 6Yn         8/1>U;      B +  F; :$z *./X