U C^ @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 quietmodeshowsysstdoutclsmessager C/tmp/pip-install-6_kvzl1k/docutils/docutils/utils/math/math2html.pydebug%s z Trace.debugcCs2tjr dStjr tjr tj|}t|tjdS)zShow a trace messageN)rrprefix showlinesmoderrrrr r r r +s   z Trace.messagecCs0d|}tjrtjrtj|}t|tjdS)zShow an error messagez* N)rrrrrstderrrr r r error3s  z Trace.errorcCstd|tddS)z#Show an error message and terminatezFATAL: N)rrexitrr r r fatal:sz Trace.fatalcCs&tjdkr|d}||ddS)zShow a message out of a channelrutf-8 N)r version_infoencodewrite)r r Zchannelr r r r?s  z Trace.show)__name__ __module__ __qualname____doc__rrrrr 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)'BibStylesConfig+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.})@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)r#@bookr$r%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)r#r&z@bookletz @conferencez@inbook @incollection@inproceedingsz@manualz@mastersthesisz@miscz @phdthesisz @proceedingsz @techreportz @unpublishedr$r%z??)ZYYZauthorsZsurnameu~$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.})r#r&r'r(r$r%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 r!Rsh     r!c@seZdZdZdddZdS) BibTeXConfigr"—.)--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@dAdAdAdAdBdUdEdHdIdDdGdIdJdBdIdNdWdXdYdrDrA InsetLength LyXFormatLyXLineNewlineNewPager;rG StartAppendixrI)r)z#LyXz />rz z z )r  r N) rrrrcharscommandsentitieshtml iso885915 nonunicoder r r r r#sB rcS@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( FormulaConfigr"ÅÆ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\i\imathz\iotaz\j\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\beginrz\end\\)begin cellseparatorend rowseparatoru⎛u⎜u⎝u⎞u⎟u⎠u⎡u⎢u⎣u⎤u⎥u⎦u⎧u⎪u⎨u⎩|u⎫u⎬u⎭∥)()[]{r}ru⎲u⎳u⌠u⌡)∑∫span class="symbol"zz)\leftz\left.z\middle\rightz\right.üúûùūŭu̧ǔu⃛u̇ůu⃖u⃗u̩u⃝u̥ũ)z\"z\'z\^z\`z\acuter2z\brevez\cz\checkz\dddotz\ddotz\dotz\gravez\hatz \mathring\overleftarrow\overrightarrowz\rz\sz \textcircledz \textsubringz\tildez\vz\vecz\~rr)#$% ru 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⋍ru✗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≅©coscoshZcotZcothZcscu⋎u⋏u↶u↷†uℸu⇠u⊣‡u⋱degZdetu╲u╱u⌀u♦Zdim÷u⋇u∸u≐u≑u∔ru⌆↓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♥ 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ϙ 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©'°r-rrªº“”ru™²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\Yuprz\_z\alephz\amalgz\anchorz\anglez \aquariusz\arccosz\arcsinz\arctanz\argz\ariesz \arrowbulletz\astz\asympz \backepsilonz \backprimez \backsimeqrz\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 \heartsuitr5z\homz\hookleftarrowz\hookrightarrowz\hslashz \idotsintz\iiintz\iintrz\infz\inftyz \intercalz \interleavez\invampz\invnegrz\jupiterz\kerz\landz \landupintr}z\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\nequivr~z\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\})rrz\widehat\]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 HeaderConfigr"r|z\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)rHrIN)rrrr parametersZstylesr r r r r>s" b&r>c@s6eZdZdZddddZddddZd d d gd Zd S) ImageConfigr"zOconvert[ -density $scale][ -define $format:use-cropbox=true] "$input" "$output"z(inkscape "$input" --export-png="$output"zlyx -C "$input" "$output") imagemagickZinkscapeZlyxZpsZpdf).epsz.pdfz.psz.pngz.svgrN)r%ZvectorN)rrrr convertersZcropboxformatsformatsr r r r rL2srLc @s0eZdZdZdddddddd d d d d dg iZdS) LayoutConfigr"rbrLrMrPr9rJr@rKr:rHr?rRrSN)rrrrZ groupabler r r r rQDsrQc@s eZdZdZddddddZdS) NewfangleConfigr"z chunkref{rrrz=<)ZchunkrefZ endcommandZendmarkrZ startmarkN)rrrr constantsr r r r rRLsrRc @sDeZdZdZdddddgddgd Zd d d d dddddddg iZdS)NumberingConfigr"ChapterSection Subsection Subsubsection ParagraphPartBook)orderedromansymbolsrz**rrru§§ru¶¶rz##N)rrrrlayoutssequencer r r r rTTs rTc@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)/ StyleConfigr"u rrr)u  rr) 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‚rrrr)ZaldZalsZardZarsZeldZelsZerdZersZfldZflsZfrdZfrsZgldZglsZgrdZgrsZpldZplsZprdZprssldZsrdu(@↕)u¶↕u$↕u#↕u@↕u on-page#↕u @on-page#↕)Zeqref formattedZnamerefZpagerefrefZvpagerefZvref ignoredtextscoltextlinepageZtheightZpheightz
z
z
z
z
)ZbigskipZdefskipZmedskipZ smallskipZvfillN) rrrrhspacesquotesreferenceformatssizevspacesr r r r raasj rac @sfeZdZdZdddddddd d d d d g dgdgdZdddgdddd d d d d gddddddgdZdS) TOCConfigr"rLrMrPr9rJr@rKr:rHr?rRrSr)rarqrOrQrurkN)rrrrZ extractplainZ extracttitler r r r rosroc @seZdZdZddiZdddZddddd d d Zd d dgiZddddddddddd ZdddZ ddddZ dddZ dddd Z d!S)" TagConfigr"Zunderrzspan class="sans"r)ZsansZ typewriterzspan class="code"zspan class="menuitem"zspan class="noun"zspan class="strong")zCharStyle:CodezCharStyle:MenuItemZCodeZMenuItemZNounZStrongr_ QuotationQuotedivzh?h2h1 blockquote) ZCenterrUDaterYrZrqrrrVrWrXolul)Z EnumerateZItemizer)zspan class="greyedout")CommentZ Greyedoutrnrr) subscript superscriptrr)ZitalicZslantedZ smallcapsN) rrrrbarredfamilyZflexgroupr_ listitemsZnotesscriptshapedr r r r rpsTrpc%@sveZdZdZdddddddd d d d d ddddddddddddddddddd d!d"d#d$d%d&$Zd'd'd(d)d'd*d(d+d,d- Zd.S)/TranslationConfigr"Appendixr[rUrYrZrVrWrXrrrsfigurez Algorithm zFigure zListing zTable zTableau Z FootnoteszDocument generated by z on ZIndexz)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)$rr[rUrYrZrVrWrXZabstract bibliographyrzfloat-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 nomenclatureon-pageprev referencestocztoc-forZupendenlfrrues) americanZbritishdeutschdutchenglishfrenchZngermanrussianspanishN)rrrrrS languagesr r r r rs`rc@s8eZdZdZddZddZddZdd Zd d Zd S) CommandLineParserzA parser for runtime optionscCs ||_dSNoptions)selfrr r r __init__szCommandLineParser.__init__cCslt|dkrdSt|dkrh|ddrh||\}}|sHd|dS|sXd|dSt|j||qdS)Parse command line optionsrNr/zOption z not recognizedz needs a value)len startswith readoptionsetattrr)rargskeyvaluer 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 optionrNrrr)Tr#r) readequalskeyreplacehasattrrgetattr isinstanceboolrr readquoteddecodelistappend)rrrrcurrentinitialrr r r rs,       zCommandLineParser.readoptioncCstd|dd}t|dkrh|ddsh|ddshtd|d|d|d7}|d=qt|dks|ddrdS|d|dd 7}|S) zRead a value between quotesZOopsNrr#r/z Appending rr)rrrendswithr)rrrrr r r rs  (zCommandLineParser.readquotedcCs,|dd}|d}|d}|d||S)zRead a key using equalsrrr)splitinsert)rrrrrrr r r rs   zCommandLineParser.readequalskeyN) rrrrrrrrrr r r r rs   rc@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)rMcCsD|dt_|d=tt}||}|r8t|||dS)rrN)rlocationrrrrusageprocessoptions)rrparserresultr r r r`s   zOptions.parseoptionsc Cstjr|tjr|tjr*|tjr8|tj rF| tj rz,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 tt D],}|d rZt t |t!||d dqZd 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)"rhelprr= showversion hardversionshowhardversion versiondateshowversiondater; showlyxformat splitpartintrrlowmemrtocformemoryparsefootnotes forceformat imageformat copyimagescssfaviconr simplemath toctargetnocopyjsmathdirrrr)rparamr r r rksR             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)rrospathbasenamerr showoptionsrr r r rs    z Options.usagecCstjs dSdt_dt_dt_tjd}|D]2}|d}tt|rPtt|dq,t d|q,tj sxtjsxtjsxdt_tj stj sdt_dS)zParse footnotes options.NFrZfootTzUnknown footnotes option: ) rr marginfoot letterfoot hoverfootrrrrrendfoot numberfoot symbolfoot)rroptionZ 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)rrrrrr r r rsj                                                    zOptions.showoptionscCs:dtjd}|dtjdd7}t|tdS)z(Return the current eLyXer version stringzeLyXer version r< (r:rN)r9r=rrrrrrr r r rs zOptions.showversioncCsttjdtdS)zReturn just the version stringr<Nrr r9r=rrrr r r rszOptions.showhardversioncCsttjdtdS)zReturn just the version dter:Nrrr r r rszOptions.showversiondatecCsttjdtdS)z#Return just the lyxformat parameterr;Nrrr r r rszOptions.showlyxformat)Brrrrinstancerr copyrightr quietr=rrrrZ showlinesstrrrrtitle directoryZ destdirectoryrrrrr;targetrrrZnobib converterrawrmathjaxZnofooterrtemplateZ noconvertZ notoclabelsrrrrrrZsupfootZ alignfootrrrr$Zembedcssdictbranchesrrrrrrrrrr r r r r&s| .8rc@s0eZdZdZddZddZddZdd Zd S) BranchOptionszA set of options for a branchcCs||_ddi|_dS)Ncolorz#ffffff)namerrrr r r rszBranchOptions.__init__cCsB|tjds"td|dS|tjdd}||j|<dS)zSet a branch optionrzInvalid branch option Nr))rr1rrrrrrrrr r r set s zBranchOptions.setcCsd|jkrdS|jddkS)z Return if the branch is selectedselectedF1rrr r r isselecteds zBranchOptions.isselectedcCsd|jdt|jS)zString representationz options for r)rrrrr r r __unicode__szBranchOptions.__unicode__N)rrrrrrrrr 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__)r originalr r r clone*sz Cloner.clonecCs||}||S)z"Create an object of a given class.)__new__r)r typerr r r r/s z Cloner.createN)rrrrrrr r 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.rbrcrdNra)rconfigr r r r;s  zContainerExtractor.__init__cs<gfdd}fdd}fdd}||||S)z?Extract a group of selected containers from elyxer.a container.cs|jjjjkSr)rrrbrcrrr r Iz,ContainerExtractor.extract..cs|jjjkSr)rrrdr rr r r Jrcs |Sr)processr rrr r r Kr)recursivesearch)r containerlocate recursiverr rr extractFs   zContainerExtractor.extractcCsL|jj}||jkr||n*||jkr:|||ntd|dS)zBAdd allowed containers, clone cloned containers and add the clone.zUnknown container class N)rrrbrrc safeclonerr)rrrrr r r rOs    zContainerExtractor.processcCs"t|}|j|_|||_|S)zFReturn a new container with contents only in a safe list, recursively.)rroutputrcontents)rrrr r r rYs  zContainerExtractor.safecloneN)rrrrrrrrr r r r r 8s    r c@sHeZdZdZddZddZddZdd Zd d Zd d Z ddZ dS)ParserzA generic parsercCsd|_t|_dS)Nr)rrrKrr r r rhszParser.__init__cCs |}||j|_|S)zParse the header) currentlinernextline linenumberr)rreaderheaderr 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 parameterrNrrrTr#)rstriprparsexmlrKrrr)rrrrrZ doublesplitr r r parseparameterss"     zParser.parseparameterc Cs|}||ds0td|d|dd}t|dkrZtddS|d}|d=t|dkr~|tfSt}|D]V}d |krtd |d ||d 7}|d }|d}|dd d} | ||<q||fS)z5Parse a parameter in xml form: rzXML parameter z should be <...>rrrzEmpty XML parameter <>)NNrzErroneous attribute for rz="0"r#) rr rrrrrrr) rrr rrattrsattrpartsZattrkeyrr r r r!s,        zParser.parsexmlcCs8|jstdt|dS||js4|qdS)z'Parse until the current ending is foundzNo ending for N)endingrrrrr)rrrr r r parseendings zParser.parseendingcCs&|j|}|r"|j|_||dSr)factorycreatecontainerparentr)rrrrr r r parsecontainers zParser.parsecontainercCs|jjdt|jdS)zReturn a descriptionrr)rrrrrr r r rszParser.__unicode__N) rrrrrrr"r!r'r+rr r r r resrc@seZdZdZddZdS) LoneCommandz"A parser for just one command linecCsgS)z Read nothingr rrr r r parseszLoneCommand.parseNrrrrr.r r r r r,sr,c@s,eZdZdZgZddZddZddZdS) TextParserz(A parser for a command and a bit of textcCs8t|d|_|jjtjkr.tj|jj|_g|_dSr)rrr&rrr1rrrr r r rs  zTextParser.__init__cCsNtj|jtjtjdtjd|jg|_g}||sJ|||q2|S)z$Parse lines as long as they are textrCrB)r0stackrr&r1risendingr+rrrr r r r.s  zTextParser.parsecCsX|}t|dkrdS|d|jkrT|dtjkrJtj|dngt_dSdS)zCheck if text is endingrFT)rrrrr0r2remove)rrrr r r r3s  zTextParser.isendingN)rrrrr2rr.r3r r r r r0s  r0c@seZdZdZddZdS)ExcludingParserz%A parser that excludes the final linecs gfddS)z5Parse everything up to (and excluding) the final linecs Sr)r+r rrrr r r rz'ExcludingParser.parse..)r'r-r r7r r.szExcludingParser.parseNr/r r r r r6sr6c@seZdZdZddZdS) BoundedParserzA parser bound by a final linecCst||}||S)z*Parse everything, including the final line)r6r.rr4r r r r.s zBoundedParser.parseNr/r r r r r8sr8c@seZdZdZddZdS) BoundedDummyz&A bound parser that ignores everythingcs |fddgS)z#Parse the contents of the containercsSr)rr rr r r rz$BoundedDummy.parse..r'rr-r r:r r.szBoundedDummy.parseNr/r r r r r9sr9c@s eZdZdZddZddZdS) StringParserzParses just a stringcCs|jd|_gS)zDo nothing, just take noterrrr-r r r rs zStringParser.parseheadercCs|}||S)zParse a single line)rrr4r r r r.szStringParser.parseNrrrrrr.r r r r r<sr<c@seZdZdZddZdS) InsetParserzParses a LyX insetcCs<tjd}|dkr0||s0||q t||S)z(Parse inset parameters into a dictionaryrr))r1rrrr"r8r.)rrrr r r r. s  zInsetParser.parseNr/r r r r r?sr?c@s eZdZdZddZddZdS)ContainerOutputz(The generic HTML output for a container.cCstdt|dS)zShow an error.zgethtml() not implemented for Nrrrr1r r r gethtmlszContainerOutput.gethtmlcCsdS)z5Decide if the output is empty: by default, not empty.Fr rr r r isemptyszContainerOutput.isemptyN)rrrrrBrCr r r r r@sr@c@seZdZddZddZdS) EmptyOutputcCsgS)zReturn empty HTML code.r r1r r r rB#szEmptyOutput.gethtmlcCsdS)z"This output is particularly empty.Tr rr r r rC'szEmptyOutput.isemptyN)rrrrBrCr r r r rD!srDc@seZdZdZddZdS) FixedOutputz Fixed outputcCs|jS)zReturn constant HTML coderr1r r r rB.szFixedOutput.gethtmlNrrrrrBr r r r rE+srEc@seZdZdZddZdS)ContentsOutputz&Outputs the contents converted to HTMLcCs^g}|jdkr|S|jD]@}t|dsLtd|jjdt||S||7}q|S)Return the HTML codeNrBz No html in r)rrrrrrrrB)rrrelementr r r rB5s   zContentsOutput.gethtmlNrGr r r r rH2srHc@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)rrLrMrNr r r settagHs zTaggedOutput.settagcCs ||_|S)zSet the value for breaklines.)rM)rrMr r r setbreaklinesQszTaggedOutput.setbreaklinescCsB|jr||gS||g}|t||7}||||S)zReturn the HTML code.)rN selfclosingopenrHrBrclose)rrrr r r rBVs   zTaggedOutput.gethtmlcCs,|s dSd|jd}|jr(|dS|S)zGet opening line.r)rrrchecktagrLrM)rrrRr r r rR_s zTaggedOutput.opencCs8|s dSd|jdd}|jr4d|dS|S)zGet closing line.r)zGlob a bit of text that satisfies a check on the current char.r))rpr~)rZ currentcheckglobr r r rHsz Globable.globcsfddS)zGlob a bit of alpha textcs Srrisalphar rr r r Qrz$Globable.globalpha..rrr rr globalphaOszGlobable.globalphacsfddS)zGlob a row of digits.cs Srrisdigitr rr r r Urz%Globable.globnumber..rrr rr globnumberSszGlobable.globnumbercCs |s|dkrdSdS)z5Return if the current character is alphanumeric or _.rTF)risalnumrr r r isidentifierWszGlobable.isidentifiercCs ||jS)z Glob alphanumeric and _ symbols.)rrrr r r globidentifier]szGlobable.globidentifiercCs$|rdS|dkr dSdS)z5Return if the current character is a value character:Fz{}()Trisspacerr r r isvalueas   zGlobable.isvaluecCs ||jS)z'Glob a value: any symbols but brackets.)rrrr r r globvaluejszGlobable.globvaluecsfddS)z(Skip all whitespace at current position.cs Srrr rr r r prz$Globable.skipspace..rrr rr skipspacenszGlobable.skipspacecs&fdd}|S)z4Glob a bit of text up to (including) the magic char.cs kSrrr  magiccharrr r r trz(Globable.globincluding..)rskip)rrrr rr globincludingrs zGlobable.globincludingcsfddS)z?Glob a bit of text up until (excluding) any excluded character.cs kSrrr excludedrr r r zrz(Globable.globexcluding..r)rrr rr globexcludingxszGlobable.globexcludingcCs|j||dS)zPush a new ending to the bottomN)r|addrr&optionalr 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 )rrr|poprrr)rexpectedr&r r r popendings   zGlobable.popendingcCs|j|}|sdS|jS)z$Return the next ending in the queue.N)r| findendingr&)r nextendingr r r rs zGlobable.nextending)F)N)rrrrrrrrrrrpr~rrrrrrrrrrrrrr r r r rzs,   rzc@sReZdZdZddZdddZddZd d Zd d Zd dZ ddZ ddZ dS)r{zA list of position endingscCs g|_dSr)rrr r r rszEndingList.__init__FcCs|jt||dS)zAdd a new ending to the listN)rrPositionEndingrr r r rszEndingList.addcCs|j|jj7_dS)z/Pick any pending endings from a parse position.N)rr|rposr r r pickpendingszEndingList.pickpendingcCs||rdSdS)zSearch for an endingTF)rrr r r rs zEndingList.checkincCs|rtddS||}|s:td|dSt|jD]6}|j|||krf|jS|j sDtd|qDtddS)z)Remove the ending at the current positionzNo ending out of boundsr)z No ending at zRemoved non-optional ending zNo endings left) rrrrrreversedrr5r&r)rrr&Zeachr r r rs     zEndingList.popcCsLt|jdkrdStt|jD]&\}}||r:|S|js dSq dS)z'Find the ending at the current positionrN)rr enumeraterrr)rrrr&r r r rs zEndingList.findendingcCs(t|jdkr$tdt|ddS)z&Check if there are any pending endingsrzPending z left openN)rrrrrrr r r rszEndingList.checkpendingcCsBd}|jD]}|t|d7}q t|jdkr:|dd}|dS)Printable representationz endings [rrNrr)rrr)rrr&r r r rs   zEndingList.__unicode__N)F) rrrrrrrrrrrrr r r r r{s  r{c@s(eZdZdZddZddZddZdS) rz An ending for a parsing positioncCs||_||_dSrr&rrr r r rszPositionEnding.__init__cCs ||jS)zCheck for the ending)rr&rr r r rszPositionEnding.checkincCsd|j}|jr|d7}|S)rzEnding z (optional)rrr r r rs zPositionEnding.__unicode__N)rrrrrrrr r r r rsrc@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|dSr)rzrrr r r rszPosition.__init__cCstddS)z Skip a stringzUnimplemented skip()Nrrr r r rsz Position.skipcCstddS)z.Return an identifier for the current position.zUnimplemented identifier()Errorrrr r r identifiers zPosition.identifiercCstddS)zHExtract the next string of the given length, or None if not enough text,zUnimplemented extract()Nrrlengthr r r rs zPosition.extractcCs||t|kS)z)Check for a string at the given position.)rrrr r r rszPosition.checkforcCs0|t|}|sdS||t|kS)z!Check for a string in lower case.F)rrlower)rrrdr r r checkforlowerszPosition.checkforlowercCs|}|||S)r)rrrrr r r r~s zPosition.skipcurrentcCs||S)z3Advance the position and return the next character.)r~rrr r r __next__ szPosition.__next__cCs||sdS||dS)z;Check for a string at the given position; if there, skip itFT)rrrr r r checkskips  zPosition.checkskipcCst|d|dS)z2Show an error message and the position identifier.rN)rrr)rr r r r rszPosition.errorN)rrrrrrrrrrr~rrrr r r r rsrc@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)rrrrgrrrgr r r rs zTextPosition.__init__cCs|jt|7_dS)Skip a string of characters.N)rrrr r r r&szTextPosition.skipcCsFd}|j|t|jkr(t|j|j}d|j|j|j|dS)z&Return a sample of the remaining text.rrrrgrr r r r*szTextPosition.identifiercCs|jt|jkS)'Find out if we are out of the text yet.rrr r r r1szTextPosition.isoutcCs |j|jS)6Return the current character, assuming we are not out.)rgrrr r r r5szTextPosition.currentcCs.|j|t|jkrdS|j|j|j|SzHExtract the next string of the given length, or None if not enough text.Nrrr r r r9szTextPosition.extractN) rrrrrrrrrrr r r r rsrc@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)rrr]rrrrsr r r rBs  zFilePosition.__init__cCsXt|}|j|t|jkrF|t|j|jd8}|q|j|7_dS)rrN)rrrrr)rrrr r r rIs  zFilePosition.skipcCs |jS)z,Get the current line of the underlying file.)rrrr r r rQszFilePosition.currentlinecCs|jd|_dS)zGo to the next line.rN)rrrrr r r rUs zFilePosition.nextlinecCs |jjdS)z#Return the line number of the file.r)rrrr r r rZszFilePosition.linenumbercCsL|jd|jd}|j|jd}dt|d|d|S)z4Return the current line and line number in the file.Nrzline rr)rrrrZ getlinenumber)rbeforeafterr r r r^szFilePosition.identifiercCs`|jt|jkrV|jt|jdkrNtd|jdt|j||jS)rrOut of the line r) rrrrrrrrrprr r r rds "zFilePosition.isoutcCsb|jt|jkrdS|jt|jkrRtd|jdt|jdS|j|jS)rrrrr)rrrrrrrrr r r rls "zFilePosition.currentcCs6|j|t|jkrdS|j|j|j|Sr)rrrrrr r r ruszFilePosition.extractN) rrrrrrrrrrrrrr r r r r?s rc@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|_dSr)rrrr r r rszContainer.__init__cCsdS)Process contentsNr rr r r rszContainer.processcCs4|j|}t|tr*td||g}||S)zGet the resulting HTMLz Raw string )rrBrrrr escapeall)rrr r r rBs   zContainer.gethtmlcCsdg}|D]V}tjr ||tj}tjr@||tj}||}ntjsT||tj}||q|S)z=Escape all lines in an array according to the output options.) rrescaperrescapeentitiesrrr)rlinesrrhr r r rs  zContainer.escapeallcCs:t|}||D]}||kr||||}q|S)z1Escape a line with replacements from elyxer.a map)rkeyssortr)rrh replacementspiecespiecer r r rs  zContainer.escapecCsd}t|}|st|dkrjtt|}|dkrPttt|d}|d|ddd7}n ||7}|q |S) z/Escape all Unicode characters to HTML entities.r)Z0xd835iz&#rNr")rrpr}rhexrr~)rrhrr codepointr r r rs  zContainer.escapeentitiescsg||fddS)z2Search for all embedded containers of a given typecs |Sr)rrrr r r rz%Container.searchall..) searchprocessrr r rr searchallszContainer.searchallcCs&||}|D]}|jj|q|S)z3Search for all containers of a type and remove them)rr*rr5)rr rrr r r searchremoves zContainer.searchremovecs|fdd|dS)z4Search for elements of a given type and process themcs t|Sr)rrr r r r rz)Container.searchprocess..N) locateprocess)rr rr rr rszContainer.searchprocesscCs,|jD] }|||||r||qdS)z3Search for all embedded containers and process themN)rr)rrrrr r r rs  zContainer.locateprocesscCs6|jD]*}||r ||||||r||qdS)z,Perform a recursive search in the container.N)rr)rrrrrr r r rs  zContainer.recursivesearchcCs,d}ttj|}|D]}||j7}q|S)z0Extract all text from elyxer.allowed containers.r))r r1rrr)rrrSconstantr r r rs  zContainer.extracttextcCs|t|jkrdSt|j|dr&dS|t|jkrn||j|rnd|j|_|j|j||j|q&|j||dS)z*Group some adjoining elements into a groupNgroupedT)rrrrrrr)rrrZ isingroupr r r rs zContainer.groupcCs>|j|}|j|t|jdkr:|j||jqdS)z)Remove a container but leave its contentsrN)rrrr)rrrr r r r5s  zContainer.removercCs4td|t||jD]}||dqdS)zShow in a treerrN)rr rrtree)rlevelrr r r rs zContainer.treecCs||jkrdS|j|S)z)Get the value of a parameter, if present.N)rKrr r r getparameters zContainer.getparametercCs||}|sgS|dS)z7Get the value of a comma-separated parameter as a list.r)rr)rr paramtextr r r getparameterlist s zContainer.getparameterlistcCs$|j}|r |jrdS|j}qdS)z&Check if the parent's output is empty.TF)r*rrCrr r r hasemptyoutput s  zContainer.hasemptyoutputcCs$|js|jjS|jjdt|jS)zGet a descriptionr)rrrrrr r r r szContainer.__unicode__)r)rrrrpartkeyr*rrrrBrrrrrrrrrrrrr5rrrrrr r r r r}s.    rc@seZdZdZddZdS)rgz)A container that does not output anythingcCst|_t|_g|_dSr)r,rrDrrrr r r r szBlackBox.__init__Nrrrrrr r r r rg srgc@seZdZdZddZdS)rwzRead the lyxformat commandcCsPt|jd}|dkr(tdt||ttjdkrLtdt|dS)zShow warning if version < 276riz(Warning: unsupported old format version r;z(Warning: unsupported new format version N)rrrrrr9r=)rr=r r r r" s zLyXFormat.processNrrrrrr r r r rw srwc@sDeZdZdZdZddZddZddZd d Zd d Z d dZ dS)rLzA container for a single stringNcCst|_t|_d|_dS)Nr))r<rr[rrrr r r r/ szStringContainer.__init__cCs|jr||j|_d|_dS)z/Replace special chars from elyxer.the contents.N)parsedreplacespecialrrr r r r4 szStringContainer.processcCsf||tj}||}tjd|krbt|dkrb|jrLdt|jd}nd}t || |S)z,Replace all special chars from elyxer.a linerrzUnknown command at rzUnknown command: ) rrr changeliner1rrrrrrr )rrhr0r r r r r: s zStringContainer.replacespecialcCs2||tj}tjd|kr |S||tj}|S)Nr)rrrr1rrrxr r r rG s zStringContainer.changelinecCs|jS)zReturn all text.r\rr r r rN szStringContainer.extracttextcCsXd}|jr|dt|j7}d}t|jdkr6d}|d|jdd|dS) "Return a printable representation.rLrz...r)rNr)rrrrr )rrZellipsisr r r rR szStringContainer.__unicode__) rrrrrrrrrrrr r r r rL* s rLc@s eZdZdZddZddZdS)rMzA constant stringcCsg|_||_t|_dSr)rrr[rrr r r r_ szConstant.__init__cCs d|jS)Nz Constant: r\rr r r rd szConstant.__unicode__Nrrrrrrr r r r rM\ srMc@s8eZdZdZdZddZd ddZd dd Zd d ZdS)rPzText inside a tagNcCst||_t|_dSr)r0rrKrrr r r rl s zTaggedText.__init__FcCs||_||j_||j_|S)z&Complete the tagged text and return it)rrrLrMrrrLrMr r r completep szTaggedText.completecCst|}||g||S)z(Complete the tagged text with a constant)rMr)rrgrLrMrr r r rw szTaggedText.constantcCs,t|jdsdS|jjsdSd|jjdS)rrLzEmtpy tagged textzTagged zTagged r r r r r src@sTeZdZdZdZdZdZddZddZd d Z d d Z d dZ ddZ ddZ dS) FormulaBitzA bit of a formulaNrr)cCsg|_t|_dS)z6The formula bit type can be 'alpha', 'number', 'font'.N)rrHrrr r r r szFormulaBit.__init__cCs ||_|S)z!Set the internal formula factory.)r()rr(r r r setfactory% szFormulaBit.setfactorycCs&|j||j|j7_||_dS)z-Add any kind of formula bit already processedN)rrrr*rbitr r r r* s zFormulaBit.addcCs6|j|7_||s2td|d|dS)z0Skip a string and add it to the original formulazString z not at N)rrrrr)rrrr r r skiporiginal0 s zFormulaBit.skiporiginalcCs.t|jdkrdStdd|jD|_|jS)zDCompute the size of the bit as the max of the sizes of all contents.rrcSsg|] }|jqSr rm.0rJr r r : sz*FormulaBit.computesize..)rrrrmrr r r computesize6 szFormulaBit.computesizecCs|j|jSzReturn a copy of itself.)r(rrrr r r r= szFormulaBit.clonecCs|jjd|jS)zGet a string representationz read in )rrrrr r r rA szFormulaBit.__unicode__)rrrrr rmrrrrr rrrr r r r r src@s*eZdZdZddZd ddZddZd S) TaggedBitzA tagged string in a formulacCs t||_|t||SzSet the constant and the tag)rKrOrrrN)rrrLr r r rH szTaggedBit.constantFcCs||_t|||_|Sr)rrKrOrrr r r rN szTaggedBit.completecCstj|dd|_|S)z4Set the self-closing tag, no contents (as in
).T)rN)rKrOrrrLr r r selfcompleteT szTaggedBit.selfcompleteN)F)rrrrrrrr r r r rE s rc@s0eZdZdZddZddZddZdd Zd S) rNzA constant string in a formulacCs"t||||_d|_d|_dS)zSet the constant stringrN)rMrrrmr rr r r r\ s zFormulaConstant.__init__cCs|jS)z+Compute the size of the constant: always 1.r rr r r rc szFormulaConstant.computesizecCs t|jSr)rNrrr r r rg szFormulaConstant.clonecCs d|jS)rzFormula constant: r\rr r r rk szFormulaConstant.__unicode__N)rrrrrrrrr r r r rNY s rNc@s eZdZdZddZddZdS)rUzA bit of text inside a formulacCs |S)zDetect a bit of raw textrrr r r detectr szRawText.detectcCs |}|t|d|_dS)zParse alphabetic textr*N)rrrNr )rrr*r r r parsebitv szRawText.parsebitNrrrrrrr r r r rUo srUc@s8eZdZdZejZejdZddZddZddZ d S) r_zA symbol inside a formularcCs(|tjkrdS|tjkr$dSdS)zDetect a symbolTF)rr_r7r2rr r r r s zFormulaSymbol.detectcCsd|tjkr"|||dS|tjkrJ|tj||dStd|ddS)Parse the symbolNzSymbol not found)rr_r7 addsymbolr2rrrr r r r szFormulaSymbol.parsebitcCs$||||jt|dS)z Add a symbolN)r rrrrN)rsymbolrr r r r szFormulaSymbol.addsymbolN) rrrrrr2r7rrrr r r r r_| s   r_c@s eZdZdZddZddZdS)rVzA string of digits in a formulacCs |S)zDetect a digitrrr r r r szFormulaNumber.detectcs*fdd}|t|d|_dS)zParse a bunch of digitscs Srrr rr r r  rz(FormulaNumber.parsebit..r<N)rrrNr )rrdigitsr rr r szFormulaNumber.parsebitNrr r r r rV srVc@s*eZdZdZejdZddZddZdS)rzz*A LaTeX comment: % to the end of the line.rcCs||jkS)z Detect the %.)rrrr r r r szComment.detectcCs|j|d7_dS)zParse to the end of the line.rN)rrrr r r r szComment.parsebitN) rrrrrrrrrr r r r rz s rzc@s(eZdZdZddZddZddZdS) WhiteSpacez"Some white space inside a formula.cCs |S)zDetect the white space.rrr r r r szWhiteSpace.detectcCs|j|7_dS)zParse all whitespace.N)rrrr r r r szWhiteSpace.parsebitcCsd|jdS)rz Whitespace: *r)rrr r r r szWhiteSpace.__unicode__N)rrrrrrrr r r r r src@sleZdZdZejdZejdZddZ ddZ ddZ d d Z d d Z d dZddZddZddZdS)rTzA {} bracket inside a formularcCst|d|_dS)z'Create a (possibly literal) new bracketN)rrinnerrr r r r s zBracket.__init__cCs ||jS)zDetect the start of a bracket)rrrr r r r szBracket.detectcCs|||j|S)zParse the bracket) parsecomplete innerformularr r r r szBracket.parsebitcCs|||j|S)zParse a text bracket)r  innertextrr r r parsetext szBracket.parsetextcCs|||j|S)zParse a literal bracket)r  innerliteralrr 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) rrrrrr rr&rrr)rrZ innerparserr r r r  s  zBracket.parsecompletecCs |s||j|qdS)z(Parse a whole formula inside the bracketNrprr(parseanyrr r r r! szBracket.innerformulacCsttj}|tjd|tjd|tj|s| |krz| |j || dr|jd7_q:| t|q:dS)zTraverse over the contents to alter variables and space units.Nr*fontr<rr)traverser  italicizerrrN)rrlastr rr r r r/> s zFormulaProcessor.traversewholeccsN|jD]B}t|dr(|jr(||jfVqt|tr||D] }|Vq|jddkrtd|_ntd|_t|jg|_dS)zMake the contents for jsMath.rrzdiv class="math"zspan class="math"N)rrKrOrrMrrrr 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/texrrz ;mode=displayr#TN)rrLrrPrrrrr 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/.r$zzN)rr8urllibr. quote_plusrrMr)rurlimgr r r r$ szFormula.googlechartscCs,t|j}t|||_|g|_dS)zEMake the contents using classic output generation with XHTML and CSS.N)FormulaFactoryrrr,rr*r)rwholer r r r7 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\)rrzUnparseable formula)rparsedollarblockparsedollarinline parseinlineto parseblocktorrrr r r r. s       z Formula.parsecCsdg|_||dS)zParse a $...$ formula.rN)r parsedollarrr r r r? szFormula.parsedollarinlinecCs*dg|_|||ds&|ddS)zParse a $$...$$ formula.rrz1Formula should be $$...$$, but last $ is missing.N)rrBrrrr r r r> s  zFormula.parsedollarblockcCs$|d|d|_|ddS)zParse to the next $.rN)rrrrrr r r rB s  zFormula.parsedollarcCsdg|_|||dS)zParse a \(...\) formula.rNr parseuptorrlimitr r r r@ szFormula.parseinlinetocCsdg|_|||dS)zParse a \[...\] formula.rNrCrEr r r rA szFormula.parseblocktocCs(|||dd|_||dS)z1Parse a formula that ends with the given command.cSsdSNTr r r r r r  rz#Formula.parseupto..N)rrrrrEr r r rD s zFormula.parseuptocCs"|jr|jjrd|jjdSdS)rz Formula (rzUnnumbered formula)rr<rr r r r szFormula.__unicode__N)rrrrrrrrr$r7r.r?r>rBr@rArDrr r r r rSY srSc@s eZdZdZddZddZdS) WholeFormulazParse a whole formulacCs | S)z"Not outside the formula is enough.)rprr r r r szWholeFormula.detectcCs |s||j|qdS)zParse with any formula bitNr&rr r r r szWholeFormula.parsebitNrr r r r rH srHc@steZdZdZeeeeee gZ ee gZ dZ ddZ ddZddZd d Zd d Zd dZddZddZddZdS)r<zConstruct bits of formulaFcCs t|_dS)z Initialize the map of instances.N)r instancesrr r r r szFormulaFactory.__init__cCs|r dS|||S)zDetect a bit of a given type.F)rprr)rr rr r r detecttype szFormulaFactory.detecttypecCs.||jks|j|s$|||j|<|j|S)z"Get an instance of the given type.)rIrrr r r r szFormulaFactory.instancecCst||S)z+Create a new formula bit of the given type.)rrrrr r r r szFormulaFactory.createcCs|s||sdSqdS)zClear any skipped types.N)rpskipanyrr r r clearskipped s zFormulaFactory.clearskippedcCs0|jD]$}|||r|||SqdS)zSkip any skipped types.N) skippedtypesrrrrrr r r r rK s zFormulaFactory.skipanycCsL|j|jD] }|||r |||Sq td|t|S)z.Parse any formula bit at the current location.zUnrecognized formula at ) typesrMrJrrrrrNr~rNr r r r' s  zFormulaFactory.parseanycCs0||}d|j|<||}|r,||S|S)z#Parse the given type and return it.N)rrIrr)rr rr Z returnedbitr r r r s     zFormulaFactory.parsetypecCs\t|}|t}||r*|||S|sXtd|| t |d|S)z5Parse a string of text that contains a whole formula.zUnknown formula at: span class="unknown") rrrHrrrprrrrrr)rrrr=r r r r s   zFormulaFactory.parseformulaN)rrrrr_rUrVrTrzrrOrMdefiningrrJrrrLrKr'rrr r r r r< s r<c@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)r rr r r translate1 szTranslator.translatecCsd|_d|_dSrG) translationfirstrr r r r7 szTranslator.__init__cCsd|_tjstddStjtjkr:tdtjdStjtjdkrNdStjtjg}ztdd||_Wn&t k rtdt |YnXdS)z/Find the translation for the document language.NzNo language in documentzUnknown language rZelyxerzNo translation for ) langcodesrrCrrrrgettextrUIOErrorr)rrWr r r findtranslation; s  zTranslator.findtranslationcCsR|jr|d|_||}|js(|Sz|j|}Wntk rLYnX|S)z-Get the translated message for the given key.F)rVrZgetuntranslatedrUZugettextrY)rrr r r r rSL s zTranslator.getmessagecCs&|tjkrtd||Stj|S)zGet the untranslated message.zCannot translate )rrSrrrrr r r r[Z s zTranslator.getuntranslated) rrrrrrTr rrZrSr[r r r r rR+ srRc @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^)Mrm)ZCMi)Di)ZCDi)Cd)ZXCZ)L2)ZXL()Xr)ZIX )V)ZIV)IrcCs ||_dS)zGive a name to the counter.N)rrr r r rv szNumberCounter.__init__cCs ||_|S)z0Set the counter mode. Can be changed at runtime.)r)rrr r r setmodez szNumberCounter.setmodecCs ||_dS)zSet an initial value.Nrrrr r r init szNumberCounter.initcCs t|jS)z$Get the next value as a text string.)rrrr r r rX szNumberCounter.gettextcCs ||jS)zGet the next value as a letter.) getsequencelettersrr r r getletter szNumberCounter.getlettercCs ||jS)zGet the next value as a symbol.)rqr^rr r r getsymbol szNumberCounter.getsymbolcCs||jdt|S)z*Get the next value from elyxer.a sequence.r)rr)rr`r r r rq szNumberCounter.getsequencecCs>d}|j}|jD](\}}||kr||||7}||}q|S)z%Get the next value as a roman number.r))r romannumerals)rrr<Znumeralrr 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.)rgrAarlrzUnknown counter mode )rrXrsrrvrtrrrr r r getvalue s     zNumberCounter.getvaluecCs"|js d|_|jd7_|S)z@Increase the current value and get the next value as configured.rr)rryrr r r getnext szNumberCounter.getnextcCs d|_dS)zReset the counter.rNrnrr r r reset szNumberCounter.resetcCs"d|j}|jr|d|j7}|S)rzCounter z in mode )rrrrr r r r s zNumberCounter.__unicode__)rrrrrrrmasterrrrTr`r^rurrmrprXrsrtrqrvryrzr{rr r r r r]e sB  r]c@s(eZdZdZddZddZddZdS) DependentCounterz4A counter which depends on another one (the master).cCs||_|j|_|S)zSet the master counter.)r}ryr5)rr}r r r setmaster s zDependentCounter.setmastercCs2|j|jkr|t|}|j|_|S)z8Increase or, if the master counter has changed, restart.)r5r}ryr{r]rzror r r rz s   zDependentCounter.getnextcCs|jdt|S)z8Get the value of the combined counter: master.dependent.r.)r}ryr]rr r r ry szDependentCounter.getvalueN)rrrrrrzryr r r r r~ sr~c@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 rr xr r r r szNumberGenerator.r]cCsg|] }|qSr rrr r r r sr\cCs |ddS)z.Remove the possible asterisk in a layout type.rr))rrr r r deasterisk szNumberGenerator.deasteriskcCs ||S)z9Find out if the layout type corresponds to a unique part.)isromanrr r r isunique szNumberGenerator.isuniquecCs|||jkS)z9Find out if the layout type should have roman numeration.)rr romanlayoutsrr r r r szNumberGenerator.isromancCs|||jkS)z?Find out if the layout type corresponds to an (un)ordered part.)rrorderedlayoutsrr r r isinordered szNumberGenerator.isinorderedcCs@d|kr dS||rdS||s(dS||tjkrrFrr r r r szLyXLine.processNrr r r r rx srxc@seZdZdZddZdS)r@zText with emphatic modecCs d|j_dS)NrrrLrr r r r szEmphaticText.processNrr r r r r@ sr@c@seZdZdZddZdS)rGzText shaped (italic, slanted)cCsL|jd|_|jtjkr8td|jdd|j_dStj|j|j_dS)NrzUnrecognized shape span)rr rprrrrrLrr r r r s   zShapedText.processNrr r r r rG srGc@seZdZdZddZdS)rKzText in versalitascCs d|j_dS)Nrrrr r r rszVersalitasText.processNrr r r r rKsrKc@seZdZdZddZdS)r?z Colored textcCs"|jd|_d|jd|j_dSNrz span class="r#)rrrrLrr r r r s zColorText.processNrr r r r r?sr?c@seZdZdZddZdS)rHz Sized textcCs"|jd|_d|jd|j_dSr)rrmrrLrr r r rs zSizeText.processNrr r r r rHsrHc@seZdZdZddZdS)r;z Bold textcCs d|j_dS)Nrrrr r r rszBoldText.processNrr r r r r;sr;c@seZdZdZddZdS)rJz,A bit of text from elyxer.a different familycCsF|jd|_|jtjkr2tdtd|j_dStj|j|j_dS)zParse the type of familyrzUnrecognized family rN)rr rpr~rrrrLrr r r rs   zTextFamily.processNrr r r r rJsrJc@seZdZdZddZdS)rAzHorizontall fillcCs d|j_dS)Nzspan class="hfill"rrr r r r+sz Hfill.processNrr r r r rA(srAc@seZdZdZddZdS)r:zText with a bar somewherecCsH|jd|_|jtjkr4td|jd|j_dStj|j|j_dS)zParse the type of barrzUnknown bar type rN)rr rpr}rrrrLrr r r r1s   zBarredText.processNrr r r r r:.sr:c@seZdZdZddZdS)rRz A line with language informationcCsF|jd}|tjkr t|_dStj|}td|dd|_dS)zDOnly generate a span with lang info when the language is recognized.rNz span lang="r#F)rrrrHrrKrO)rlangZisolangr r r r=s    zLangLine.processNrr r r r rR:srRc@seZdZdZddZdS)rvz!A length measure inside an inset.cCs|jd|_dS)Nr)rrrr r r rIszInsetLength.processNrr r r r rvFsrvc@s(eZdZdZddZddZddZdS) rqzA space of several typescCst|_t|_dSrr?rrErrr r r rOszSpace.__init__cCsz|jd|_|jtjkr4td|jdg|_dStj|jg|_|}|sTdSt dd|_ t | |dS)NrzUnknown space type rzspan class="hspace"F)rr rarjrrr getlengthrKrOrrrrrr r r rSs  z Space.processcCs.t|jdkst|jdts"dS|jdjS)z.N) instantiater stagedict)rclassesrrIr r r rGs zStageDict.__init__cCs*dd|D}|D]}|||_q|S)z-Instantiate an element from elyxer.each classcSsg|]}||qSr )rrr r r rNsz)StageDict.instantiate..)rr)rrrrrJr r r rLs zStageDict.instantiatecCs|j|jkrdS|j|jS)z=Get the stage for a given element, if the type is in the dictN)rrrrJr r r rTs zStageDict.getstageN)rrrrrrrr r r r rDsrc@sLeZdZdZeZdZddZddZdddZ d d Z d d Z d dZ dS)rizA label to be referencedNcCst|d|_dSr)rr lastnumberedrr r r rbs zLabel.__init__cCs"|d}|d|tj|_dS)zProcess a label container.rrN)rrri lastlayoutrr\r r r rfs  z Label.processcCsD||_|j|||d|tj|<|tjkr@tj|D] }||_q4|S)z!Create the label for a given key.)rr )rrrinamesrjrr)rrgrr  referencer r r rls  z Label.createcCs||}|r|jr|jSdS)z8Get the part key for the latest numbered container seen.r))rr)rrr r r findpartkeyvs  zLabel.findpartkeycCs,|jr |S|js |jr|jSdS||jS)z)Get the numbered container for the label.N)rr*rrr1r r r r}szLabel.numberedcCst|dsdSd|jS)rrz Unnamed labelzLabel )rrrr r r rs zLabel.__unicode__)ri) rrrrrrrrrrrrrr r r r ri\s  ric@s:eZdZdZeZdZddZddZddZ d d Z d S) rjzA 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.rrrrZprerefN) rrrir directionrrformatcontentsrjrr)rlabelr 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|_|d d D]$}|j|j7_|jt|qd S)zFormat the reference contents.Z LatexCommandrdrzUnknown reference format rrrrrrNrr)rrcrarlrrrrrRrTrrr<ZtocentryZ titlecontentsrMrrr)rZ formatkeyrrrr r r rs*     zReference.formatcontentscCs*||jkrdS|sd}|j|||_dS)z2Replace a key in the format template with a value.Nr))rcrrr r r rs  zReference.replacecCs d|jS)rz Reference )rrr r r rszReference.__unicode__N) rrrrrrrrrrrr r r r rjsrjc@sZeZdZdZgZejdZdZddZ ddZ dd Z d d Z d d Z ddZddZdS)FormulaCommandz A LaTeX command inside a formularNcCs |tjS)zFind the current command.)rrrrr r r rszFormulaCommand.detectcCs|||}|||}|r|S|ds2|drF|||}|rF|S|jjs\td|t d|_ | t |dS)zParse the command.\up\UpzUnknown command rPN) extractcommandparsewithcommandr parseupgreekr(rQrrrKrOrrrN)rrrr upgreekr r r rs   zFormulaCommand.parsebitcCs,tjD] }||jkr||||SqdS)z0Parse the command type once we have the command.N)rrO commandmapparsecommandtype)rrrr r r r rs  zFormulaCommand.parsewithcommandcCs,|j|}||||}|r(|S|S)zParse a given command type.)r(r setcommandr)rrr rr Zreturnedr r r rs    zFormulaCommand.parsecommandtypecCsh|tjs |dtjdS|r2||S|rZtj|}|d|Stj| S)z5Extract the command from elyxer.the current position.zMissing command start Nr) rrrrrp emptycommandrrrr~)rrrr r r rs    zFormulaCommand.extractcommandcCs0d}|s&|}|r&||r&|}tj|S)zqCheck for an empty command: look for command disguised as ending. Special case against '{ \{ \} }' situation.r))rrrrr)rrrr&r r r rs zFormulaCommand.emptycommandcCst|dkrdS|dr,d|dd}n>|drXd|dd|dd}ntd|dS|||}|rd|_|S) zParse the Greek \up command..rkNrrrrzImpossible upgreek command: r2)rrrupperrrrr )rrrZ upcommandrr r r rs   " zFormulaCommand.parseupgreek)rrrrrOrrrrrrrrrrrr r r r rs   rc@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)rrr translated)rrr r r r#szCommandBit.setcommandcCs2|j||rdS|j|}|||S)z)Parse a parameter at the current positionN)r(rLrpr'r)rr parameterr r r r"*s    zCommandBit.parseparametercCs:|j||jt|sdS|jt|}|||S)zParse a square bracketN)r(rLrJr)rrrrrr r r parsesquare3s   zCommandBit.parsesquarecCsd|j||jt|s@|s8td|dS|St |j}| | ||j S)zParse a literal bracket.zNo literal parameter found at: N) r(rLrJrTrrrrrrrr%r(rr r r r%<s zCommandBit.parseliteralcCsB|j||jt|sdSt|j}||||jS)z!Parse a square bracket literally.N)r(rLrJr)rrr%r(rr r r parsesquareliteralHs  zCommandBit.parsesquareliteralcCsP|j||jt|s.td|jdSt|j|}| ||S)zParse a text parameter.zNo text parameter for N) r(rLrJrTrrrrr#rrr r r r#Qs  zCommandBit.parsetextN) rrrrrr"rr%rr#r r r r r s    rc@seZdZdZejZddZdS)rXz%An empty command (without parameters)cCst|jg|_dS)"Parse a command without parametersNrNrrrr r r r`szEmptyCommand.parsebitN)rrrrrrrrr r r r rX[srXc@seZdZdZejZddZdS) SpacedCommandzFind a function which is represented by a symbol (like _ or ^)cCs|tjkS)zFind the symbol)rrZrrr r r rszSymbolFunction.detectcCs8||||jt|j|_||dS)rN) rrrrrKrOrrr"rr r r rs zSymbolFunction.parsebitN) rrrrrr5rrrr r r r rZsrZc@s&eZdZdZejZddZddZdS)r[z-A function where parameters are read as text.cCst|j|_||dS)zParse a text parameterN)rKrOrrr#rr r r rszTextFunction.parsebitcCs d|_dS)zSet the type to fontr2Nrrr r r rszTextFunction.processN) rrrrrr6rrrr r r r r[sr[c@s&eZdZdZejZddZddZdS) LabelFunctionzA function that acts as a labelcCs|||_dS)zParse a literal parameterN)r%rrr r r rszLabelFunction.parsebitcCs8d|_tjd|jdd|_|jg|_|jtj|j<dS)z&Add an anchor with the label contents.r2rZeqnumberrN)r rirrrrrrr r r rs zLabelFunction.processN) rrrrrr0rrrr r r r rsrc@seZdZdZejZddZdS)r\z1A function of one parameter that changes the fontcCsd|_|dS)z.Simplify if possible using a single character.r2N)r rrr r r rszFontFunction.processN)rrrrrr-rrr r r r r\sr\c@s.eZdZdZejZddZddZddZ dS) BigSymbolzA big symbol generator.cCs ||_dS)zCreate the big symbol.N)r)rrr r r rszBigSymbol.__init__cCs0|j|jkr|jgS|r$|jgS|j|jS)zGet an array with all pieces.)rr^ smalllimitrr r r getpiecess  zBigSymbol.getpiecescCs(tjs dSt|j|jdkr"dStjS)z7Decide if the limit should be a small, one-line symbol.Tr)rrrr^rrrrr r r rs zBigSymbol.smalllimitN) rrrrrr(r^rrrr r r r rs rc@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)rmr alignmentrrr')rrmrrr r r rs  zBigBracket.__init__cCs t|dtt|j}||S)z%Return the nth piece for the bracket.getpiece)rrrr)rrfunctionr r r rszBigBracket.getpiececCs |jdS)z1Return the only piece for a single-piece bracket.r)rrrr r r getpiece1szBigBracket.getpiece1cCs4|dkr|jdS||jdkr*|jdS|jdS)zGGet the nth piece for a 3-piece bracket: parenthesis or square bracket.rrrrrmrr r r getpiece3s   zBigBracket.getpiece3cCsP|dkr|jdS||jdkr*|jdS||jddkrF|jdS|jdS)z7Get the nth piece for a 4-piece bracket: curly bracket.rrrrrrr r r getpiece4 s   zBigBracket.getpiece4cCs&||}d|jd}t||S)z'Get the bracket piece as an array cell.zspan class="bracket align-r#)rrrr)rrrrr r r getcells zBigBracket.getcellcCs\|jdks|js|Sg}t|jD]$}||}|t|gdq&t|dgS)z3Get the bracket as an array or as a single bracket.rspan class="arrayrow"span class="array")rmrgetsinglebracketrhrrrr)rrowsrcellr r r getcontentss zBigBracket.getcontentscCs,|jdkrtddgSt|jdgS)z$Return the bracket as a single sign.r.r)zspan class="emptydot"r)rrrrr r r r$s zBigBracket.getsinglebracketN)r) rrrrrrrrrrrrr r r r rs   rc@seZdZdZdZddZdS)FormulaEquationzA simple numbered equation.ZequationcCs t|_||jt|dS)Parse the arrayN)rHrrr(rrHrr r r r4szFormulaEquation.parsebitNrrrrrrr r r r r/src@s eZdZdZddZddZdS) FormulaCellzAn array cell inside a rowcCs"||_td|dd|_|S)Nzspan class="arraycell align-r#T)rrKrOr)rrr r r setalignment<szFormulaCell.setalignmentcCs0|j||rdS||jt|dSr)r(rLrprrrHrr r r rAs zFormulaCell.parsebitN)rrrrr rr r r r r 9sr c@s2eZdZdZejdZddZddZddZ d S) FormulaRowzAn array row inside an arrayrcCs||_tdd|_|S)NrT) alignmentsrKrOr)rr r r r setalignmentsLszFormulaRow.setalignmentscCsjd}|j|jdd|sP||}|||||d7}||jqt|jdkrft |_ dS)zParse a whole rowrT)rrN) rrrp createcellrrrrrrDr)rrrrr r r rQs   zFormulaRow.parsebitcCs&|j|t|j}|jt|S)z4Create the cell that corresponds to the given index.)r rr(rr r )rrrr r r r^szFormulaRow.createcellN) rrrrrr&rr rrr r r r r Gs   r c@s0eZdZdZddZddZddZdd Zd S) MultiRowFormulazA formula with multiple rows.cCsPg|_d}||D]*}|r"d}n|||||qt|j|_dS)z,Parse all rows, finish when no more row endsTFN)r iteraterowsaddemptyraddrowrrm)rrrVrowr r r parserowsfs  zMultiRowFormula.parserowsccsZtjd}||d|jt}||jV||rP|j | |7_ q dSq dS)z0Iterate over all rows, end when no more row endsrTN) rr&rr(rr r r rrr)rrrrr r r rts    zMultiRowFormula.iteraterowscCs^|jt|j}t|jdjD]*\}}||}| t d| |q$| |dS)zAdd an empty row.rrN) r(rr r r rrrrrrNr)rrrZ originalcellrr r r rs   zMultiRowFormula.addemptycCs|j|||dS)z2Add a row to the contents and to the list of rows.N)rrr)rrr r r rs zMultiRowFormula.addrowN)rrrrrrrrr r r r rcs   rc@s$eZdZdZdZddZddZdS) FormulaArrayzAn array within a formular&cCs(tdd|_||||dS)rrFN)rKrOrparsealignmentsrrr r r rs zFormulaArray.parsebitcCsDd|_||}|r||_||}g|_|D]}|j|q.dS)zParse the different alignmentsrN)valignrr%r r)rrr(rr r r rs  zFormulaArray.parsealignmentsN)rrrrrrrr r r r rsrc@seZdZdZdZddZdS) FormulaMatrixz'A matrix (array with center alignment).ZmatrixcCs,tdd|_d|_dg|_||dS)z(Parse the matrix, set alignments to 'c'.rFrN)rKrOrrr rrr r r rszFormulaMatrix.parsebitNrr r r r rsrc@seZdZdZdZddZdS) FormulaCaseszA cases statementZcasescCst|_ddg|_|||jD].}|jD]"}|jdd|jtdq,q"t |jdd}t t |jdd}| |g|_dS)zParse the casesrzspan class="case align-l"Trzspan class="bracketcases"rN) rHrr rrrOrrNrrrrr)rrrrr&bracer r r rs    zFormulaCases.parsebitNrr r r r rsrc@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) rKrOrrrrr,r rrr)rr environmentr r r rs zEquationEnvironment.parsebitN)rrrrrr r r r rsrc@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) r%findbitrr&rrrrrrm)rrrr r&r r r rs     zBeginCommand.parsebitcCsDtjD]&}|dd|jkr|j|Sq|jt}||_|S)z7Find the command bit corresponding to the \begin{piece}rr))rrOrrr(rr)rrr r r r r rs   zBeginCommand.findbitN)rrrrrr&rrrrrrOrrr r r r rs   rc@s"eZdZejZddZddZdS)r]cCspd|_|j}||}|s,td|jn0t|dkr\td|jd|d|j t |dS)zParse a combining function.r*z'Empty parameter for combining function rzApplying combining function z to invalid string "r#N) r rparsesingleparameterrrrrrrrrM)rr combiningrr 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) r(rLrprrrrJrTrr"rNr~r)rrletterr r r rs     z&CombiningFunction.parsesingleparameterN)rrrrr*rrrr r r r r]s r]c@seZdZdZejZddZdS)r^z*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) r rrrrr"rrKrOrrrr)rrrr r r rs zDecoratingFunction.parsebitN)rrrrrr+rrr r r r r^sr^c@seZdZdZejZddZdS) LimitCommandz@A command which accepts limits above and below, in display mode.cCs@t|j}td|_|D]}|jt |dq dS)zParse a limit command.span class="limits"zspan class="limit"N) rrrrKrOrrrrr)rrrrr r r r$szLimitCommand.parsebitN)rrrrrr1rrr r r r r"sr"c@s$eZdZdZdZddZddZdS)r z(A command to limit the previous command.NcCstd|_|j|dS)z Do nothing.r#N)rKrOrr(rLrr r r r0szLimitPreviousCommand.parsebitcCsdS)rzLimit previous commandr rr r r r5sz LimitPreviousCommand.__unicode__)rrrrrrrr r r r r +sr c@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.Nr)rr checklimits modifylimits checkscript modifyscriptsr+r r r r<s   zLimitsProcessor.processcCsNtjs dS|||dtr,|||dSt||ts>dS|||dS)z3Check if the current position has a limits command.Fr)rr checkcommandr  limitsaheadrr"r'r+r r r r%Es zLimitsProcessor.checklimitscCs*||d||t||_dS)z,Limit the current element based on the next.rN)rrrDrr+r r r r*PszLimitsProcessor.limitsaheadcCsf||}|||d}|j||||drF|||d}ntdd}|jd|dS)zCModify a limits commands so that the limits appear above and below.rrzsup class="limit"rN)getlimitrrr'rrr)rrrZlimitedr{r|r r r r&Us zLimitsProcessor.modifylimitscCs$|||}|jjdd|j_|S)z#Get the limit for a limits command.rrF) getscriptrrLr)rrrrFr r r r+`s zLimitsProcessor.getlimitcCs:|||}|||}t||gd}|||dS)z=Modify the super- and subscript to appear vertically aligned.zspan class="scripts"N)r,rrr)rrrr{r|scriptsr r r r(fs  zLimitsProcessor.modifyscriptscCs|||tS)z6Check if the current element is a sub- or superscript.)r)rZr+r r r r'nszLimitsProcessor.checkscriptcCst||krdSt|||S)z0Check for the given type as the current element.F)rr)rrrr r r r r)rs zLimitsProcessor.checkcommandcCs"||}|jjd7_||=|S)zGet the sub- or superscript.z class="script"r)rrrr r r r r,xszLimitsProcessor.getscriptN) rrrrrr%r*r&r+r(r'r)r,r r r r r$9s   r$c@s&eZdZdZejZddZddZdS)r`z"A command which defines a bracket.cCst||dS)zParse the bracket.N)rYrrr r r rszBracketCommand.parsebitcCs ||_d||_t|g|_|S)z+Create the bracket for the given character.r)rrrNrrr characterr r r rs  zBracketCommand.createN) rrrrrr)rrrr r r r r`sr`c@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)rr checkleft processleftr+r r r rs zBracketProcessor.processcCsJ|||d}|sdS||||}||||||||dS)zProcess a left bracket.rN) findrightfindmaxresize)rrr rightindexrmr r r r2s zBracketProcessor.processleftcCs|||dS)z0Check if the command at the given index is left.rcheckdirectionr+r r r r1szBracketProcessor.checkleftcCs|||dS)z1Check if the command at the given index is right.rr7r+r r r checkrightszBracketProcessor.checkrightcCst|tsdS|j|kS)z6Check if the given bit is the desired bracket command.F)rr`r)rr rr r r r8s zBracketProcessor.checkdirectioncCsRd}|t|krN|||r$|d7}|||r8|d8}|dkrD|S|d7}qdS)z9Find the right bracket starting at the given index, or 0.rrN)rr1r9)rrrdepthr r r r3s    zBracketProcessor.findrightcCs|||}tdd|DS)z@Find the max size of the contents between the two given indices.cSsg|] }|jqSr r r r r r rsz,BracketProcessor.findmax..)r)rrZ leftindexr6Zslicedr r r r4s zBracketProcessor.findmaxcCs8|}|jdd}t|||}t|_||_dS)z+Resize a bracket command to the given size.rr)N)rrrrrHrrr)rrrmr/rrr r r r5s  zBracketProcessor.resizeN) rrrrrr2r1r9r8r3r4r5r r r r r0s  r0c@seZdZdZdZddZdS)r zShows today's date.NcCs t|_tjdg|_dS)rz %b %d, %YN)rErdatetimer:todaystrftimerrr r r rszTodayCommand.parsebit)rrrrrrr r r r r sr c@s8eZdZdZddgZddZddZdd Zd d Zd S) ParameterDefinitionz3The definition of a parameter in a hybrid function.)rr)rrcCs"d|_d|_d|_d|_d|_dS)NF)rr(rr literalvaluerr r r rs zParameterDefinition.__init__cCstjD]\}}||r|dkr&d|_|dsLtd|ddS||_|drfd|_ ||std|dS|Sqtd |dS) z2Parse a parameter definition: [$0], {$x}, {$1!}...rTrz$Wrong parameter name, did you mean $?Nr!zWrong parameter closing z'Wrong character in parameter template: ) r> parambracketsrrrrrr~rr()rrZopeningclosingr r r r.s       zParameterDefinition.parsecCs^|jr:|jr|||_n |||_|jrZt|j|_n |jrN|||_n |||_dS)z/Read the parameter itself using the definition.N) r(rrr?r%rNrrr")rrrr r r reads zParameterDefinition.readcCs0d|j}|jr$|dt|j7}n|d7}|S)rzparam rz (empty))rrrr|r r r rs  zParameterDefinition.__unicode__N) rrrrrArr.rCrr r r r r>s r>c@s8eZdZdZddZddZddZdd Zd d Zd S) ParameterFunctionzFA function with a variable number of parameters defined in a template.cCs8t|_||D] }|||||jd|j<qdS)z*Read the params according to the template.rN)rparams paramdefsrCrr readtemplaterZparamdefr r r readparamss zParameterFunction.readparamsccs,t|}|s(t|}|r|VqdS)z*Read each param definition in the templateN)rrpr>r.rGr r r rF$s  zParameterFunction.paramdefscCs||jkrdS|j|S)zGet a parameter as parsed.N)rErr r r getparam,s zParameterFunction.getparamcCs ||jS)zGet the value of a parameter.)rJrrr r r ry2szParameterFunction.getvaluecCs||}|r|jsdS|jS)z%Get the literal value of a parameter.N)rJr?)rrrr r r getliteralvalue6s  z!ParameterFunction.getliteralvalueN) rrrrrIrFrJryrKr r r r rDs rDc@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 {} parametersrrN)rrI writeparamsrcomputehybridsize)rrrH writetemplater r r rQs     zHybridFunction.parsebitcCs|t|S)z*Write all params according to the template)writeposr)rrOr r r rMYszHybridFunction.writeparamscCsg}|s|dr0||}|r||q|drZ||}|rd|_||q|drx||ddq|dr||ddq|t|q|S)z/Write all params as read in the parse position.rfNrleftrright) rpr writeparamr writefunctionr  writebracketrNr~)rrrrrr r r rP]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.)r~rErrrrrr )rrrr r r rTrs    zHybridFunction.writeparamcCsz||}|sdS|dr(t|S|ds@tddS|d||}|t |dkrldSt ||S)z"Write a single function f0,...,fn.Nrrz Function should be defined in {}rr) readtagrrrrrrrPrrr)rrrLrr r r rU~s        zHybridFunction.writefunctioncCs|s"td|dSt|}d|t|jkrZtdt|ddS|jd|}d|krt|S|j D]V}||krz|j |}|j std|d|d qz|j r|j }nd }| ||}qz|S) zJGet the tag corresponding to the given index. Does parameter substitution.zFunction should be f0,...,f9: fNrz Function fz is not definedrzParameters in tag z should be literal: {z!}r)) rrrrrr~rrrrEr(r?r)rrrrLvariablerrr r r rWs*    zHybridFunction.readtagcCs|jt||S)z4Return a new bracket looking at the given direction.)r(rr`r.r r r rVszHybridFunction.writebracketcCs>|jtjkr|dSt||_|jD] }|j|_q,dS)z(Compute the size of the hybrid function.N)r HybridSize configsizesrgetsizermrrr r r rNs   z HybridFunction.computehybridsizeN)rrrrrr.rrrMrPrTrUrWrVrNr r r r rL=s rLc@seZdZdZejZddZdS)rYz+The size associated with a hybrid function.cCsb|j|j}|jD],}||kr|j|j}||t|}qd|krZtd|dSt |S)z*Read the size for a function and parse it.rz%Unconverted variable in hybrid size: r) rZrrErrrrrreval)rrZ sizestringrrmr r r r[s  zHybridSize.getsizeN)rrrrrr/rZr[r r r r rYsrYc@s0eZdZdZddZddZddZdd Zd S) HeaderParserzParses the LyX headercs(gfddS)z?Parse header parameters into a dictionary, return the preamble.cs Sr) parseliner r7r r r rz$HeaderParser.parse..r;r-r r7r r.szHeaderParser.parsecCsz|}|tjdr&||dS|tjdrFt|dS|tjdrl||j |dS| |dS)z0Parse a single line as a parameter or as a startr@NrDr?) rrr>rK parsebranch LstParser parselstsetrr(r)r")rrrrhr r r r^s  zHeaderParser.parselinecCsh|d}|ttjd}||t|}|jD]}| ||j|qB|t j |<dS)zParse all branch definitions.rrAN) rrrr]rr>rKr.rrrr)rrr@Z subparserrrr r r r_s  zHeaderParser.parsebranchcCs ||_|S)z*Complete the parser with the given ending.)r&)rr&r r r rszHeaderParser.completeN)rrrrr.r^r_rr r r r r]s  r]c@s$eZdZdZgZddZddZdS)PreambleParserzA parser for the LyX preamble.cs&tjd_fddgS)z,Parse the full preamble with all statements.rBcs Sr)parsepreambleliner rrr r r rz&PreambleParser.parse..)r>rKr&r'r-r rdr r.s zPreambleParser.parsecCstj||dS)zParse a single preamble line.N)rbpreamblerrrr-r r r rcsz PreambleParser.parsepreamblelineN)rrrrrer.rcr r r r rbsrbc@s6eZdZdZeZddZddZddZdd Z d S) r`z!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: Nrr) extractlstsetrrrparselstparamsr` globalparams)rrrZlefttextZ croppedtextr r r ras  zLstParser.parselstsetcCs>d}|s0||7}||dr|SqtddS)z%Extract the global lstset parameters.r)rz0Could not find end of \lstset settings; abortingN)rprrrrr)rrrr r r rfs  zLstParser.extractlstsetcCs,tj|_|d}|j||dS)z-Parse some lstparams from elyxer.a container. lstparamsN)r`rhrrirupdaterg)rr paramlistr r r r+&s  zLstParser.parsecontainercCsTt}|D]D}d|kr6t|dkrNtd|q |dd\}}|||<q |S)z1Process a number of lstparams from elyxer.a list.rrzInvalid listing parameter r)rrr rrr)rrkZ paramdictrrrr r r rg,s zLstParser.parselstparamsN) rrrrrrhrarfr+rgr r r r r` s   r`c@s6eZdZdZeZddZddZddZdd Z d S) r z0A 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 rz parameters)N) rDrparameternumberdefaultsr(rQparseparametersrr newcommandrmacrosrr r r r@s zMacroDefinition.parsebitcCsZ|||_||}|r$t||_||}|rJ|j|||}q.|||_ dS)zDParse all optional parameters (number of parameters, default values)N) parsenewcommandrorrrlrrmrr" definition)rrr(rr r r rnLs      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 r) r(rLrJrTr%rrrrrrrr r r rq\s  zMacroDefinition.parsenewcommandcCs |jS)z Return an instance of the macro.)rrrrr r r rfszMacroDefinition.instantiateN) rrrrrrprrnrqrr r r r r ;s   r c@s eZdZdZddZddZdS)MacroParameterz A parameter from elyxer.a macro.cCs |dS)zFind a macro parameter: #n.r)rrr r r rmszMacroParameter.detectcCsV|dstddSt||_dt|j|_t dt|jdg|_ dS)zParse the parameter: #n.rzMissing parameter start #.NrP) rrrrr~r<rrrrrrr r r rqs   zMacroParameter.parsebitNrr r r r rsjsrsc@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)rVrvaluesrrn completemacrorrmacror 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) parseoptionalrrmparsemandatoryrlrrurrrrwr r r rnszMacroFunction.parseparameterscCsg}|jt|r6|||t|t|krq6q|D]4}|}t|jdkrb|j|q:|j|q:|j|7_dS)zParse optional parameters.rN) r(rJr)rrrrrru)rrrmrrr%r r r ryszMacroFunction.parseoptionalcCs8t|D]*}||||}|s&dS|j|qdS)z'Parse a number of mandatory parameters.N)rhparsemacroparameterrur)rrr<rrr r r rzs  zMacroFunction.parsemandatorycCs<|j||rdS|jt|r2|||S||S)z?Parse a macro parameter. Could be a bracket or a single letter.N)r(rLrprJrV parsenumbersr")rr remainingr r r r{s   z!MacroFunction.parsemacroparametercCs\|jt|}t|j|ks |S|jD]0}|jt}|t|||_|j |q&dS)z3Parse the remaining parameters as a running number.N) r(rrVrrrrrNr rur)rrr}r<digitrr r r r|s  zMacroFunction.parsenumberscCs|g|_dgt|j}|tD]N}|jd}|t|jkrZtdt |dSd||<|j| g|_q&t t|jD]}||s| ||j|qdS)z,Complete the macro with the parameters read.Frz%Macro parameter index out of bounds: NT) rrrrurrsr<rrrrrhrY)rrxr0rrr r r rvs  zMacroFunction.completemacrocCs6dt|d}d|jd}|j||dS)z@Add a filter for the given parameter number and parameter value.rrr)rN)rjoinrurBrrY)rrrrr r r rYszMacroFunction.addfilterN)rrrrr rprrrnryrzr{r|rvrYr r r r rtzs  rtc@s eZdZdZddZddZdS)rmz!A math macro defined in an inset.cCst|_t|_dSr)rrrDrrr r r rszFormulaMacro.__init__cCsdS)rz Math macror rr r r rszFormulaMacro.__unicode__Nrr r r r rmsrmcCs2t}||}t||d|S)zConvert some TeX math to HTML.r))r<rr,rrrB)rr(r=r r r math2htmls   rcCsHtj}t|t|dkr.tdtt|d}t |dS)z=Main function, called if invoked from elyxer.the command linerz"Usage: math2html.py escaped_stringrN) rargvrrrrrrrr )rrr r r mains    r__main__)robjectros.pathrr!r,r1rrr9r>rLrQrRrTrarorprrrrurllib.requestr8 urllib.parse urllib.errorrr rr,r0r6r8r9r<r?r@rDrErHrKrVr[r`r]rrrzr{rrrrrrgrwrLrMrPrrrrrrNrUr_rVrzrrTr)r*r,rSrHr< unicodedatarXrRrr]r~rrrrrrorxr@rGrKr?rHr;rJrAr:rRrvrqrpr9ryrzrrIr{rrhrlrrrrirjrrrXrrWrYrZr[rr\rOrrrr r rrrrrrr;r]r^r"r r$r`r0r r0r>rDrLrYr]rbr`r rsrtrmrrrr r r r sz2K X #,"E] -M#     B D(v?8#> 2 "h,   F 8k K 6Yn         8/1>U;    B +  F; :$z *./X