o n_{@s ddlZddlZddlZddlZddlZddlZddlZejdkr(ddl m Z nddl m Z ejdkr:e Z e ZejZGdddeZGdddeZGdd d eZGd d d eZGd d d eZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGdddeZGd d!d!eZ Gd"d#d#eZ!Gd$d%d%eZ"Gd&d'd'eZ#Gd(d)d)eZ$Gd*d+d+eZ%Gd,d-d-eZ&Gd.d/d/eZ'Gd0d1d1e'Z(Gd2d3d3e'Z)Gd4d5d5e'Z*Gd6d7d7e*Z+Gd8d9d9e'Z,Gd:d;d;e'Z-Gdd?d?eZ/Gd@dAdAe/Z0GdBdCdCe/Z1GdDdEdEe/Z2GdFdGdGe2Z3GdHdIdIe2Z4GdJdKdKe/Z5GdLdMdMeZ6GdNdOdOeZ7GdPdQdQeZ8GdRdSdSeZ9GdTdUdUeZ:GdVdWdWe8Z;GdXdYdYe;ZGd^d_d_e>Z?Gd`dadae?Z@Gdbdcdce>ZAGdddedeeAZBGdfdgdge>ZCGdhdidieZDGdjdkdke'ZEGdldmdmeEZFGdndodoe>ZGGdpdqdqeGZHGdrdsdseBZIGdtdudueGZJGdvdwdweGZKGdxdydyeGZLGdzd{d{eGZMGd|d}d}eGZNGd~ddeGZOGdddeOZPGdddeZQGdddeZRGddde>ZSGdddeGZTGdddeZUGdddeZVeVeV_WGdddeZXGdddeXZYGdddeZZGdddeZZ[e[eZ_\eZeZ_]GdddeZ^Gddde>Z_Gddde>Z`GdddeCZaGdddeCZbGdddeCZcGdddeCZdGdddeCZeGdddeCZfGdddeCZgGdddeCZhGdddeCZiGdddeCZjGddde?ZkGddde>ZlGddde>ZmGddde>ZnGddde>ZoGdddeoZpGddde>ZqGdddeCZrGddde?ZsGddÄde>ZtGddńdetZuGddDŽdeuZvGddɄde/ZwGdd˄deZxGdd̈́deZyGddτdetZzGddфdetZ{GddӄdeGZ|GddՄde|Z}Gddׄde}Z~Gddلde}ZGddۄde~ZGdd݄de}ZGdd߄de}ZGddde}ZGddde}ZGdddeZeUje|eg7_ee~eeeeege|_GdddeZGdddeZGddde}ZGddde|ZGddde|ZGddde}ZGdddeZGdddeZGdddeZGdddeZGddde}Ze|jeg7_GdddeZGdddeZGddde~ZGdddeZGdddeQZGdddeZGdd d eQZGd d d e~Ze|jeeeeg7_eRjeeg7_Gd d d eZGddde}ZGdddeZGdddeZe|jeg7_Gddde'ZGddde'ZGdddeZGddde}ZGdddeGZGddde}ZGd d!d!eSZeUjeg7_e|jeg7_d"d#Zd$d%Zed&krQedSdS('Nr) quote_plusc@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"tjrtjrdSt|tjdS)zShow a debug messageN)r debugmode quietmodeshowsysstdoutclsmessager?/usr/lib/python3/dist-packages/docutils/utils/math/math2html.pydebug4s z Trace.debugcCs2tjrdStjrtjrtj|}t|tjdS)zShow a trace messageN)rrprefix showlinesmoderr r r rrrr :s   z Trace.messagecCs0d|}tjrtjrtj|}t|tjdS)zShow an error messagez* N)rrrrr stderrr rrrerrorBs  z Trace.errorcCstd|tddS)z#Show an error message and terminatezFATAL: N)rrexitr rrrfatalIs z Trace.fatalcCs&tjdkr |d}||ddS)zShow a message out of a channelrutf-8 N)r version_infoencodewrite)r r channelrrrrNs  z Trace.show)__name__ __module__ __qualname____doc__rrrrrr rrr classmethodrrrrr+s  rc@seZdZdZddddZddddZd d d d d Zid ddddddddddddddddddddddddd d!d"d#d$d%dZd&d'd'd(Zd)d*d$d+d Z d,d-d.d/d$d0d1Z d2d3d$d4d Z d5S)6BibStylesConfig+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'r%ue$authors: “$title”, $journal,{ pp. $pages,} $year.{ URL $url.}{ $note.}r(zj{$authors: }$title{ ($editor, ed.)}.{{ $publisher,} $year.}{ URL $url.}{ $note.}z@bookletzW$authors: $title.{{ $publisher,} $year.}{ URL $url.}{ $note.}z @conferencez@inbook @incollectionz$authors: $title{ in $booktitle{ ($editor, ed.)}}.{{ $publisher,} $year.}{ URL $url.}{ $note.}@inproceedingsug$authors: “$title”, $booktitle,{ pp. $pages,} $year.{ URL $url.}{ $note.}z@manualz@mastersthesisz@misczh$authors: $title.{{ $publisher,}{ $howpublished,} $year.}{ URL $url.}{ $note.}z @phdthesisz @proceedingsz @techreportzG$authors: $title, $year.{ URL $url.}{ $note.}z @unpublisheduW$authors: “$title”, $journal, $year.{ URL $url.}{ $note.}r&z$indexr'z??)YYauthorssurnameu~$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) rrr r!abbrvnatalpha authordate2r' defaulttagsieeetrplain vancouverrrrrr#[s       r#c@seZdZdZdddZdS) BibTeXConfigr$—.)--z..N)rrr r!replacedrrrrr6s r6c @seZdZdZidddddddd d d d d d dddddddddddddddddddd d!d"d#d$Zgd%d&ggd'd(Zd)ddd*Zid&d+d,d-d.d-d/dd0d1d2dd3dddd4d-d5d-d6d-d7d8d9d-d:dd;d<d=d>d?d@idAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbidcdbdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdDdwdFdxdHdydHdzdHd{dHd|dJid}dsd~dPddVddXddNddTddXddZddJddXddbdddddddd<ddddiddddddddddddddddddddddddddddddddddidddddddddd dd d d-dd dd-dd-dd-dd-ddddddd"dēdd-idd-dddd-ddɓdd˓dd͓ddϓddѓddӓdd-dd-dd-ddؓdd-dddd-dd-dd-d-dd-dd-d dޜZddiZdddgiZ dS)ContainerConfigr$Alignz \end_layout BarredText\barBoldTextz\seriesCellz?@ABBCDEFFGHIIJJKKLLMMNNOOPPQQRRSSTTUUVVW^r;c @sdeZdZdZddddddZddddd d d d d ddd ZddddZddiZddddZddiZ dS) EscapeConfigr$r+u — ’‘)rz -- z --- '`  r8…u ▷ -/r) 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{} \backslashz&z<>)&<>/>rz z z )r  r N) rrr r!charscommandsentitieshtml iso885915 nonunicoderrrrr%s&  rc@s&eZdZdZidddddddd d d d d ddddddddddddddddddd d!d"d#id$d%d&d'd(d)d*d+d,d-d.d'd/d0d1d2d3d2d4d5d6d7d8d7d9d:d;d<d=d>d?d@dAdBidCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcddidedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddLddddddddZdddddZgdgdgdgdgddggddgdZddgddgdZddddddZidddddddddddddddddddddddddddddddddddddddddddŜZ iddǓddɓdd˓dd͓ddϓddddғddԓdd֓ddؓddړddܓddޓddddddddiddddddddddddddddddddddddddddddddddid d d d d dddddddddddjddddddddd d!d"dld#d$d%d&d'd(id)d*d+d,d-d.d/d0d1d2d3d4d5d6d7dnd8d9d:dpd;drd<d=d>dtd?d@dAdBdCdDdEdFidGdHdIdJdKdLdMdNdOdPdQdRdSdvdTdUdVdWdXdYdZd[d\dxd]d^d_d`dadzdbdcdddidedfdgdhdid|djdkddldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~ddddddiddddddddddddddddddddddddddddddddddiddddddddddddddddddddddddddddddBdÐdēdŐdƓidǐdȓdɐdʓdːd̓d͐dΓdϐdГdѐdғdӐdԓdՐd֓dאdؓdِdړdېdܓdݐdޓdߐdddddddddidddddddddddddddddddddddddddddddddd id d d d ddddddddddrdddddddddd d!d"d#dd$d%d&d'd(d)id*d+d,d-d.d-d/d0d1d2d3d4d5d6d7d6d8d9d:d;d<d=d>d?d@dAdBdCdDddEdFdGdHidIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjidkdldmdndodpdqddrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddiddddddddddddddddddddddddddddddddddiddddddddddddddddd3d2ddddddddÓdĐdœdƐdǓd8d7dȐdɓidʐd˓d̐dd͐dΓdϐdГdѐdғdӐdԓdՐd֓dאd֓dؐdٓdڐdۓdܐdVdݐdޓdߐdddddddddiddddddddddddddddddddddddddddddddddid d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*id+d,d-d.d/d0d1d2d3d4d5d6d7dd8d9d:d;d<d=d>dɓd?d@dAdBdCdDdEdFdGdHdIdJidKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdlidmdndodpdqd&drd&dsdtdudvdwdldxdydzd{d|d}d~dddddddddddddiddddddɓddɓdd&dddddd}ddddddddddddddddddidddddddddddddddddddddddddddddÐddĐdœdƐdǓidȐdɓdʐd˓d̐d͓dΐdϓdАddѐdғdӐddԐdddd֐dדdؐdٓdڐdƓdېdܓdݐdޓdߐdddddiddddddddddddddddddddddғddddddddddddidddddd d d d d ddddddddddddddddddddd d!d"d#id$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEidFdGdHdIdJdKdLdMdNdOdPdQdRdCdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdɓdddeidfdgdhdidjdkdlddmdndodpdqdrdsdtduddvdwdxdydzd{d|d}d~dddddddiddddddddddddddddddddddddddddHddiddddiddddVddddddddddddddddddddddddddRddddiddғdd“dÐdēdŐdƓdǐddȐddɐdʓdːd̓d͐dΓdϐdГdѐdғdӐdԓdՐd֓dאdؓdِdړdېdʓdܐdГidݐdГdސdߓddddddddddddddddZddddFddddjddddddiddddddddVdddddddddddddd d d d d dd֓ddddZ iZ d,d2dHdZ ddddddZ ddggdddgdZidddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:id;d<d=d>d?d@dAdBdCdDdEddFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[id\d]d^d_d`ddadJdbdcdddedfddgdhdiddjdkdldmdndodpdqdrdGdsdIdtdKdudMdOdQdSdUdWdvdwdxZidygdzd{gd|d}gd~dgddgddgddgddgddgddgddgddgddgddgddgddgddgdidgddgddgd~dgddgddgddgd~dgd|dgddgddgddgddddgdgddgddgddgdgdgdgdgdgdgdgdgdgdgdd ZdddddddZddiZidĐdœdƐdǓdȐdɓdʐd˓d̐d͓dΐd͓dϐdГdѐdғdӐd͓dԐdՓd֐dדdؐdٓdڐdۓdܐdݓdސdߓddddZddddddddZdddɐddddddddddddɐdZidddddddddddddddddddddddddd d d d dd dddddiZiddddRdddddddddddd d!dd"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1id2d3d4d5d6d7d8d9d:d;d<d=d>d?d@ddAdBdCdDdEdFdGdHdIddJdKdLdMdNdOdPdQidRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsidtdduddvdwdxdydzd{d|d}d~dddddddddddddddddddddiddddddddddddddddddddddddddddddddddidddddddddddddddddd“dÐdēdŐdƓdǐdȓdɐdʓdːd̓d͐ddΐddϐd{idАddѐddҐddӐdԓdՐd֓dאdؓdِdړdېdܓdݐddސdߓddddddddddddddiddddddddddddޓddddidddddddddddddddd d d d d dddddddd Zddd֐ddϐdd͐dِdd ZdddZdddddedddddedwd d! Zd"gd#iZd$d%iZd&S(' FormulaConfigr$z\AAÅz\AEÆz\AmSz#AmSz \AngstroemuÅz\DHÐz\KoppauϞz\LuŁz\Microµz\OØz\OEuŒz\SampiuϠz\StigmauϚz\THÞz\aaåz\aeæz\alphauαz\betauβz\deltauδz\dhðz\digammauϝz\epsilonuϵz\etauηz\ethz\gammauγz\iuız\imathz\iotauιz\juȷz\jmathz\kappauκz\koppauϟz\lułz\lambdauλz\muuμz\nuuνz\oøz\oeuœz\omegauωz\phiuφz\piuπz\psiuψz\rhouρz\sampiuϡz\sigmauσz\ssßz\stigmauϛz\tauuτz\tcohmuΩz\textcrhuħz\thþz\thetauθz\upsilonuυz \varDeltau∆z \varGammauΓz \varLambdauΛz \varOmegauΩz\varPhiuΦz\varPiuΠz\varPsiuΨz \varSigmauΣz \varThetauΘz \varUpsilonuΥz\varXiuΞz\varbetauϐz \varepsilonuεz \varkappauϰz\varphiz\varpiuϖuϱuςuϑuξuζ)z\varrhoz \varsigmaz \varthetaz\xiz\zetaz\beginrz\endz\\)begin cellseparatorend rowseparator)u⎛u⎜u⎝)u⎞u⎟u⎠)u⎡u⎢u⎣)u⎤u⎥u⎦)u⎧⎪u⎨u⎩|)u⎫ru⎬u⎭∥)()[]{r}ru⎲u⎳u⌠u⌡)∑∫span class="symbol"zz)\leftz\left.z\middle\rightz\right.z\"üz\'úz\^ûz\`ùz\acuter>ūz\breveŭz\cu̧z\checkǔz\dddotu⃛z\ddotz\dotu̇z\gravez\hatz \mathringů\overleftarrowu⃖\overrightarrowu⃗u̩u⃝u̥ũ)z\rz\sz \textcircledz \textsubringz\tildez\vz\vecz\~z\ rz\!r+z\##z\$$z\%%z\&z\, z\:rz\;u z\ACu∿z \APLcommentu⍝z\APLdownarrowboxu⍗z \APLinputu⍞z\APLinvu⌹z\APLleftarrowboxu⍇z\APLlogu⍟z\APLrightarrowboxu⍈z\APLuparrowboxu⍐z\Boxu□z\Bumpequ≎z\CIRCLEu●z\Capu⋒z\CapitalDifferentialDuⅅz \CheckedBoxu☑z\Circleu○z \Coloneqqu⩴z \ComplexIuⅈz \ComplexJuⅉz \Correspondsu≙z\Cupu⋓z\DeltauΔz\Diamondu◇z \Diamondblacku◆z \Diamonddotu⟐z\DifferentialDuⅆz \Downarrowu⇓z\EUR€z\Euleruℇz \ExponetialEuⅇz\FinvuℲz\Gameu⅁z\Gammaz\Imuℑz\Joinu⨝z \LEFTCIRCLEu◖z \LEFTcircleu◐z\LHDu◀z\Lambdaz\Lbagu⟅z \Leftarrowu⇐z \Lleftarrowu⇚z\Longleftarrowu⟸z\Longleftrightarrowu⟺z\Longrightarrowu⟹z\Lparenu⦅z\Lshu↰z \Mapsfromu⇐|z\Mapstou|⇒z\Omegaz\P¶z\Phiz\Piz\PrPrz\Psiz\QoppauϘz\RHDu▶z \RIGHTCIRCLEu◗z \RIGHTcircleu◑z\Rbagu⟆z\Reuℜz\Rparenu⦆z \Rrightarrowu⇛z\Rshu↱z\S§z\Sigmaz\Squareu☐z\Subsetu⋐z\Sunu☉z\Supsetu⋑z\Thetaz\Uparrowu⇑z \Updownarrowu⇕z\Upsilonz\Vdashu⊩z\Vertz\Vvdashu⊪z\XBoxu☒z\Xiz\Yupu⅄z
z\__z\alephuℵz\amalgu∐z\anchoru⚓z\angleu∠z \aquariusu♒z\arccosarccosz\arcsinarcsinz\arctanarctanz\argargz\ariesu♈z \arrowbulletu➢z\astu∗z\asympu≍z \backepsilonu∍z \backprimeu‵z \backsimequ⋍rrz\ballotxu✗z \barwedgeu⊼z\becauseu∵z\bethuℶz\betweenu≬z\bigcapu∩z\bigcircz\bigcupu∪z\bigodotu⊙z \bigoplusu⊕z \bigotimesu⊗z \bigsqcupu⊔z\bigstaru★z\bigtriangledownu▽z\bigtriangleupu△z \biguplusu⊎z\bigveeu∨z \bigwedgeu∧z \biohazardu☣z \blacklozengeu⧫z \blacksmileyu☻z \blacksquareu■z\blacktriangleu▲z\blacktriangledownu▼z\blacktriangleleftu◂z\blacktrianglerightz\blacktriangleupu▴z\botu⊥z\bowtieu⋈z\boxu▫z\boxastu⧆z\boxbaru◫z\boxboxu⧈z \boxbslashu⧅z \boxcircleu⧇z\boxdotu⊡z \boxminusu⊟z\boxplusu⊞z \boxslashu⧄z \boxtimesu⊠z\bulletu•z\bumpequ≏z\canceru♋z\capz \capricornusu♑z\catu⁀z\cdotu⋅z\cdotsu⋯z\cent¢z \centerdotu∙z \checkmarku✓z\chiuχz\circu∘z\circequ≗z\circlearrowleftu↺z\circlearrowrightu↻z \circledR®z \circledastu⊛z\circledbslashu⦸z \circledcircu⊚z \circleddashu⊝z \circledgtru⧁z \circledlessu⧀z \clubsuitu♣z\colon: z \coloneqqu≔z \complementu∁z\congu≅z\coprodz \copyright©z\coscosz\coshcoshz\cotcotz\cothcothz\csccscz\cupz \curlyveeu⋎z \curlywedgeu⋏z\curvearrowleftu↶z\curvearrowrightu↷z\dag†z\daggerz\dalethuℸz\dashleftarrowu⇠z\dashvu⊣z\ddag‡z\ddaggerz\ddotsu⋱z\degdegz\detdetz \diagdownu╲z\diagupu╱z \diameteru⌀z\diamondz \diamondsuitu♦z\dimdimz\div÷z\divideontimesu⋇z\dotdivu∸z\dotequ≐z \doteqdotu≑z\dotplusu∔z\dotsrz\doublebarwedgeu⌆z \downarrow↓z\downdownarrowsu⇊z\downharpoonleftu⇃z\downharpoonrightu⇂z\dsubu⩤z\earthu♁z \eighthnoteu♪z\elluℓz \emptysetu∅z\eqcircu≖z\eqcolonu≕z\eqsimu≂z\euroz\existsu∃z\expexpz\fallingdotsequ≒z\fcmpu⨾z\femaleu♀z\flatu♭z\forallu∀z\fourthu⁗z\frownu⌢z\frownieu☹z\gcdgcdz\geminiu♊z\geq)u≥z\geqqu≧z \geqslantz\getsu←z\ggu≫z\gggu⋙z\gimeluℷz\gneqqu≩z\gnsimu⋧z\gtrdotu⋗z \gtreqlessu⋚z \gtreqqlessu⪌z\gtrlessu≷z\gtrsimu≳z\guillemotleft«z\guillemotright»z\hbaruℏz \heartsuitu♥rG z\homhomz\hookleftarrowu↩z\hookrightarrowu↪z\hslashz \idotsintu(∫⋯∫z\iiintu"z\iintu"z\infinfz\inftyu∞z \intercalu⊺z \interleaveu⫴z\invampu⅋z\invnegu⌐z\jupiteru♃z\kerkerz\landz \landupintu"ru⟪z\langleu⟨z\lblotu⦉z\lbracerz\lbrace)z\lbrackrz\lceilu⌈z\ldotsz\leadstou⇝z \leftarrow)z\leftarrowtailu↢z\leftarrowtobaru⇤z\leftharpoondownu↽z\leftharpoonupu↼z\leftleftarrowsu⇇z\leftleftharpoonsu⥢z \leftmoonu☾z\leftrightarrowu↔z\leftrightarrowsu⇆z\leftrightharpoonsu⇋z\leftthreetimesu⋋z\leou♌z\leq)u≤z\leqqu≦z \leqslantz\lessdotu⋖z \lesseqgtru⋛z \lesseqqgtru⪋z\lessgtru≶z\lesssimu≲z\lflooru⌊z\lglgz\lgroupu⟮z\lhdu⊲z\librau♎z \lightningu↯z\limgu⦇z\liminfliminfz\limsuplimsupz\llu≪z \llbracketu⟦z \llcorneru⌞z\lllu⋘z\lnlnz\lneqqu≨z\lnot¬z\lnsimu⋦z\loglogz\longleftarrowu⟵z\longleftrightarrowu⟷z \longmapstou⟼z\longrightarrowu⟶z\looparrowleftu↫z\looparrowrightu↬z\lorz\lozengeu◊z \lrcorneru⌟z\ltimesu⋉z\lyxlockz\maleu♂z\malteseu✠z \mapsfromu↤z\mapstou↦z\mathcircumflex^z\maxmaxz\measuredangleu∡z \medbulletu⚫z\medcircu⚪z\mercuryu☿z\mhou℧z\midu∣z\minminz\modelsu⊨z\mpu∓z \multimapu⊸z \nLeftarrowu⇍z\nLeftrightarrowu⇎z \nRightarrowu⇏z\nVDashu⊯z\nablau∇z\napproxu≉z\naturalu♮z\ncongu≇z\nearrowu↗z\negz\neg)z\neptuneu♆z\nequivu≢rz\nexistsu∄z \ngeqslantu≱z\ngtru≯z \ngtrlessu≹z\niu∋z\ni)z \nleftarrowu↚z\nleftrightarrowu↮z \nleqslantu≰z\nlessu≮z \nlessgtru≸z\nmidu∤z \nolimitsz \nonumberz\notz\notz \notbackslashu⍀z\notinu∉z\notniu∌z \notslashu⌿z \nparallelu∦z\nprecu⊀z \nrightarrowu↛z\nsimu≁z\nsimequ≄z \nsqsubsetu⊏̸z \nsubsetequ⊈z\nsuccu⊁z \nsucccurlyequ⋡z\nsupsetu⊅z \nsupsetequ⊉z\ntriangleleftu⋪z\ntriangleleftequ⋬z\ntrianglerightu⋫z\ntrianglerightequ⋭z\nvDashu⊭z\nvdashu⊬z\nwarrowu↖z\odotz \officialeuroz\oiiintu"z\oiintu"z\ointu"z\ointclockwiseu"z\ointctrclockwiseu"z\ominusu⊖z\oplusz\oslashu⊘z\otimesz\ownsz \parallelz\partialu∂z\pencilu✎z\perpz\piscesu♓z \pitchforku⋔z\plutou♇z\pm±z\pointeru➪z \pointrightu☞z\pounds£z\precu≺z \preccurlyequ≼z\preceqz\precsimu≾z\primeu′z\promptou∝z\qoppauϙz\qquad z\quadz \quarternoteu♩z \radiationu☢z\rangu⟫z\rangleu⟩z\rblotu⦊z\rbracerz\rbrace)z\rbrackrz\rceilu⌉z\recycleu♻z\rflooru⌋z\rgroupu⟯z\rhdu⊳z \rightangleu∟z \rightarrow)u→z\rightarrowtailu↣z\rightarrowtobaru⇥z\rightharpoondownu⇁z\rightharpoonupu⇀z\rightharpooondownz\rightharpooonupz\rightleftarrowsu⇄z\rightleftharpoonsu⇌z \rightmoonu☽z\rightrightarrowsu⇉z\rightrightharpoonsu⥤z\rightthreetimesu⋌z\rimgu⦈z \risingdotsequ≓z \rrbracketu⟧z\rsubu⩥z\rtimesu⋊z \sagittariusu♐z\saturnu♄z\scorpiou♏z\searrowu↘z\secsecz\secondu″z \setminusu∖z\sharpu♯z\simequ≃z\sinsinz\sinhsinhz\sixteenthnoteu♬z\skullu☠z\slashu∕z\smallsetminusz\smalltriangledownu▿z\smalltriangleleftu◃z\smalltrianglerightu▹z\smalltriangleupu▵z\smileu⌣z\smileyu☺z \spadesuitu♠z\spddot¨z\sphatz\sphericalangleu∢z\spotu⦁z\sptilde~z\sqcapu⊓z\sqcupz \sqsubsetu⊏z \sqsubsetequ⊑z \sqsupsetu⊐z \sqsupsetequ⊒z\squarez\sslashu⫽z\staru⋆z \steamingu☕z \subseteqqu⫅z \subsetneqqu⫋z\succu≻z \succcurlyequ≽z\succeqz \succnsimu⋩z\succsimu≿z\sunu☼z\supsupz \supseteqqu⫆z \supsetneqqu⫌z\surdu√z\swarrowu↙z\swordsu⚔z \talloblongu⫾z\tantanz\tanhtanhz\taurusu♉z\textasciicircumz\textasciitildez\textbackslashz\textcopyrightu©'z \textdegree°z \textellipsisz \textemdashr7z \textendashz \texteuroz \textgreaterrz \textlessrz\textordfeminineªz\textordmasculineºz\textquotedblleft“z\textquotedblright”z\textquoterightrz\textregisteredz\textrightarrowz \textsectionz\texttrademarku™z\texttwosuperior²z\textvisiblespacez \thereforeu∴z\thirdu‴z\topu⊤z \trianglez \triangleleftz\triangleleftequ⊴z \trianglequ≜z\trianglerightu▷z\trianglerightequ⊵z\twoheadleftarrowu↞z\twoheadrightarrowu↠z \twonotesu♫z\udotu⊍z \ulcorneru⌜z\unlhdz\unrhdz\unrhlz\uparrow↑z \updownarrow↕z\upharpoonleftu↿z\upharpoonrightu↾z\uplusz \upuparrowsu⇈z\uranusu♅z \urcorneru⌝z\vDashz \varclubsuitu♧z\vardiamondsuitz \varheartsuitz \varnothingz \varspadesuitu♤z\vdashu⊢z\vdotsu⋮z\veez\vee)z\veebaru⊻z\vertz\virgou♍z\warningu⚠z \wasylozengeu⌑z\wedgez\wedge)z\wpu℘z\wru≀z\yen¥z\yinyangu☯z\{z\|z\})rrz\widehat\]z\end{)bracketcomplexendafter endbefore squarebracketrl)r;cr<)aligneqnarraygatheredz \boldsymbolbz\mathbbzspan class="blackboard"z \mathbb{A}u𝔸z \mathbb{B}u𝔹z \mathbb{C}uℂz \mathbb{D}u𝔻z \mathbb{E}u𝔼z \mathbb{F}u𝔽z \mathbb{G}u𝔾z \mathbb{H}uℍz \mathbb{J}u𝕁z \mathbb{K}u𝕂z \mathbb{L}u𝕃z \mathbb{N}uℕz \mathbb{O}u𝕆z \mathbb{P}uℙz \mathbb{Q}uℚz \mathbb{R}uℝz \mathbb{S}u𝕊z \mathbb{T}u𝕋z \mathbb{W}u𝕎z \mathbb{Z}uℤz\mathbfz\mathcalzspan class="scriptfont"z \mathcal{B}uℬz \mathcal{E}uℰz \mathcal{F}uℱz \mathcal{H}uℋz \mathcal{I}uℐz \mathcal{L}uℒz \mathcal{M}uℳz \mathcal{R}uℛz \mathfrakzspan class="fraktur"z \mathfrak{C}uℭz \mathfrak{F}u𝔉z \mathfrak{H}uℌz \mathfrak{I}z \mathfrak{R}z \mathfrak{Z}uℨz\mathitiz \mathring{A}z \mathring{U}uŮz \mathring{a}z \mathring{u}uůz \mathring{w}uẘz \mathring{y}uẙz\mathrmzspan class="mathrm"z\mathscrz \mathscr{B}z \mathscr{E}z \mathscr{F}zspan class="mathsf"tt)z \mathscr{H}z \mathscr{I}z \mathscr{L}z \mathscr{M}z \mathscr{R}z\mathsfz\mathttz\addcontentsline)z{$p!}{$q!}{$r!}f0{}ignoredz\addtocontents)z {$p!}{$q!}rDrEz \backmatter)r+rDrE\binom){$1}{$2}zf2{(}f0{f1{$1}f1{$2}}f2{)}zspan class="binom"zspan class="binomstack"span class="bigsymbol"z\boxed){$1}f0{$1}zspan class="boxed"\cfrac)z [$p!]{$1}{$2}!f0{f3{(}f1{$1}f3{)/(}f2{$2}f3{)}}span class="fullfraction"zspan class="numerator align-$p"span class="denominator"span class="ignored"rD) {$p!}{$1}rJzspan style="color: $p;"z \colorbox)rPrJz-span class="colorbox" style="background: $p;"\dbinom)rGu%(f0{f1{f2{$1}}f1{f2{ }}f1{f2{$2}}})zspan class="binomial"zspan class="binomrow"zspan class="binomcell"\dfrac)rGrLrMspan class="numerator"rNrOz \displaystyle)rIrJzspan class="displaystyle"z \fancyfoot)z [$p!]{$q!}rDrEz \fancyheadz\fbox)rIrJzspan class="fbox"z \fboxrule){$p!}rDrEz\fboxsepz \fcolorbox)z{$p!}{$q!}{$1}rJz>>>???@@AAABBBCCCCDDDEEEEFFFFGGGGHHHHIIIIJJJKKKLLMMMNNOPPQQQRRRSSSSTTUUUUVVVVWWWXXYYYZZ[[[\\\\]]]^^^^____```aaaabbbbccdddeeeffffggghhhiiiijjjjkkklllmmmmnnnnoooppppqqqrrrrssssttttuuuvvvwwwxxxyyzzz{{{||}~                    !!!""""###$$$%%%&&'''((()))**++,,--..////000112233334445556667778889999::::;;;<<<<====@                                                   ! "# 0                       !!!"""###$$%%%%&&&&'''((())))***+++,,--...///000111   8     rc@seZdZdZddddZdS) GeneralConfigr$z 2015-02-26413z1.2.5)date lyxformatnumberN)rrr r!versionrrrrrs rc @s@eZdZdZdddddddd d d d d d ZgdgddZdS) HeaderConfigr$rz\branchz \textclassz \end_branchz \end_preamblez \languagez\lstsetz\output_changesz\paragraph_separationz \pdf_titlez \secnumdepthz \tocdepth) beginpreamblebranch documentclass endbranch endpreamblelanguagelstset outputchangesparagraphseparationpdftitle secnumdepthtocdepth)0articleaastexaapaper acmsiggraph sigplanconfachemsoamsartapaz arab-articlezarmenian-articlezarticle-beamerchessdtk elsarticlez heb-articleIEEEtraniopartkluwerzscrarticle-beamerscrartcl extarticlepapermwartrevtex4spie svglobal3ltugboatzagu-dtdjgrgaagumsentcsegsijmpcijmpdz singlecol-newz doublecol-newisprstarticle jsarticlejarticlejsszliterate-articlesiamltexcl2emultllncssvglobalsvjogsvprobth)bookamsbookscrbookextbookz tufte-bookreport extreportscrreprtmemoirtbookjsbookjbookmwbksvmonosvmulttreportjreportmwrep)rrN)rrr r! parametersstylesrrrrrs  rc@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") imagemagickinkscapelyxpspdf).epsz.pdfz.psz.pngz.svgr)r'vectorN)rrr r! converterscropboxformatsformatsrrrrr1s rc@seZdZdZdgdiZdS) LayoutConfigr$rl rTrUrXr<rRrErSr=rOrCrZr[N)rrr r! groupablerrrrrBsrc@s eZdZdZddddddZdS) NewfangleConfigr$z chunkref{rrrz=<)chunkref endcommandendmarkr startmarkN)rrr r! constantsrrrrrIs  rc@s.eZdZdZgdddgdZdgdiZdS) NumberingConfigr$)ChapterSection Subsection Subsubsection ParagraphPartBook)orderedromansymbols) rjz**r r ru§§ru¶¶rz##N)rrr r!layoutssequencerrrrrQsrc @seZdZdZdddddddddddd Zid d d d dddddddddddddddddd dd ddd d!d"d#d$d%d&dd!d'd(d'd'd)Zd*d+d,d-d.d/d0d1Zd2gd3iZd4d5d6d7d8d9Zd: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{}r(aldralsu›ardrarsu‹eldz“elsz‘erdz”ersz’fldflsfrdfrsgldu„glsu‚grdr/grsrpldr0r)plsprdprssldsrdu(@↕)u¶↕u$↕u#↕u@↕u on-page#↕u @on-page#↕)eqref formattednamerefpagerefrefvpagerefvref ignoredtexts)coltextlinepagetheightpheightz
z
z
z
z
)bigskipdefskipmedskip smallskipvfillN) rrr r!hspacesquotesreferenceformatssizevspacesrrrrr]sp  rc@s<eZdZdZgddgdgdZgdgdgddZdS) TOCConfigr$rr+rk)rTrUr)rRrErSr=rOrCrZr[)rWrXr<rYrrN)rrr r! extractplain extracttitlerrrrr,s r,c @seZdZdZddiZdddZddddd d d Zd d dgiZddddddddddd ZdddZ ddddZ dddZ dddd Z d!S)" TagConfigr$underrgzspan class="sans"rC)sans typewriterzspan class="code"zspan class="menuitem"zspan class="noun"zspan class="strong")zCharStyle:CodezCharStyle:MenuItemCodeMenuItemNounStrongr QuotationQuotedivzh?h2h1 blockquote) CenterrDaterrr7r8rrrolul) EnumerateItemizer+zspan class="greyedout")Comment Greyedoutrrqr)) subscript superscriptrBrr)italicslanted smallcapsN) rrr r!barredfamilyflexgroupr listitemsnotesscriptshapedrrrrr/s2 r/c @seZdZdZiddddddddddddddd d d d d d ddddddddddddddidddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?Zd@d@dAdBd@dCdAdDdEdF ZdGS)HTranslationConfigr$Appendixrrrrrrrabstractr bibliographyrfigurezfloat-algorithmz Algorithm z float-figurezFigure z float-listingzListing z float-tablezTable z float-tableauzTableau footnotes Footnotesz generated-byzDocument generated by z generated-onz on indexIndexz jsmath-enablez)Please enable JavaScript on your browser.zjsmath-requireszH requires JavaScript to correctly process the mathematics on this page. zjsmath-warningz Warning: zlist-algorithmzList of Algorithmsz list-figurezList of Figuresz list-tablezList of Tablesz list-tableauzList of Tableauxz main-pagez Main pagenextNext nomenclature Nomenclatureon-pagez on page prevPrev references ReferencestoczTable of Contentsz Contents for Up)ztoc-forupendenlfrrues) americanbritishdeutschdutchenglishfrenchngermanrussianspanishN)rrr r!r languagesrrrrrRs         rRc@s8eZdZdZddZddZddZdd Zd d Zd S) CommandLineParserzA parser for runtime optionscCs ||_dSNoptions)selfrzrrr__init__ zCommandLineParser.__init__cCst|dkrdSt|dkr@|ddr@||\}}|s$d|dS|s,d|dSt|j||t|dkr@|ddsdS)Parse command line optionsrNr9zOption z not recognizedz needs a value)len startswith readoptionsetattrrz)r{argskeyvaluerrr parseoptionss   zCommandLineParser.parseoptionscCs|ddd}|d=d|vr|||}n|dd}t|j|s&d|fSt|j|}t|tr5|dfSt|dkr?|dfS|ddrU|d}|d=|| ||fS|d d }|d=t|t rm| |||fS||fS) z$Read the key and value for an optionrNrerr+Trwr) readequalskeyreplacehasattrrzgetattr isinstanceboolrr readquoteddecodelistappend)r{rrrcurrentinitialrrrrrs,       zCommandLineParser.readoptioncCstd|dd}t|dkrG|ddsG|ddsGtd|d|d|d7}|d=t|dkrG|ddsG|ddrt|dksT|ddrVdS|d|dd 7}|S) zRead a value between quotesOopsNrrwr9z Appending rr)rrrendswithr)r{rrrrrrrs  ((zCommandLineParser.readquotedcCs,|dd}|d}|d}|d||S)zRead a key using equalsrerr)splitinsert)r{rrrrrrrrrs  zCommandLineParser.readequalskeyN) rrr r!r|rrrrrrrrrws  rwc@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}||}|rt|||dS)r~rN)rlocationrwrrrusageprocessoptions)r{rparserresultrrrrVs    zOptions.parseoptionsc Cs|tjr|tjr|tjr|tjr|tj r#| tj rMzt tj t_ tj dkr;t d|Wnt dtj |YtjsVtjsVtjrYdt_|tjrgtjsgtjt_tjdkrodt_tjgkrxdgt_tjdkr~ tjrdt_tjrtjst d tjt_tjrt d tjrt d tt D]}|d rt t |t!||d dqd 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 splitpartintrrlowmemrdtocformemoryparsefootnotes forceformat imageformat copyimagescssfaviconr simplemath toctargetnocopyjsmathdirrrr)r{paramrrrrasZ              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 showoptionsr{rrrrs     z Options.usagecCstjsdSdt_dt_dt_tjd}|D]}|d}tt|r(tt|dqt d|qtj sz@ --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)rrr rrrrrrsj                                                     zOptions.showoptionscCs:dtjd}|dtjdd7}t|tdS)z(Return the current eLyXer version stringzeLyXer version r (rrN)rrrrr rr{rrrrrs  zOptions.showversioncCttjdtdS)zReturn just the version stringrNrr rrr rrrrrr zOptions.showhardversioncCr)zReturn just the version dterNrrrrrrrzOptions.showversiondatecCr)z#Return just the lyxformat parameterrNrrrrrrrzOptions.showlyxformat)Brrr r!instancerr copyrightrquietrrrrr showlinesunicoderrrtitle directory destdirectoryrdrrrrtargetrrrnobib converterrawrmathjaxnofooterrtemplate noconvert notoclabelsrrrrrrsupfoot alignfootrWrrrxembedcssdictbranchesrrrrrrrrrrrrrrs~ .8 rc@BeZdZdZddZddZddZdd Zej d kreZ d Sd S) BranchOptionszA set of options for a branchcCs||_ddi|_dS)Ncolorz#ffffff)namerzr{rrrrr|szBranchOptions.__init__cCsB|tjdstd|dS|tjdd}||j|<dS)zSet a branch optionrzInvalid branch option Nr+)rr;rrrrrzr{rrrrrsets zBranchOptions.setcCsd|jvrdS|jddkS)z Return if the branch is selectedselectedF1ryrrrr isselecteds zBranchOptions.isselectedcCsd|jdt|jS)zString representationz options for r)rrrzrrrr __unicode__ zBranchOptions.__unicode__rN) rrr r!r|rrrr r__str__rrrrrs rc@s0eZdZdZddZddZeeZeeZdS)Clonerz&An object used to clone other objects.cCs ||jS)z"Return an exact copy of an object.)create __class__)r originalrrrclones z Cloner.clonecCs||}||S)z"Create an object of a given class.)__new__r|)r typerrrrrs z Cloner.createN)rrr r!rrr"rrrrrs  rc@0eZdZdZddZddZddZdd 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.rlrmrnNrk)r{configrrrr|)s  zContainerExtractor.__init__cs<gfdd}fdd}fdd}||||S)z?Extract a group of selected containers from elyxer.a container.cs|jjjjvSrx)rrrlrmr=rrr7z,ContainerExtractor.extract..cs|jjjvSrx)rrrnrrrrr8scs |Srx)processrrr{rrr9 )recursivesearch)r{ containerlocate recursiverrrrextract4s   zContainerExtractor.extractcCsP|jj}||jvr||dS||jvr|||dStd|dS)zBAdd allowed containers, clone cloned containers and add the clone.zUnknown container class N)rrrlrrm safeclonerr)r{rrrrrrr=s   zContainerExtractor.processcCs"t|}|j|_|||_|S)zFReturn a new container with contents only in a safe list, recursively.)rroutputrcontents)r{rrrrrrGs  zContainerExtractor.safecloneN)rrr r!r|rrrrrrrr&s   rc@sZeZdZdZddZddZddZdd Zd d Zd d Z ddZ e j dkr+e Z dSdS)ParserzA generic parsercCsd|_t|_dS)Nr)rrrrrrrr|Vs zParser.__init__cCs |}||j|_|S)zParse the header) currentlinernextline linenumberr)r{readerheaderrrr parseheaderZs zParser.parseheadercCs|dr||\}}||j|<dS|dd}|t|dkr-dS|d}t|dkr>d|j|<dSd|dvrO|d|j|<dS|dd}|d|j|<dS)zParse a parameterrNrrrTrw)r striprparsexmlrrr r)r{r rrr doublesplitrrrparseparameteras"     zParser.parseparameterc Cs|}||dstd|d|dd}t|dkr-tddS|d}|d=t|dkr?|tfSt}|D]+}d |vrYtd |d ||d 7}|d }|d}|dd d} | ||<qD||fS)z5Parse a parameter in xml form: rzXML parameter z should be <...>rrrzEmpty XML parameter <>NNrezErroneous attribute for rz="0"rw) r rr rrrrrr) r{r rrrattrsattrpartsattrkeyrrrrrus,        zParser.parsexmlcCsJ|jstdt|dS||js#|||jrdSdS)z'Parse until the current ending is foundzNo ending for N)endingrrrr r)r{r rrrr parseendings zParser.parseendingcCs*|j|}|r|j|_||dSdSrx)factorycreatecontainerparentr)r{r rrrrrparsecontainers zParser.parsecontainercCs|jjdt|jdS)zReturn a descriptionrr)rrrrrrrrrzParser.__unicode__rN)rrr r!r|rrrrrrr rrrrrrrSs rc@eZdZdZddZdS) LoneCommandz"A parser for just one command linecCgS)z Read nothingrr{r rrrparsezLoneCommand.parseNrrr r!r#rrrrr  r c@s,eZdZdZgZddZddZddZdS) TextParserz(A parser for a command and a bit of textcCs8t|d|_|jjtjvrtj|jj|_g|_dSrx)rr|rrrr;rr{rrrrr|s  zTextParser.__init__cCsVtj|jtjtjdtjd|jg|_g}||s)|||||r|S)z$Parse lines as long as they are textrIrH)r'stackrrr;risendingrr{r rrrrr#s     zTextParser.parsecCsZ|}t|dkrdS|d|jvr+|dtjvr&tj|ddSgt_dSdS)zCheck if text is endingrFT)r rrrr'r)remove)r{r rrrrr*s  zTextParser.isendingN)rrr r!r)r|r#r*rrrrr's  r'c@r)ExcludingParserz%A parser that excludes the final linecs gfddS)z5Parse everything up to (and excluding) the final linec Srx)rrrr r{rrrrz'ExcludingParser.parse..)rr"rr/rr#szExcludingParser.parseNr%rrrrr-r&r-c@r) BoundedParserzA parser bound by a final linecCst||}||S)z*Parse everything, including the final line)r-r#r r+rrrr#s zBoundedParser.parseNr%rrrrr0r&r0c@r) BoundedDummyz&A bound parser that ignores everythingcs |fddgS)z#Parse the contents of the containercsSrx)r rr rrrsz$BoundedDummy.parse..rr r"rr2rr#szBoundedDummy.parseNr%rrrrr1r&r1c@ eZdZdZddZddZdS) StringParserzParses just a stringcCs|jd|_gS)zDo nothing, just take noterr rr"rrrrs zStringParser.parseheadercCs|}||S)zParse a single line)r r r+rrrr#szStringParser.parseNrrr r!rr#rrrrr5 r5c@r) InsetParserzParses a LyX insetcCsTtjd}|dkr$||s$|||dkr$||rt||S)z(Parse inset parameters into a dictionaryrr+)r;rr rrr0r#)r{r rrrrr#s   zInsetParser.parseNr%rrrrr9r&r9c@r4)ContainerOutputz(The generic HTML output for a container.cCtdt|dS)zShow an error.zgethtml() not implemented for Nrrrr(rrrgethtml zContainerOutput.gethtmlcCdS)z5Decide if the output is empty: by default, not empty.Frrrrrisemptyr$zContainerOutput.isemptyN)rrr r!r=r@rrrrr: r:c@seZdZddZddZdS) EmptyOutputcCr!)zReturn empty HTML code.rr(rrrr=r$zEmptyOutput.gethtmlcCr?)z"This output is particularly empty.Trrrrrr@r$zEmptyOutput.isemptyN)rrr r=r@rrrrrBs rBc@r) FixedOutputz Fixed outputcCs|jS)zReturn constant HTML coderr(rrrr= zFixedOutput.gethtmlNrrr r!r=rrrrrCr&rCc@r)ContentsOutputz&Outputs the contents converted to HTMLcCs^g}|jdkr |S|jD] }t|ds&td|jjdt||S||7}q |S)Return the HTML codeNr=z No html in r)rrrrrrrr=)r{rrelementrrrr='s   zContentsOutput.gethtmlNrFrrrrrG$r&rGc@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{rKrLrMrrrsettag:s zTaggedOutput.settagcC ||_|S)zSet the value for breaklines.)rL)r{rLrrr setbreaklinesCzTaggedOutput.setbreaklinescCsB|jr ||gS||g}|t||7}||||S)zReturn the HTML code.)rM selfclosingopenrGr=rclose)r{rrrrrr=Hs   zTaggedOutput.gethtmlcC.||sdSd|jd}|jr|dS|S)zGet opening line.r+rrrchecktagrKrL)r{rrSrrrrSQ zTaggedOutput.opencCs:||sdSd|jdd}|jrd|dS|S)zGet closing line.r+zGlob a bit of text that satisfies a check on the current char.r+)rzr)r{ currentcheckglobrrrr1s  z Globable.globcfddS)zGlob a bit of alpha textc Srxrisalpharrrrr:rz$Globable.globalpha..rrrrr globalpha8rzGlobable.globalphacr)zGlob a row of digits.crrxrisdigitrrrrr>rz%Globable.globnumber..rrrrr globnumber<rzGlobable.globnumbercCs |s |dkrdSdS)z5Return if the current character is alphanumeric or _.rTF)risalnumrrrr isidentifier@szGlobable.isidentifiercC ||jS)z Glob alphanumeric and _ symbols.)rrrrrrglobidentifierF zGlobable.globidentifiercCs& |r dS|dvrdSdS)z5Return if the current character is a value character:Fz{}()TrisspacerrrrisvalueJs   zGlobable.isvaluecCr)z'Glob a value: any symbols but brackets.)rrrrrr globvalueSrzGlobable.globvaluecr)z(Skip all whitespace at current position.crrxrrrrrrYrz$Globable.skipspace..rrrrr skipspaceWrzGlobable.skipspacecs&fdd}|S)z4Glob a bit of text up to (including) the magic char.cs kSrxrr magiccharr{rrr]rz(Globable.globincluding..)rskip)r{rrrrr globincluding[s zGlobable.globincludingcsfddS)z?Glob a bit of text up until (excluding) any excluded character.cs vSrxrrexcludedr{rrrcrz(Globable.globexcluding..r)r{rrrr globexcludingar^zGlobable.globexcludingcCs|j||dS)zPush a new ending to the bottomN)raddr{roptionalrrr pushendingerzGlobable.pushendingNcCsN|r |jr |S|j|}|r ||kr td|d||||S)z,Pop the ending found at the current positionzExpected ending z, got )rrrpoprrr)r{expectedrrrr popendingis   zGlobable.popendingcCs|j|}|s dS|jS)z$Return the next ending in the queue.N)r findendingr)r{ nextendingrrrrss zGlobable.nextendingFrx)rrr r!rr|rrrrrzrrrrrrrrrrrrrrrrrrrs.    rc@sdeZdZdZddZdddZddZd d Zd d Zd dZ ddZ ddZ e j dkr0e ZdSdS)rzA list of position endingscCs g|_dSrx)rrrrrr|}r}zEndingList.__init__FcCs|jt||dS)zAdd a new ending to the listN)rrPositionEndingrrrrrr>zEndingList.addcCs|j|jj7_dS)z/Pick any pending endings from a parse position.N)rrr{posrrr pickpendingr>zEndingList.pickpendingcCs||rdSdS)zSearch for an endingTF)rrrrrrs zEndingList.checkincCs|r tddS||}|std|dSt|jD]}|j|||kr3|jS|j s=td|q"tddS)z)Remove the ending at the current positionzNo ending out of boundsr+z No ending at zRemoved non-optional ending zNo endings left) rrrrrreversedrr,rr)r{rreachrrrrs      zEndingList.popcCsLt|jdkr dStt|jD]\}}||r|S|js#dSqdS)z'Find the ending at the current positionrN)rr enumeraterrr)r{rrYrrrrrs zEndingList.findendingcCs,t|jdkrtdt|ddSdS)z&Check if there are any pending endingsrzPending z left openN)rrrrrrrrrrszEndingList.checkpendingcCsBd}|jD] }|t|d7}qt|jdkr|dd}|dS)Printable representationz endings [rcrNrr)rrr)r{rrrrrrs   zEndingList.__unicode__rNr)rrr r!r|rrrrrrrr rrrrrrrzs   rc@:eZdZdZddZddZddZejdkreZ d Sd S) rz An ending for a parsing positioncCs||_||_dSrxrrrrrrr| zPositionEnding.__init__cC ||jS)zCheck for the ending)rrrrrrrrzPositionEnding.checkincCsd|j}|jr |d7}|S)rzEnding z (optional)rrrrrrs zPositionEnding.__unicode__rN) rrr r!r|rrr rrrrrrrs rc@sneZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ e j dkr-e ZddZddZdS)PositionzA position in a text to parse. Including those in Globable, functions to implement by subclasses are: skip(), identifier(), extract(), isout() and current().cCst|dSrx)rr|rrrrr|r}zPosition.__init__cCr)z Skip a stringzUnimplemented skip()Nrrrrrrz Position.skipcCr)z.Return an identifier for the current position.zUnimplemented identifier()Errorrrrrr identifierrzPosition.identifiercCs tddS)zHExtract the next string of the given length, or None if not enough text,zUnimplemented extract()Nrr{lengthrrrrs zPosition.extractcCs||t|kS)z)Check for a string at the given position.)rrrrrrrrzPosition.checkforcCs0|t|}|s dS||t|kS)z!Check for a string in lower case.F)rrlower)r{rrnrrr checkforlowerszPosition.checkforlowercCs|}|||S)r)rrr{rrrrrs zPosition.skipcurrentcCs||S)z3Advance the position and return the next character.)rrrrrr__next__szPosition.__next__rcCs||sdS||dS)z;Check for a string at the given position; if there, skip itFT)rrrrrr checkskips  zPosition.checkskipcCst|d|dS)z2Show an error message and the position identifier.rN)rrr)r{r rrrr rzPosition.errorN)rrr r!r|rrrrrrrr rr[rrrrrrrs  rc@@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)rr|rrrr{rrrrr|s  zTextPosition.__init__cCs|jt|7_dS)Skip a string of characters.N)rrrrrrrr>zTextPosition.skipcCsFd}|j|t|jkrt|j|j}d|j|j|j|dS)z&Return a sample of the remaining text.rjrrrrrrrrszTextPosition.identifiercCs|jt|jkS)'Find out if we are out of the text yet.rrrrrr#zTextPosition.isoutcCs |j|jS)6Return the current character, assuming we are not out.)rrrrrrr'rzTextPosition.currentcCs.|j|t|jkr dS|j|j|j|SzHExtract the next string of the given length, or None if not enough text.Nrrrrrr+szTextPosition.extractN) rrr r!r|rrrrrrrrrrs rc@XeZdZdZddZddZddZdd 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)rr|rdr rrrrrrr|4s   zFilePosition.__init__cCsnt|}|j|t|jkr.|t|j|jd8}||j|t|jks|j|7_dS)rrN)rrr r r )r{rrrrrr;s zFilePosition.skipcC |jS)z,Get the current line of the underlying file.)r r rrrrr Cr[zFilePosition.currentlinecCs|jd|_dS)zGo to the next line.rN)r r rrrrrr G  zFilePosition.nextlinecCs |jjdS)z#Return the line number of the file.r)r r rrrrr LrzFilePosition.linenumbercCsL|jd|jd}|j|jd}dt|d|d|S)z4Return the current line and line number in the file.Nrzline rrj)r r rr getlinenumber)r{beforeafterrrrrPs zFilePosition.identifiercCs`|jt|jkr+|jt|jdkr'td|jdt|j||jS)rrOut of the line r) rrr r rrrr rzrrrrrVs " zFilePosition.isoutcCsb|jt|jkr dS|jt|jkr)td|jdt|jdS|j|jS)rrrrrj)rrr r rrrrrrrr^s "zFilePosition.currentcCs6|j|t|jkrdS|j|j|j|Sr)rrr r rrrrrgszFilePosition.extractN) rrr r!r|rr r r rrrrrrrrr1s rc@seZdZdZdZdZdZddZddZddZ d d Z e j fd d Z d dZddZddZddZddZddZddZddZddZd+d d!Zd"d#Zd$d%Zd&d'Zd(d)Zejd*kreeZdSdS), Containerz.A container for text and objects in a lyx fileNcCrrx)rrrrrrr|vrzContainer.__init__cCr?)Process contentsNrrrrrryr$zContainer.processcCs4|j|}t|trtd||g}||S)zGet the resulting HTMLz Raw string )rr=rrrr escapeall)r{rrrrr=}s   zContainer.gethtmlcCsdg}|D]+}tjr||tj}tjr ||tj}||}n tjs*||tj}||q|S)z=Escape all lines in an array according to the output options.) rrescaperrescapeentitiesrrr)r{linesrrrrrrs  zContainer.escapeallcCs2t|}|D]}||vr||||}q|S)z1Escape a line with replacements from elyxer.a map)sortedkeysr)r{r replacementspiecespiecerrrrs zContainer.escapecCsd}t|}|sCt|dkr5tt|}|dkr(ttt|d}|d|ddd7}n||7}||r |S) z/Escape all Unicode characters to HTML entities.r+0xd835iz&#rNrv)rrzrrhexr[r)r{rrr codepointrrrrs  zContainer.escapeentitiescsg||fddS)z2Search for all embedded containers of a given typecs |Srx)rrrrrr z%Container.searchall..) searchprocessr{rrrr searchallszContainer.searchallcCs&||}|D] }|jj|q|S)z3Search for all containers of a type and remove them)rrrr,)r{rrrrrr searchremoves zContainer.searchremovecs|fdd|dS)z4Search for elements of a given type and process themcs t|Srx)rrrrrrrz)Container.searchprocess..N) locateprocess)r{rrrrrrrzContainer.searchprocesscCs,|jD]}|||||r||qdS)z3Search for all embedded containers and process themN)rr)r{rrrrrrrs  zContainer.locateprocesscCs6|jD]}||r||||||r||qdS)z,Perform a recursive search in the container.N)rr)r{rrrrrrrrs zContainer.recursivesearchcCs,d}ttj|}|D]}||j7}q |S)z0Extract all text from elyxer.allowed containers.r+)rr;rrr)r{rrconstantrrrrs  zContainer.extracttextcCs|t|jkr dSt|j|drdS|t|jkrD||j|rDd|j|_|j|j||j||t|jkrD||j|s!|j||dS)z*Group some adjoining elements into a groupNgroupedT)rrrrrrr)r{rYrM isingrouprrrrMs  zContainer.groupcCsN|j|}|j|t|jdkr%|j||jt|jdksdSdS)z)Remove a container but leave its contentsrN)rrrr)r{rYrrrrr,s  zContainer.removercCs4td|t||jD] }||dqdS)zShow in a treer#rN)rrrrtree)r{levelrrrrrs zContainer.treecC||jvrdS|j|S)z)Get the value of a parameter, if present.N)rrrrr getparameter  zContainer.getparametercCs||}|s gS|dS)z7Get the value of a comma-separated parameter as a list.rc)rr)r{r paramtextrrrgetparameterlists  zContainer.getparameterlistcCs&|j}|r|jr dS|j}|sdS)z&Check if the parent's output is empty.TF)rrr@rrrrhasemptyoutputs zContainer.hasemptyoutputcCs$|js|jjS|jjdt|jS)zGet a descriptionrf)rrrrrrrrr szContainer.__unicode__r)r)rrr r!partkeyrrr|rr=rrrrrrrrrrrrMr,rrr r rr rrrrrrros6   rc@r)rqz)A container that does not output anythingcCst|_t|_g|_dSrx)r rrBrrrrrrr|  zBlackBox.__init__Nrrr r!r|rrrrrq r&rqc@r)rzRead the lyxformat commandcCsTt|jd}|dkrtdt||ttjdkr(tdt|dSdS)zShow warning if version < 276riz(Warning: unsupported old format version rz(Warning: unsupported new format version N)rr rrstrrr)r{rrrrr s zLyXFormat.processNrrr r!rrrrrr r&rc@sVeZdZdZdZddZddZddZd d Zd d Z d dZ e j dkr)e Z dSdS)rTzA container for a single stringNcCst|_t|_d|_dS)Nr+)r5rr`rrrrrrr|$ r zStringContainer.__init__cCs"|jr||j|_d|_dSdS)z/Replace special chars from elyxer.the contents.N)parsedreplacespecialrrrrrr) s zStringContainer.processcCsf||tj}||}tjd|vr1t|dkr1|jr&dt|jd}nd}t || |S)z,Replace all special chars from elyxer.a linerrzUnknown command at rzUnknown command: ) rrr changeliner;rrrrrrr)r{rr:r rrrr/ s zStringContainer.replacespecialcCs2||tj}tjd|vr|S||tj}|S)Nr)rrrr;rrrrrrr< s zStringContainer.changelinecC|jS)zReturn all text.rarrrrrC rEzStringContainer.extracttextcCsXd}|jr|dt|j7}d}t|jdkrd}|d|jdd|dS) "Return a printable representation.rTrfz...r+rNr)rrrrr)r{rellipsisrrrrG s"zStringContainer.__unicode__r)rrr r!rr|rrrrrr rrrrrrrT s  rTc@2eZdZdZddZddZejdkreZdSdS)rUzA constant stringcCsg|_||_t|_dSrx)rrr`rrrrrr|X s zConstant.__init__cC d|jS)Nz Constant: rarrrrr] r}zConstant.__unicode__rN rrr r!r|rr rrrrrrrUU s rUc@sJeZdZdZdZddZd ddZd dd Zd d Ze j d kr#eZ dSdS)rXzText inside a tagNcCst||_t|_dSrx)r'rrJrrrrrr|i s  zTaggedText.__init__FcCs||_||j_||j_|S)z&Complete the tagged text and return it)rrrKrLr{rrKrLrrrcompletem szTaggedText.completecCst|}||g||S)z(Complete the tagged text with a constant)rUr)r{rrKrLrrrrrt zTaggedText.constantcCs,t|jdsdS|jjsdSd|jjdS)rrKzEmtpy tagged textzTagged zTagged / z*FormulaBit.computesize..)rrrr*rrrr computesize+ szFormulaBit.computesizecCs|j|jSzReturn a copy of itself.)rr-rrrrrr2 rzFormulaBit.clonecCs|jjd|jS)zGet a string representationz read in )rrrrrrrr6 rzFormulaBit.__unicode__r)rrr r!rr*rr|r>rrArHrrr rrrrrrr< s r<c@s*eZdZdZddZd ddZddZd S) TaggedBitzA tagged string in a formulacCs t||_|t||SzSet the constant and the tag)rJrNrrrV)r{rrKrrrrA szTaggedBit.constantFcCs||_t|||_|SrK)rrJrNrrrrrrG szTaggedBit.completecCstj|dd|_|S)z4Set the self-closing tag, no contents (as in
).T)rM)rJrNrr{rKrrr selfcompleteM szTaggedBit.selfcompleteNr)rrr r!rrrMrrrrrJ> s   rJc@r) rVzA constant string in a formulacCs"t||||_d|_d|_dS)zSet the constant stringrN)rUr|rr*rrrrrr|U s  zFormulaConstant.__init__cCr)z+Compute the size of the constant: always 1.rCrrrrrH\ rEzFormulaConstant.computesizecC t|jSrI)rVrrrrrr` r[zFormulaConstant.clonecCr)rzFormula constant: rarrrrrd r[zFormulaConstant.__unicode__rN) rrr r!r|rHrrr rrrrrrrVR s rVc@r4)r]zA bit of text inside a formulacC |S)zDetect a bit of raw textrrrrrdetecto rzRawText.detectcCs |}|t|d|_dS)zParse alphabetic textr0N)rrrVr)r{rr0rrrparsebits s zRawText.parsebitNrrr r!rPrQrrrrr]l rAr]c@s8eZdZdZejZejdZddZddZddZ d S) rhzA symbol inside a formularscCs(|tjvr dS|tjvrdSdS)zDetect a symbolTF)rrhrrrrrrrP s zFormulaSymbol.detectcCsd|tjvr|||dS|tjvr%|tj||dStd|ddS)Parse the symbolNzSymbol not found)rrhr addsymbolrrrrrrrrQ szFormulaSymbol.parsebitcCs$||||jt|dS)z Add a symbolN)rArrrrV)r{symbolrrrrrU szFormulaSymbol.addsymbolN) rrr r!rrrrPrQrUrrrrrhy s  rhc@r4)r_zA string of digits in a formulacCrO)zDetect a digitrrrrrrP rzFormulaNumber.detectcs*fdd}|t|d|_dS)zParse a bunch of digitscrrxrrrrrr rz(FormulaNumber.parsebit..rN)rrrVr)r{rdigitsrrWrrQ s zFormulaNumber.parsebitNrRrrrrr_ rAr_c@s*eZdZdZejdZddZddZdS)rCz*A LaTeX comment: % to the end of the line.rncCs||jkS)z Detect the %.)rr:rrrrrP rzComment.detectcCs|j|d7_dS)zParse to the end of the line.rN)rrrrrrrQ rzComment.parsebitN) rrr r!rrr:rPrQrrrrrC s   rCc@r) WhiteSpacez"Some white space inside a formula.cCrO)zDetect the white space.rrrrrrP rzWhiteSpace.detectcCs|j|7_dS)zParse all whitespace.N)rrrrrrrQ r>zWhiteSpace.parsebitcCsd|jdS)rz Whitespace: *rj)rrrrrr rzWhiteSpace.__unicode__rN) rrr r!rPrQrr rrrrrrrY s rYc@sleZdZdZejdZejdZddZ ddZ ddZ d d Z d d Z d dZddZddZddZdS)r\zA {} bracket inside a formular6cCst|d|_dS)z'Create a (possibly literal) new bracketN)r<r|innerrrrrr| rzBracket.__init__cCr)zDetect the start of a bracket)rr:rrrrrP rzBracket.detectcC|||j|S)zParse the bracket) parsecomplete innerformularrrrrQ zBracket.parsebitcCr[)zParse a text bracket)r\ innertextrrrr parsetext r^zBracket.parsetextcCr[)zParse a literal bracket)r\ innerliteralrrrr parseliteral r^zBracket.parseliteralcCsp||jstd|jd|dS||j|||j|||j| |j7_| dS)zParse the start and end markszBracket should start with z at N) rr:rrrrArrrrrH)r{r innerparserrrrr\ s   zBracket.parsecompletecC*|s||j||rdSdS)z(Parse a whole formula inside the bracketNrzrrparseanyrrrrr] zBracket.innerformulacCsttj}|tjd|tjd|tj|sL| |vr=| |j || dr<|jd7_n | t||r!dSdS)zzMathsProcessor.processcCs d|jjS)zReturn a printable description.zMaths processor )rrrrrrr rzMathsProcessor.__unicode__rN) rrr r!rrr rrrrrrrk  rkc@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 traversewholer?rrrr* s  zFormulaProcessor.processcCs0t|tsdS||jD]}||qdS)z&Process the contents of a formula bit.N)rr<rrro)r{r@rIrrrro0 s   z FormulaProcessor.processcontentscCsJt|tsdSt|jD]\}}|jD] }||j|q||q dS)z8Process the insides (limits, brackets) in a formula bit.N)rr<rr processorsrrp)r{r@rYrI processorrrrrp8 s   zFormulaProcessor.processinsidescCsbd}||D]'\}}|jdkr|||n|jdkr,|r,|jdkr,|jdtd|}qdS)z>Traverse over the contents to alter variables and space units.Nr0fontrrr)traverser italicizerrrV)r{r.lastr@rrrrrqB s zFormulaProcessor.traversewholeccsP|jD]!}t|dr|jr||jfVqt|tr%||D]}|VqqdS)zHTraverse a formula and yield a flattened structure of (bit, list) pairs.rN)rrrrr<ru)r{r@rIpairrrrruL s  zFormulaProcessor.traversecCs"||}t|gd||<dS)z Italicize the given bit of text.rBN)rYrJr)r{r@rrYrrrrvU s zFormulaProcessor.italicizeN) rrr r!rrrrorprqrurvrrrrrn% s  rnc@seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZejdkrGeZdSdS) r[zA LaTeX formulacCt|_td|_dS)Nzspan class="formula")r$rrJrNrrrrrr|` zFormula.__init__cCsl|jddkr dt_n dt_|jddtjr|dStjr'|dStjr0|dS| dS)zConvert the formula to tagsrr(FTzdiv class="formula"N) r rr#rrNrrrrxclassicrrrrrd s    zFormula.processcCs>|jddkrtd|_ntd|_t|jg|_dS)zMake the contents for jsMath.rr(zdiv class="math"zspan class="math"N)r rJrNrrUrrrrrrrt szFormula.jsmathcCs@d|j_d}|jddkr|d7}t|j|ddg|_dS) zMake the contents for MathJax.zspan class="MathJax_Preview"zscript type="math/texrr(z ;mode=displayrwTN)rrKr rXrrrrLrrrr| s zFormula.mathjaxcCs:tjdt|j}d|d|jd}t|g|_dS)zIMake the contents using Google Charts http://code.google.com/apis/chart/.rxzzN)rrrrrUr)r{urlimgrrrrx szFormula.googlechartscCs,t|j}t|||_|g|_dS)zEMake the contents using classic output generation with XHTML and CSS.N)FormulaFactoryr-rrnrrr)r{wholerrrr{ s  zFormula.classiccCsr|dr ||n(|dr||n|dr"||dn|dr.||dn|d||S)z4Parse using a parse position instead of self.parser.z$$rz\(z\)rir5zUnparseable formula)rparsedollarblockparsedollarinline parseinlineto parseblocktorrrrrrr# s       z Formula.parsecCsdg|_||dS)zParse a $...$ formula.r(N)r  parsedollarrrrrr szFormula.parsedollarinlinecCs.dg|_|||ds|ddSdS)zParse a $$...$$ formula.r)rz1Formula should be $$...$$, but last $ is missing.N)r rrrrrrrr s   zFormula.parsedollarblockcCs$|d|d|_|ddS)zParse to the next $.rN)rrrrrrrrr s  zFormula.parsedollarcCdg|_|||dS)zParse a \(...\) formula.r(Nr  parseuptor{rlimitrrrr rzFormula.parseinlinetocCr)zParse a \[...\] formula.r)Nrrrrrr rzFormula.parseblocktocCs(|||dd|_||dS)z1Parse a formula that ends with the given command.cSr?NTrrrrrr sz#Formula.parseupto..N)rrrrrrrrr s zFormula.parseuptocCs"|jr|jjrd|jjdSdS)rz Formula (rzUnnumbered formula)r rrrrrr szFormula.__unicode__rN)rrr r!r|rrrrxr{r#rrrrrrrr rrrrrrr[] s& r[c@r4) WholeFormulazParse a whole formulacCs | S)z"Not outside the formula is enough.)rzrrrrrP r[zWholeFormula.detectcCrd)zParse with any formula bitNrerrrrrQ rgzWholeFormula.parsebitNrRrrrrr rArc@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 instancesrrrrr| rzFormulaFactory.__init__cCs|rdS|||S)zDetect a bit of a given type.F)rzrrP)r{rrrrr detecttype szFormulaFactory.detecttypecCs.||jvs |j|s|||j|<|j|S)z"Get an instance of the given type.)rrrrrrr s zFormulaFactory.instancecCst||S)z+Create a new formula bit of the given type.)rrr>rrrrr rzFormulaFactory.createcCs"|s||s dS|rdS)zClear any skipped types.N)rzskipanyrrrr clearskipped s  zFormulaFactory.clearskippedcCs0|jD]}|||r|||SqdS)zSkip any skipped types.N) skippedtypesrrPr'r{rrrrrr s zFormulaFactory.skipanycCsL|j|jD]}|||r|||Sqtd|t|S)z.Parse any formula bit at the current location.zUnrecognized formula at ) typesrrr'rrrrVrrrrrrf s   zFormulaFactory.parseanycCs0||}d|j|<||}|r||S|S)z#Parse the given type and return it.N)rrrQr>)r{rrr@ returnedbitrrrr' s    zFormulaFactory.parsetypecCs\t|}|t}||r|||S|s,td|| t |d|S)z5Parse a string of text that contains a whole formula.zUnknown formula at: span class="unknown") rrrrPrQrzrrrrrJr)r{r.rrrrrr- s   zFormulaFactory.parseformulaN)rrr r!rhr]r_r\rCrYrrdefiningr|rrrrrrfr'r-rrrrr~ s r~c@sFeZdZdZ dZddZeeZddZddZd 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 rrrr translate' rzTranslator.translatecCsd|_d|_dSr) translationfirstrrrrr|- rzTranslator.__init__cCsd|_tjs tddStjtjvrtdtjdStjtjdkr'dStjtjg}z tdd||_WdSt yLtdt |YdSw)z/Find the translation for the document language.NzNo language in documentzUnknown language rgelyxerzNo translation for ) langcodesrrrrrRrvgettextrIOErrorr)r{rrrrfindtranslation1 s   zTranslator.findtranslationcCsP|jr |d|_||}|js|Sz |j|}W|Sty'Y|Sw)z-Get the translated message for the given key.F)rrgetuntranslatedrugettextr)r{rr rrrrB s  zTranslator.getmessagecCs&|tjvrtd||Stj|S)zGet the untranslated message.zCannot translate )rRrrrr{rrrrrP s  zTranslator.getuntranslated) rrr r!rrr"r|rrrrrrrr! s rc@seZdZdZ dZdZdZdZdZe j dZ gdZ ddZ dd Zd d Zd d ZddZddZddZddZddZddZddZddZejdkrSeZdSdS) NumberCounterz#A counter for numbers (by default).NABCDEFGHIJKLMNOPQRSTUVWXYZr) )Mrv)CMi)Di)CDi)Cd)XCZ)L2)XL()Xr)IX )V)IV)IrcCrs)zGive a name to the counter.N)rrrrrr|l r[zNumberCounter.__init__cCrO)z0Set the counter mode. Can be changed at runtime.)r)r{rrrrsetmodep rQzNumberCounter.setmodecCrs)zSet an initial value.Nrr{rrrrinitu r[zNumberCounter.initcCrN)z$Get the next value as a text string.)rrrrrrry r[zNumberCounter.gettextcCr)zGet the next value as a letter.) getsequencelettersrrrr getletter} rzNumberCounter.getlettercCr)zGet the next value as a symbol.)rrrrrr getsymbol rzNumberCounter.getsymbolcCs||jdt|S)z*Get the next value from elyxer.a sequence.r)rr)r{rrrrr r>zNumberCounter.getsequencecCs>d}|j}|jD]\}}||kr||||7}||}q|S)z%Get the next value as a roman number.r+)r romannumerals)r{rrnumeralrrrrgetroman szNumberCounter.getromancCs||jr|jdvr |S|jdkr|S|jdkr |S|jdkr)|S|jdkr2|Std|j|S)z8Get the current value as configured in the current mode.)rrAarrjzUnknown counter mode )rrrrrrrrrrrrgetvalue s     zNumberCounter.getvaluecCs"|jsd|_|jd7_|S)z@Increase the current value and get the next value as configured.rr)rrrrrrgetnext szNumberCounter.getnextcC d|_dS)zReset the counter.rNrrrrrreset r[zNumberCounter.resetcCs"d|j}|jr|d|j7}|S)rzCounter z in mode )rrr{rrrrr s zNumberCounter.__unicode__r)rrr r!rrrmasterrrrrrr|rrrrrrrrrrrr rrrrrrr[ s2   rc@(eZdZdZddZddZddZdS) DependentCounterz4A counter which depends on another one (the master).cCs||_|j|_|S)zSet the master counter.)rrrw)r{rrrr setmaster s zDependentCounter.setmastercCs2|j|jkr |t|}|j|_|S)z8Increase or, if the master counter has changed, restart.)rwrrrrrrrrrr s   zDependentCounter.getnextcCs|jdt|S)z8Get the value of the combined counter: master.dependent.r8)rrrrrrrr rzDependentCounter.getvalueN)rrr r!rrrrrrrr s  rc@seZdZdZ dZdZddejdDZddejdDZ 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:NcCg|]}|qSrrrExrrrrF rzNumberGenerator.rcCrrrrrrrrF rrcCs |ddS)z.Remove the possible asterisk in a layout type.rjr+)rrrrr deasterisk rzNumberGenerator.deasteriskcCs ||S)z9Find out if the layout type corresponds to a unique part.)isromanrrrrisunique r[zNumberGenerator.isuniquecC|||jvS)z9Find out if the layout type should have roman numeration.)rr romanlayoutsrrrrr r^zNumberGenerator.isromancCr)z?Find out if the layout type corresponds to an (un)ordered part.)rrorderedlayoutsrrrr isinordered r^zNumberGenerator.isinorderedcCs@d|vrdS||r dS||sdS||tjkrdSdS)zCFind out if the type for a layout corresponds to a numbered layout.rjFT)rrgetlevelrr"rrrr isnumbered s  zNumberGenerator.isnumberedcCsd|vS)z5Find out if the type contains an asterisk, basically.rjrrrrr isunordered rbzNumberGenerator.isunorderedcCsR||rdS||std|dS||}|j|d}|tj S)z0Get the level that corresponds to a layout type.rzUnknown layout type r) rrrrrrrrYrr!)r{rrrrrr s   zNumberGenerator.getlevelcCs$ tjr ||dkr dS||S)z4Obtain the type for the part: without the asterisk, rrS)rappendixrrrrrr getparttype s zNumberGenerator.getparttypecCs ||S)z$Generate a number for a layout type.) getcounterrrrrrgenerate s zNumberGenerator.generatecCs,|}||jvr|||j|<|j|S)z#Get the counter for the given type.)rcountersrrrrrr s  zNumberGenerator.getcountercCsh||r$||dkr$|j|}|j|d}||}|||St|}||r2|d|S)z$Create a counter for the given type.rr) rrrrYrcreatedependentrrr)r{rrYabovercounterrrrr s     zNumberGenerator.createcCs2||jvs |j|js||||j|<|j|S)zDGet (or create) a counter of the given type that depends on another.)rrrr{rrrrrgetdependentcounter* s z#NumberGenerator.getdependentcountercCst||S)z,Create a dependent counter given the master.)rrrrrrr0 rzNumberGenerator.createdependentcCs.|jtj}||}|ddt_dS)zStart appendices here.rTN)rrr!rrrrr)r{ firsttyperrrr startappendix4 s   zNumberGenerator.startappendix)rrr r! chaptered generatorrrrrrrrrrrrrrrrrrrrrrrrrrr s4    rc@eZdZdZ ddZdS)ChapteredGeneratorz1Generate chaptered numbers, as in Chapter.Number.cCs2 tjdkr tj|S|d}|||S)zBGenerate a number which goes with first-level numbers (chapters). rr)rr!rrrrrr)r{rchapterrrrr? s    zChapteredGenerator.generateN)rrr r!rrrrrr;  rc@seZdZdZdZdZdZdZdZdddZ dddZ ddZ d d Z d d Z d dZddZddZddZddZddZddZddZdS) ContainerSizezThe size of a container.NcC|d||d||S)z*Set the proper size with width and height.widthheightsetvaluer{rrrrrrY   zContainerSize.setcCr)zSet max width and/or height.maxwidth maxheightr)r{rrrrrsetmax_ rzContainerSize.setmaxcCs2||d||d||d|||S)z*Read some size parameters off a container.rrscale) setparametercheckvalidheightr(rrrreadparameterse s    zContainerSize.readparameterscCs||}|||dS)z=Read a size parameter off a container, and set it if present.N)rr)r{rrrrrrrm s zContainerSize.setparametercCs"||}|rt|||dSdS)z6Set the value of a parameter name, only if it's valid.N)processparameterrr{rrrrrrr s zContainerSize.setvaluecCs>|d}|jr||jdkr|dkrd|_dSdSdSdS)z;Check if the height parameter is valid; otherwise erase it.height_specialr totalheightN)rr extractnumber)r{r heightspecialrrrrx s   zContainerSize.checkvalidheightcCsB|sdS||dkr dStjdD] }||vr||d}q|S)z&Do the full processing on a parameter.N0rr+)rrr*r)r{rrErrrr~ s zContainerSize.processparametercCsHd}d}|D]}|r||7}q|dkr|s||7}d}q|S|S)z+Extract the first number in the given text.r+Fr8T)r)r{rrdecimalcharrrrr s  zContainerSize.extractnumbercCs|rt|d|_|jr|js|||_|r*t|d|_|jr*|js*|||_|jr3|js3d|_|jr>|js@d|_dSdSdS)z-Check image dimensions, set them if possible.pxautoN)rrrr scalevaluerrrrrr checkimage s       zContainerSize.checkimagecCs"|t|jd}tt|dS)zFScale the value according to the image scale and return it as unicode.rr)rrr)r{rscaledrrrr  szContainerSize.scalevaluecCs8|jsdSd|jvr dS|j}d|_|jdkrd|_|S)z?Remove percent width if present, to set it at the figure level.Nrr )rr)r{rrrrremovepercentwidth s  z ContainerSize.removepercentwidthcCst|jtstdt||js|js|js|j sdSd}|| d7}|| d7}|| d7}|| d7}|dd krG|dd}|d 7}|jj |7_ dS) z1Add the proper style attribute to the output tag.zNo tag to add style, in Nz style="rrrrrrrw) rrrJrrrrrrrstyleparameterrK)r{rrKrrraddstyle s   zContainerSize.addstylecCs*t||}|r|ddd|dSdS)z%Get the style for a single parameter.rzmax-rz; r+)rrrrrrr s zContainerSize.styleparameterr)rrr r!rrrrrrrrrrrrrr r r rrrrrrrP s(    rc@r4)rzA container for a pretty quotecCt|_t|_dSrx)r0rrCrrrrrr|  zQuoteContainer.__init__cCsL|jd|_|jtjvrtd|jddg|_dStj|jg|_dS)rrz Quote type rTrwN)r rrr(rrrrrrrr s  zQuoteContainer.processNrrr r!r|rrrrrr rArc@r4)rz A Lyx linecCrrxr rrCrrrrrr| rzLyXLine.__init__cCs dg|_dS)Nz
rDrrrrr rzLyXLine.processNrrrrrr rArc@r)rEzText with emphatic modecC d|j_dS)NrBrrKrrrrr rzEmphaticText.processNrrrrrrE r&rEc@r)rMzText shaped (italic, slanted)cCsL|jd|_|jtjvrtd|jdd|j_dStj|j|j_dS)NrzUnrecognized shape span)r rr/rQrrrrKrrrrr s  zShapedText.processNrrrrrrM r&rMc@r)rSzText in versalitascCr)Nrrrrrrrr rzVersalitasText.processNrrrrrrS r&rSc@r)rCz Colored textcC"|jd|_d|jd|j_dSNrz span class="rw)r rrrKrrrrr zColorText.processNrrrrrrCr&rCc@r)rOz Sized textcCrr)r r*rrKrrrrr rzSizeText.processNrrrrrrO r&rOc@r)r?z Bold textcCr)NrArrrrrrrzBoldText.processNrrrrrr?r&r?c@r)rRz,A bit of text from elyxer.a different familycCsF|jd|_|jtjvrtdtd|j_dStj|j|j_dS)zParse the type of familyrzUnrecognized family rN)r rr/rKrrrrKrrrrrs  zTextFamily.processNrrrrrrRr&rRc@r)rFzHorizontall fillcCr)Nzspan class="hfill"rrrrrr%rz Hfill.processNrrrrrrF"r&rFc@r)r=zText with a bar somewherecCsH|jd|_|jtjvrtd|jd|j_dStj|j|j_dS)zParse the type of barrzUnknown bar type rN)r rr/rJrrrrKrrrrr+s  zBarredText.processNrrrrrr=(r&r=c@r)rZz A line with language informationcCsF|jd}|tjvrt|_dStj|}td|dd|_dS)zDOnly generate a span with lang info when the language is recognized.rNz span lang="rwF)r rRrvrGrrJrN)r{langisolangrrrr7s   zLangLine.processNrrrrrrZ4r&rZc@r)rz!A length measure inside an inset.cCs|jd|_dS)Nr)r rrrrrrCszInsetLength.processNrrrrrr@r&rc@r) rzA space of several typescCrrxr9rrCrrrrrr|IrzSpace.__init__cCsz|jd|_|jtjvrtd|jdg|_dStj|jg|_|}|s*dSt dd|_ t | |dS)NrzUnknown space type rzspan class="hspace"F)r rrr'rrr getlengthrJrNrrrrrrrrrMs  z Space.processcCs.t|jdkst|jdtsdS|jdjS)z.N) instantiater stagedict)r{classesr.rrrrr|Es zStageDict.__init__cCs*dd|D}|D] }|||_q |S)z-Instantiate an element from elyxer.each classcSsg|]}||qSr)rrrrrrFLr3z)StageDict.instantiate..)r|r.)r{r6r.r*rIrrrr4Js zStageDict.instantiatecCs|j|jvrdS|j|jS)z=Get the stage for a given element, if the type is in the dictN)rr5r{rIrrrr0Rs  zStageDict.getstageN)rrr r!r|r4r0rrrrr)Bs  r)c@s^eZdZdZeZdZddZddZdddZ d d Z d d Z d dZ e jdkr-e ZdSdS)r}zA label to be referencedNcCst|d|_dSrx)r!r| lastnumberedrrrrr|`s  zLabel.__init__cCs"|d}|d|tj|_dS)zProcess a label container.rrN)rrr} lastlayoutr8rrrrrds   z Label.processcCsD||_|j|||d|tj|<|tjvr tj|D]}||_q|S)z!Create the label for a given key.)r#r)rrr}namesrrbr$)r{rrr referencerrrrjs  z Label.createcCs||}|r |jr |jSdS)z8Get the part key for the latest numbered container seen.r+)r*r )r{r*rrr findpartkeyts  zLabel.findpartkeycCs,|jr|S|js|jr|jSdS||jS)z)Get the numbered container for the label.N)r rr8r*r(rrrr*{s zLabel.numberedcCst|dsdSd|jS)rrz Unnamed labelzLabel )rrrrrrrrzLabel.__unicode__r)r})rrr r!rr:r9r|rrr<r*rr rrrrrrr}Zs   r}c@sLeZdZdZeZdZddZddZddZ d d Z e j d kr$e Z d Sd S) rzA reference to a label.nonecCs|d|_|jtjvrd|_tj|j}n d|_td|jd}||_||jtj vr5gtj |j<tj |j |dS)z%Read the reference and set the arrow.r;r2rrprerefN) rrr}r: directionrr$formatcontentsrrbr)r{labelrrrrs    zReference.processcCs|d}|s d}d|_|tjvrtj||_ntd||d|j|dd|dt d|j }|d|oA|j |d |oJ|j d |jvsV|rV|js_t|jg|_d S|jd }t|d g|_|d d D]}|j|j7_|jt|qsd S)zFormat the reference contents. LatexCommandrr3zUnknown reference format rrr_rfrrNrr)rrrr)rrrr?rrr$r<rtocentry titlecontentsrUrrr)r{ formatkeyr rrrrrr@s,     zReference.formatcontentscCs*||jvrdS|s d}|j|||_dS)z2Replace a key in the format template with a value.Nr+)rrrrrrrs zReference.replacecCr)rz Reference )rrrrrrr[zReference.__unicode__rN)rrr r!rrbrrr@rrr rrrrrrrs rc@sZeZdZdZgZejdZdZddZ ddZ dd Z d d Z d d Z ddZddZdS)FormulaCommandz A LaTeX command inside a formularmNcCs |tjS)zFind the current command.)rrFr:rrrrrPrzFormulaCommand.detectcCs|||}|||}|r|S|ds|dr#|||}|r#|S|jjs.td|t d|_ | t |dS)zParse the command.\up\UpzUnknown command rN) extractcommandparsewithcommandr parseupgreekrrrrrJrNrrrV)r{rrmr@upgreekrrrrQs   zFormulaCommand.parsebitcCs,tjD]}||jvr||||SqdS)z0Parse the command type once we have the command.N)rFr commandmapparsecommandtype)r{rmrrrrrrJs  zFormulaCommand.parsewithcommandcCs,|j|}||||}|r|S|S)zParse a given command type.)rr setcommandrQ)r{rmrrr@returnedrrrrNs   zFormulaCommand.parsecommandtypecCsh|tjs|dtjdS|r||S|r-tj|}|d|Stj| S)z5Extract the command from elyxer.the current position.zMissing command start Nrj) rrFr:rrz emptycommandrrrr)r{rrmrrrrIs    zFormulaCommand.extractcommandcCs0d}|s|}|r||r|}tj|S)zqCheck for an empty command: look for command disguised as ending. Special case against '{ \{ \} }' situation.r+)rrrrFr:)r{rrmrrrrrQ s  zFormulaCommand.emptycommandcCst|dkrdS|drd|dd}n|dr,d|dd|dd}n td|dS|||}|r@d|_|S) zParse the Greek \up command..rNrGrrrHzImpossible upgreek command: rt)rrrupperrrrJr)r{rmr upcommandrLrrrrKs   " zFormulaCommand.parseupgreek)rrr r!rrrr:rMrPrQrJrNrIrQrKrrrrrFs   rFc@r) CommandBitz%A formula bit that includes a commandcCs0||_|jr|j|7_|j|j|_dSdS)zSet the command in the bitN)rmrMr translated)r{rmrrrrO's zCommandBit.setcommandcCs2|j||r dS|j|}|||S)z)Parse a parameter at the current positionN)rrrzrfr)r{r parameterrrrr.s   zCommandBit.parseparametercCs:|j||jt|sdS|jt|}|||S)zParse a square bracketN)rrrrjr'rr{rr6rrr parsesquare7s  zCommandBit.parsesquarecCsd|j||jt|s |std|dS|St |j}| | ||j S)zParse a literal bracket.zNo literal parameter found at: N) rrrr\rrrrrr>rrbrirWrrrrb@s zCommandBit.parseliteralcCsB|j||jt|sdSt|j}||||jS)z!Parse a square bracket literally.N)rrrrjr>rrbrirWrrrparsesquareliteralLs zCommandBit.parsesquareliteralcCsP|j||jt|std|jdSt|j|}| ||S)zParse a text parameter.zNo text parameter for N) rrrr\rrrmr>r`rrWrrrr`Us  zCommandBit.parsetextN) rrr r!rOrrXrbrYr`rrrrrT$s   rTc@eZdZdZejZddZdS)raz%An empty command (without parameters)cCst|jg|_dS)"Parse a command without parametersNrVrUrrrrrrQdrzEmptyCommand.parsebitN)rrr r!rrrMrQrrrrra_ rac@rZ) SpacedCommandzFind a function which is represented by a symbol (like _ or ^)cCs|tjvS)zFind the symbol)rrcrMrrrrrPrzSymbolFunction.detectcCs8||||jt|j|_||dS)rSN) rOrrrmrJrNrUrrrrrrrQs zSymbolFunction.parsebitN) rrr r!rrrMrPrQrrrrrc  rcc@ra)rdz-A function where parameters are read as text.cCst|j|_||dS)zParse a text parameterN)rJrNrUrr`rrrrrQszTextFunction.parsebitcCr)zSet the type to fontrtNrrrrrrr[zTextFunction.processN) rrr r!rrrMrQrrrrrrds  rdc@ra) LabelFunctionzA function that acts as a labelcCs|||_dS)zParse a literal parameterN)rbrrrrrrQrzLabelFunction.parsebitcCs8d|_tjd|jdd|_|jg|_|jtj|j<dS)z&Add an anchor with the label contents.rtreqnumberrN)rr}rrrArr:rrrrrs zLabelFunction.processN) rrr r!rrrMrQrrrrrrcrbrcc@rZ)rez1A function of one parameter that changes the fontcCsd|_|dS)z.Simplify if possible using a single character.rtN)rr_rrrrrr=zFontFunction.processN)rrr r!rrrMrrrrrrer]rec@s.eZdZdZejZddZddZddZ dS) BigSymbolzA big symbol generator.cCrs)zCreate the big symbol.N)rV)r{rVrrrr|r[zBigSymbol.__init__cCs0|j|jvr |jgS|r|jgS|j|jS)zGet an array with all pieces.)rVr smalllimitrrrr getpiecess  zBigSymbol.getpiecescCs(tjsdSt|j|jdkrdStjS)z7Decide if the limit should be a small, one-line symbol.Tr)rr#rrrVrrrrrrrfs zBigSymbol.smalllimitN) rrr r!rr|rr|rgrfrrrrres  rec@sReZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ dS) BigBracketzA big bracket generator.r<cCs6||_||_||_d|_|tjvrtj||_dSdS)z(Set the size and symbol for the bracket.N)r*r alignmentrrr{)r{r*r6rirrrr|s zBigBracket.__init__cCs t|dtt|j}||S)z%Return the nth piece for the bracket.getpiece)rrrr)r{rYfunctionrrrrjszBigBracket.getpiececCs |jdS)z1Return the only piece for a single-piece bracket.r)rr{rYrrr getpiece1r[zBigBracket.getpiece1cCs4|dkr |jdS||jdkr|jdS|jdS)zGGet the nth piece for a 3-piece bracket: parenthesis or square bracket.rrrrr*rlrrr getpiece3s    zBigBracket.getpiece3cCsP|dkr |jdS||jdkr|jdS||jddkr#|jdS|jdS)z7Get the nth piece for a 4-piece bracket: curly bracket.rrrrrnrlrrr getpiece4s    zBigBracket.getpiece4cCs&||}d|jd}t||S)z'Get the bracket piece as an array cell.zspan class="bracket align-rw)rjrirJr)r{rYrrrrrgetcells zBigBracket.getcellcCs\|jdks|js |Sg}t|jD]}||}|t|gdqt|dgS)z3Get the bracket as an array or as a single bracket.rspan class="arrayrow"span class="array")r*rgetsinglebracketrprqrrJr)r{rowsrYcellrrr getcontentss zBigBracket.getcontentscCs,|jdkr tddgSt|jdgS)z$Return the bracket as a single sign.r8r+zspan class="emptydot"r)rrJrrrrrrt(s zBigBracket.getsinglebracketN)r<) rrr r!r|rjrmrorprqrwrtrrrrrhs    rhc@eZdZdZdZddZdS)FormulaEquationzA simple numbered equation.equationcCs t|_||jt|dS)Parse the arrayN)rGrrrr'rrrrrrQ8zFormulaEquation.parsebitNrrr r!rrQrrrrry3 ryc@r4) FormulaCellzAn array cell inside a rowcCs"||_td|dd|_|S)Nzspan class="arraycell align-rwT)rirJrNr)r{rirrr setalignment@szFormulaCell.setalignmentcCs0|j||r dS||jt|dSrx)rrrzrr'rrrrrrQEs zFormulaCell.parsebitN)rrr r!rrQrrrrr=r8rc@s2eZdZdZejdZddZddZddZ d S) FormulaRowzAn array row inside an arrayrcCs||_tdd|_|S)NrrT) alignmentsrJrNr)r{rrrr setalignmentsPszFormulaRow.setalignmentscCstd}|j|jdd|s+||}|||||d7}||j|rt|jdkr8t |_ dSdS)zParse a whole rowrT)rrN) rrrz createcellrQrrrrrBr)r{rrYrvrrrrQUs     zFormulaRow.parsebitcCs&|j|t|j}|jt|S)z4Create the cell that corresponds to the given index.)rrrrrr)r{rYrirrrrbszFormulaRow.createcellN) rrr r!rrzrrrQrrrrrrKs   rc@r) MultiRowFormulazA formula with multiple rows.cCsPg|_d}||D]}|rd}n|||||q t|j|_dS)z,Parse all rows, finish when no more row endsTFN)ru iteraterowsaddemptyrQaddrowrr*)r{rrrowrrr parserowsjs  zMultiRowFormula.parserowsccsZtjd} ||d|jt}||jV||r*|j | |7_ ndSq)z0Iterate over all rows, end when no more row endsrTN) rrzrrrrrrrrr)r{rrrrrrrxs    zMultiRowFormula.iteraterowscCs^|jt|j}t|jdjD]\}}||}| t d| |q| |dS)zAdd an empty row.rrN) rrrrrrrurrrrVr)r{rrY originalcellrvrrrrs   zMultiRowFormula.addemptycCs|j|||dS)z2Add a row to the contents and to the list of rows.N)rurr)r{rrrrrs zMultiRowFormula.addrowN)rrr r!rrrrrrrrrgs  rc@s$eZdZdZdZddZddZdS) FormulaArrayzAn array within a formularzcCs(tdd|_||||dS)r{rsFN)rJrNrparsealignmentsrrrrrrQs zFormulaArray.parsebitcCsDd|_||}|r ||_||}g|_|D]}|j|qdS)zParse the different alignmentsr=N)valignrYrbrr)r{rrir<rrrrs  zFormulaArray.parsealignmentsN)rrr r!rrQrrrrrr  rc@rx) FormulaMatrixz'A matrix (array with center alignment).matrixcCs,tdd|_d|_dg|_||dS)z(Parse the matrix, set alignments to 'c'.rsFr=N)rJrNrrrrrrrrrQszFormulaMatrix.parsebitNr}rrrrrr~rc@rx) FormulaCaseszA cases statementcasescCst|_ddg|_|||jD]}|jD]}|jdd|jtdqqt |jdd}t t |jdd}| |g|_dS)zParse the casesr<zspan class="case align-l"Trzspan class="bracketcases"rN) rGrrrrrNrrVrJrrhrrw)r{rrrvrzbracerrrrQs    zFormulaCases.parsebitNr}rrrrrr~rc@r)EquationEnvironmentz;A \begin{}...\end equation environment with rows and cells.cCs\tdd|_|jdd}|tjvrtj||_n t d|jdg|_| |dS)zParse the whole environment.zspan class="environment"Frjr+zUnknown equation environment r<N) rJrNrrrrrrrrr)r{r environmentrrrrQs zEquationEnvironment.parsebitN)rrr r!rQrrrrrr&rc@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) rbfindbitrrzrrQrrrr*)r{rrmr@rrrrrQs      zBeginCommand.parsebitcCsDtjD]}|dd|jkr|j|Sq|jt}||_|S)z7Find the command bit corresponding to the \begin{piece}rjr+)rrrrrrr)r{rrr@rrrrs  zBeginCommand.findbitN)rrr r!rrzrMryrrrrrQrrrrrrs   rc@s"eZdZejZddZddZdS)rfcCspd|_|j}||}|std|jnt|dkr.td|jd|d|j t |dS)zParse a combining function.r0z'Empty parameter for combining function rzApplying combining function z to invalid string "rwN) rrUparsesingleparameterrrrmrrrrrU)r{r combiningrVrrrrQs  zCombiningFunction.parsebitcCsj|j||rtd|dS|jt|s#|jt|r(| |St | }| ||S)z&Parse a parameter, or a single letter.z(Error while parsing single parameter at N) rrrzrrrrr\rFrrVrr)r{rletterrrrrs     z&CombiningFunction.parsesingleparameterN)rrr rr~rMrQrrrrrrfs rfc@rZ)rgz*A function that decorates some bit of textcCsbd|_|j}t|d|_|||_td|_ |j d|jtd|j_ | dS)zParse a decorating functionr0zspan class="symbolover"zspan class="withsymbol"rzspan class="undersymbol"N) rrUrJrrVrrVrJrNrrrr_)r{rrVrrrrQs  zDecoratingFunction.parsebitN)rrr r!rrrMrQrrrrrgr]rgc@rZ) LimitCommandz@A command which accepts limits above and below, in display mode.cCs@t|j}td|_|D] }|jt |dqdS)zParse a limit command.span class="limits"zspan class="limit"N) rerUrgrJrNrrrrJr)r{rrrrrrrQ&s zLimitCommand.parsebitN)rrr r!rrrMrQrrrrr!r]rc@s6eZdZdZdZddZddZejdkreZ dSdS)r\z(A command to limit the previous command.NcCstd|_|j|dS)z Do nothing.rN)rJrNrrrrrrrrQ2szLimitPreviousCommand.parsebitcCr?)rzLimit previous commandrrrrrr7r$z LimitPreviousCommand.__unicode__r) rrr r!rMrQrr rrrrrrr\-s r\c@r)LimitsProcessorz)A processor for limits inside an element.cCsVtjrdS|||r||||||r'|||dr)|||dSdSdS)z"Process the limits for an element.Nr)rr checklimits modifylimits checkscript modifyscriptsrlrrrrBs  zLimitsProcessor.processcCsNtjsdS|||dtr|||dSt||tsdS|||dS)z3Check if the current position has a limits command.Fr)rr# checkcommandr\ limitsaheadrrrrlrrrrKs zLimitsProcessor.checklimitscCs*||d||t||_dS)z,Limit the current element based on the next.rN)rrrBrrlrrrrVszLimitsProcessor.limitsaheadcCsf||}|||d}|j||||dr#|||d}ntdd}|jd|dS)zCModify a limits commands so that the limits appear above and below.rrzsup class="limit"rN)getlimitrrrrJrr)r{rrYlimitedrErFrrrr[s zLimitsProcessor.modifylimitscCs$|||}|jjdd|j_|S)z#Get the limit for a limits command.rPr) getscriptrrKr)r{rrYrrrrrfs zLimitsProcessor.getlimitcCs:|||}|||}t||gd}|||dS)z=Modify the super- and subscript to appear vertically aligned.zspan class="scripts"N)rrJrr)r{rrYrErFscriptsrrrrls  zLimitsProcessor.modifyscriptscCs|||tS)z6Check if the current element is a sub- or superscript.)rrcrlrrrrtrzLimitsProcessor.checkscriptcCst||krdSt|||S)z0Check for the given type as the current element.F)rr)r{rrYrrrrrxs zLimitsProcessor.checkcommandcCs"||}|jjd7_||=|S)zGet the sub- or superscript.z class="script"r)r{rrYr@rrrr~szLimitsProcessor.getscriptN) rrr r!rrrrrrrrrrrrrr?s    rc@ra)riz"A command which defines a bracket.cCst||dS)zParse the bracket.N)rbrQrrrrrQrzBracketCommand.parsebitcCs ||_d||_t|g|_|S)z+Create the bracket for the given character.r)rrmrVrr{r? characterrrrrs  zBracketCommand.createN) rrr r!rr}rMrQrrrrrrirbric@rc)BracketProcessorz!A processor for bracket commands.cCs&tjrdS|||r|||SdS)z6Convert the bracket using Unicode pieces, if possible.N)rr checkleft processleftrlrrrrs   zBracketProcessor.processcCsJ|||d}|s dS||||}||||||||dS)zProcess a left bracket.rN) findrightfindmaxresize)r{rrY rightindexr*rrrrs zBracketProcessor.processleftcC|||dS)z0Check if the command at the given index is left.rcheckdirectionrlrrrrrzBracketProcessor.checkleftcCr)z1Check if the command at the given index is right.rrrlrrr checkrightrzBracketProcessor.checkrightcCst|tsdS|j|kS)z6Check if the given bit is the desired bracket command.F)rrirm)r{r@rmrrrrrzBracketProcessor.checkdirectioncCs\d}|t|kr,|||r|d7}|||r|d8}|dkr"|S|d7}|t|ksdS)z9Find the right bracket starting at the given index, or 0.rrN)rrr)r{rrYdepthrrrrs    zBracketProcessor.findrightcCs|||}tdd|DS)z@Find the max size of the contents between the two given indices.cSrBrrCrDrrrrFrGz,BracketProcessor.findmax..)r)r{r leftindexrslicedrrrrs zBracketProcessor.findmaxcCs8|}|jdd}t|||}t|_||_dS)z+Resize a bracket command to the given size.rr+N)rrmrrhrGrrwr)r{rmr*rrir6rrrrs  zBracketProcessor.resizeN) rrr r!rrrrrrrrrrrrrs  rc@seZdZdZdZddZdS)r`zShows today's date.NcCs t|_tjdg|_dS)r[z %b %d, %YN)rCrdatetimertodaystrftimerrrrrrQr|zTodayCommand.parsebit)rrr r!rMrQrrrrr`r~r`c@sReZdZdZ ddgZddZddZdd Zd d Ze j d kr'eZ d Sd S)ParameterDefinitionz3The definition of a parameter in a hybrid function.)rr)rrcCs"d|_d|_d|_d|_d|_dS)NF)rrirr literalvaluerrrrr|s  zParameterDefinition.__init__cCstjD]E\}}||rH|dkrd|_|ds&td|ddS||_|dr3d|_ ||sDtd|dS|Sqtd |dS) z2Parse a parameter definition: [$0], {$x}, {$1!}...rTrz$Wrong parameter name, did you mean $?NruzWrong parameter closing z'Wrong character in parameter template: ) r parambracketsrrrrrrrri)r{ropeningclosingrrrr#s"      zParameterDefinition.parsecCsf|jr |jr |||_n|||_|jrt|j|_dSdS|jr+|||_dS|||_dS)z/Read the parameter itself using the definition.N) rirrYrrbrVrrXr)r{rrkrrrreads zParameterDefinition.readcCs2d|j}|jr|dt|j7}|S|d7}|S)rzparam rz (empty))rrrrrrrrs zParameterDefinition.__unicode__rN) rrr r!rr|r#rrr rrrrrrrs rc@s:eZdZdZ ddZddZddZdd Zd d Zd S) ParameterFunctionzFA function with a variable number of parameters defined in a template.cCs8t|_||D]}|||||jd|j<q dS)z*Read the params according to the template.rN)rparams paramdefsrrr{ readtemplaterparamdefrrr readparams's  zParameterFunction.readparamsccs8t|}|st|}|r|V|r dSdS)z*Read each param definition in the templateN)rrzrr#rrrrr.s zParameterFunction.paramdefscCr)zGet a parameter as parsed.N)rrrrrgetparam6rzParameterFunction.getparamcCs ||jS)zGet the value of a parameter.)rrrrrrr<rzParameterFunction.getvaluecCs||}|r |js dS|jS)z%Get the literal value of a parameter.N)rr)r{rrrrrgetliteralvalue@s  z!ParameterFunction.getliteralvalueN) rrr r!rrrrrrrrrr#s rc@VeZdZdZejZddZddZddZ 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)rUr writeparamsrcomputehybridsize)r{rr writetemplaterrrrQ[s     zHybridFunction.parsebitcCs|t|S)z*Write all params according to the template)writeposr)r{rrrrrcrzHybridFunction.writeparamscCsg}|sX|dr||}|r||n<|dr-||}|r,d|_||n'|dr<||ddn|drK||ddn |t||r|S)z/Write all params as read in the parse position.rfNrleftrright) rzr writeparamr writefunctionr writebracketrVr)r{rrrrkrrrrgs(        zHybridFunction.writeposcCs^d|}||jvrtd|dS|j|sdS|dr)||j|j_|j|jS)z*Write a single param of the form $0, $x...rzUnknown parameter Nr8)rrrrrrrr)r{rrrrrr|s     zHybridFunction.writeparamcCsz||}|s dS|drt|S|ds tddS|d||}|t |dkr6dSt ||S)z"Write a single function f0,...,fn.Nrrz Function should be defined in {}rr) readtagrrJrMrrrrrrr)r{rrKrrrrrs        zHybridFunction.writefunctioncCs|std|dSt|}d|t|jkr-tdt|ddS|jd|}d|vr:|S|j D]+}||vrh|j |}|j sYtd|d|d q=|j r`|j }nd }| ||}q=|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+) rrrrrrrrUrrrirr)r{rrYrKvariablerrrrrrs,     zHybridFunction.readtagcCs|jt||S)z4Return a new bracket looking at the given direction.)rrrirrrrrr^zHybridFunction.writebracketcCs>|jtjvr |dSt||_|jD]}|j|_qdS)z(Compute the size of the hybrid function.N)rm HybridSize configsizesrHgetsizer*rr7rrrrs   z HybridFunction.computehybridsizeN)rrr r!rrrMrQrrrrrrrrrrrrGs  rc@rZ)rz+The size associated with a hybrid function.cCsb|j|j}|jD]}||vr|j|j}||t|}q d|vr-td|dSt |S)z*Read the size for a function and parse it.rz%Unconverted variable in hybrid size: r) rrmrrrHrrrreval)r{rk sizestringrr*rrrrs  zHybridSize.getsizeN)rrr r!rrrrrrrrrr]rc@r) HeaderParserzParses the LyX headercs(gfddS)z?Parse header parameters into a dictionary, return the preamble.cr.rx) parselinerr/rrrrz$HeaderParser.parse..r3r"rr/rr#szHeaderParser.parsecCsz|}|tjdr||dS|tjdr#t|dS|tjdr6||j |dS| |dS)z0Parse a single line as a parameter or as a startrNrr) r rrr parsebranch LstParser parselstsetrrrr)r{r rrrrrrs  zHeaderParser.parselinecCsh|d}|ttjd}||t|}|jD] }| ||j|q!|t j |<dS)zParse all branch definitions.rrN) r rr rrrrr#rrrr)r{r r subparserrzrrrrrs  zHeaderParser.parsebranchcCrO)z*Complete the parser with the given ending.)r)r{rrrrrrQzHeaderParser.completeN)rrr r!r#rrrrrrrrs  rc@s$eZdZdZgZddZddZdS)PreambleParserzA parser for the LyX preamble.cs&tjd_fddgS)z,Parse the full preamble with all statements.rcs Srx)parsepreamblelinerr r{rrrrz&PreambleParser.parse..)rrrrr"rrrr# s zPreambleParser.parsecCstj||dS)zParse a single preamble line.N)rpreamblerr r r"rrrrrz PreambleParser.parsepreamblelineN)rrr r!rr#rrrrrrrrc@6eZdZdZeZddZddZddZdd Z d S) rz!Parse global and local lstparams.cCsN||}d|vrtd|dS|dd}|dd}||t_dS)z+Parse a declaration of lstparams in lstset.rz#Missing opening bracket in lstset: Nrr) extractlstsetrrrparselstparamsr globalparams)r{r r lefttext croppedtextrrrrs  zLstParser.parselstsetcCsDd}|s||7}||dr|S|rtddS)z%Extract the global lstset parameters.r+rz0Could not find end of \lstset settings; abortingN)rzr r rrr)r{r r rrrr&s  zLstParser.extractlstsetcCs,tj|_|d}|j||dS)z-Parse some lstparams from elyxer.a container. lstparamsN)rrrrr updater)r{r paramlistrrrr0s  zLstParser.parsecontainercCsTt}|D]"}d|vrt|dkrtd|q|dd\}}|||<q|S)z1Process a number of lstparams from elyxer.a list.rerzInvalid listing parameter r)rrrrrr)r{r paramdictrrrrrrr6s zLstParser.parselstparamsN) rrr r!rrrrrrrrrrrs  rc@r) 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) rBrparameternumberdefaultsrrparseparametersrr newcommandrmacrosrrrrrQJs zMacroDefinition.parsebitcCs^ |||_||}|rt||_||}|r'|j|||}|s|||_ dS)zDParse all optional parameters (number of parameters, default values)N) parsenewcommandrrYrrrXrrr definition)r{rrir6rrrrVs      zMacroDefinition.parseparameterscCsZ|j||jt|r||S|jt|r"|jt|St d| dS)z"Parse the name of the new command.z,Unknown formula bit in defining function at r&) rrrr\rbrFrrIrrrrrrrrfs  zMacroDefinition.parsenewcommandcCr)z Return an instance of the macro.)rrrrrrr4pr[zMacroDefinition.instantiateN) rrr r!rrrQrrr4rrrrr]Es  r]c@r4)MacroParameterz A parameter from elyxer.a macro.cCs |dS)zFind a macro parameter: #n.r)rrrrrrPwr[zMacroParameter.detectcCsV|ds tddSt||_dt|j|_t dt|jdg|_ dS)zParse the parameter: #n.rzMissing parameter start #.Nr) rrrrrrrrrJrrrrrrrQ{s   zMacroParameter.parsebitNrRrrrrrtrArc@r) MacroFunctionz*A function that was defined using a macro.cCs.t|_g|_|j}|||||dS)z#Parse a number of input parameters.N)rYrvaluesrUr completemacror{rmacrorrrrQs  zMacroFunction.parsebitcCsT||t|j|||jt|jt|j|jkr(tdt |dSdS)z'Parse as many parameters as are needed.zMissing parameters in macro N) parseoptionalrrparsemandatoryrrrrrrrrrrrs zMacroFunction.parseparameterscCsg}|jt|r!|||t|t|krn|jt|s |D]}|}t|jdkr7|j|q#|j|q#|j|7_dS)zParse optional parameters.rN) rrrjrrXrrrr)r{rrrrr'rrrrszMacroFunction.parseoptionalcCs8t|D]}||||}|sdS|j|qdS)z'Parse a number of mandatory parameters.N)rpparsemacroparameterrr)r{rrrYrVrrrrs zMacroFunction.parsemandatorycCs@ |j||rdS|jt|r|||S||S)z?Parse a macro parameter. Could be a bracket or a single letter.N)rrrzrr_ parsenumbersr)r{r remainingrrrrs   z!MacroFunction.parsemacroparametercCs^ |jt|}t|j|ks|S|jD]}|jt}|t|||_|j |qdS)z3Parse the remaining parameters as a running number.N) rr'r_rrrrrVrrr)r{rrrdigitrrrrrs  zMacroFunction.parsenumberscCs|g|_dgt|j}|tD]'}|jd}|t|jkr-tdt |dSd||<|j| g|_qt t|jD]}||sQ| ||j|qBdS)z,Complete the macro with the parameters read.Frz%Macro parameter index out of bounds: NT) r4rrrrrrrrrrrpr])r{rr:rVrYrrrrs  zMacroFunction.completemacrocCs6dt|d}d|jd}|j||dS)z@Add a filter for the given parameter number and parameter value.rrr+rN)rjoinrr=rr])r{rYrrrrrr]szMacroFunction.addfilterN)rrr r!r]rrMrQrrrrrrr]rrrrrs  rc@r)rz!A math macro defined in an inset.cCrrx)r;rrBrrrrrr|rzFormulaMacro.__init__cCr?)rz Math macrorrrrrrr$zFormulaMacro.__unicode__rNrrrrrrrmrcCs2t}||}t||d|S)zConvert some TeX math to HTML.r+)r~r-rnrrr=)r.rrrrr math2htmls   rcCsHtj}t|t|dkrtdtt|d}t |dS)z=Main function, called if invoked from elyxer.the command linerz"Usage: math2html.py escaped_stringrN) r argvrrrrrrrr )rrrrrmains    r __main__)rhrrioos.pathrr unicodedatar urllib.parserurllibrrrIOBasergobjectrr#r6r;rrrrrrrrrr,r/rRrwrrrrrr r'r-r0r1r5r9r:rBrCrGrJrYr`rdr~rrrrrrrrqrrTrUrXrr$r;r<rJrVr]rhr_rCrYr\rjrkrnr[rr~rrrrrrrrrrrrErMrSrCrOr?rRrFr=rZrrrr<rrrrQrr!rzrr"r(r)r}rrFrTrar^r`rbrcrdrcrerrerhryrrrrrrrrrfrgrr\rrirr`rrrrrrrrrr]rrrrr rrrrrsv   0D V #,D]-Q#     BD(vC;#> 6!h0   F 8o I6]n         </5@U;    B +  F; >$z *./X