o
    n§¥_{Ñ ã                   @   s¦
  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZejdkr(d dl	m
Z
 nd dlm
Z
 ejdkr:eZeZejZG dd„ deƒZG dd„ deƒZG dd	„ d	eƒZG d
d„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG d d!„ d!eƒZ G d"d#„ d#eƒZ!G d$d%„ d%eƒZ"G d&d'„ d'eƒZ#G d(d)„ d)eƒZ$G d*d+„ d+eƒZ%G d,d-„ d-eƒZ&G d.d/„ d/eƒZ'G d0d1„ d1e'ƒZ(G d2d3„ d3e'ƒZ)G d4d5„ d5e'ƒZ*G d6d7„ d7e*ƒZ+G d8d9„ d9e'ƒZ,G d:d;„ d;e'ƒZ-G d<d=„ d=e+ƒZ.G d>d?„ d?eƒZ/G d@dA„ dAe/ƒZ0G dBdC„ dCe/ƒZ1G dDdE„ dEe/ƒZ2G dFdG„ dGe2ƒZ3G dHdI„ dIe2ƒZ4G dJdK„ dKe/ƒZ5G dLdM„ dMeƒZ6G dNdO„ dOeƒZ7G dPdQ„ dQeƒZ8G dRdS„ dSeƒZ9G dTdU„ dUeƒZ:G dVdW„ dWe8ƒZ;G dXdY„ dYe;ƒZ<G dZd[„ d[e;ƒZ=G d\d]„ d]eƒZ>G d^d_„ d_e>ƒZ?G d`da„ dae?ƒZ@G dbdc„ dce>ƒZAG ddde„ deeAƒZBG dfdg„ dge>ƒZCG dhdi„ dieƒZDG djdk„ dke'ƒZEG dldm„ dmeEƒZFG dndo„ doe>ƒZGG dpdq„ dqeGƒZHG drds„ dseBƒZIG dtdu„ dueGƒZJG dvdw„ dweGƒZKG dxdy„ dyeGƒZLG dzd{„ d{eGƒZMG d|d}„ d}eGƒZNG d~d„ deGƒZOG d€d�„ d�eOƒZPG d‚dƒ„ dƒeƒZQG d„d…„ d…eƒZRG d†d‡„ d‡e>ƒZSG dˆd‰„ d‰eGƒZTG dŠd‹„ d‹eƒZUG dŒd�„ d�eƒZVeVƒ eV_WG dŽd�„ d�eƒZXG d�d‘„ d‘eXƒZYG d’d“„ d“eƒZZG d”d•„ d•eZƒZ[e[ƒ eZ_\eZƒ eZ_]G d–d—„ d—eƒZ^G d˜d™„ d™e>ƒZ_G dšd›„ d›e>ƒZ`G dœd�„ d�eCƒZaG dždŸ„ dŸeCƒZbG d d¡„ d¡eCƒZcG d¢d£„ d£eCƒZdG d¤d¥„ d¥eCƒZeG d¦d§„ d§eCƒZfG d¨d©„ d©eCƒZgG dªd«„ d«eCƒZhG d¬d­„ d­eCƒZiG d®d¯„ d¯eCƒZjG d°d±„ d±e?ƒZkG d²d³„ d³e>ƒZlG d´dµ„ dµe>ƒZmG d¶d·„ d·e>ƒZnG d¸d¹„ d¹e>ƒZoG dºd»„ d»eoƒZpG d¼d½„ d½e>ƒZqG d¾d¿„ d¿eCƒZrG dÀdÁ„ dÁe?ƒZsG dÂdÃ„ dÃe>ƒZtG dÄdÅ„ dÅetƒZuG dÆdÇ„ dÇeuƒZvG dÈdÉ„ dÉe/ƒZwG dÊdË„ dËeƒZxG dÌdÍ„ dÍeƒZyG dÎdÏ„ dÏetƒZzG dÐdÑ„ dÑetƒZ{G dÒdÓ„ dÓeGƒZ|G dÔdÕ„ dÕe|ƒZ}G dÖd×„ d×e}ƒZ~G dØdÙ„ dÙe}ƒZG dÚdÛ„ dÛe~ƒZ€G dÜdÝ„ dÝe}ƒZ�G dÞdß„ dße}ƒZ‚G dàdá„ dáe}ƒZƒG dâdã„ dãe}ƒZ„G dädå„ dåe�ƒZ…eU j†e|e‚g7  _†e€e~e�e…e„eƒege|_†G dædç„ dçeƒZ‡G dèdé„ dée‡ƒZˆG dêdë„ dëe}ƒZ‰G dìdí„ díe|ƒZŠG dîdï„ dïe|ƒZ‹G dðdñ„ dñe}ƒZŒG dòdó„ dóeŒƒZ�G dôdõ„ dõeŒƒZŽG död÷„ d÷eŒƒZ�G dødù„ dùeŒƒZ�G dúdû„ dûe}ƒZ‘e| j†e‘g7  _†G düdý„ dýe�ƒZ’G dþdÿ„ dÿe�ƒZ“G �d �d„ �de~ƒZ”G �d�d„ �de”ƒZ•G �d�d„ �deQƒZ–G �d�d„ �de�ƒZ—G �d�d	„ �d	eQƒZ˜G �d
�d„ �de~ƒZ™e| j†e“e’e”e—g7  _†eR jše–ƒ e˜ƒ g7  _šG �d�d„ �deƒZ›G �d�d„ �de}ƒZœG �d�d„ �deœƒZ�G �d�d„ �deƒZže| j†e�g7  _†G �d�d„ �de'ƒZŸG �d�d„ �de'ƒZ G �d�d„ �deƒZ¡G �d�d„ �de}ƒZ¢G �d�d„ �deGƒZ£G �d�d„ �de}ƒZ¤G �d �d!„ �d!eSƒZ¥eU j†e£g7  _†e| j†e¤g7  _†�d"�d#„ Z¦�d$�d%„ Z§e¨�d&k�rQe§ƒ  dS dS ('  é    N©é   r   )Ú
quote_plusc                   @   sp   e Zd ZdZdZdZdZdZdd„ Zdd„ Z	dd	„ Z
d
d„ Zdd„ ZeeƒZee	ƒZ	ee
ƒZ
eeƒZeeƒZdS )ÚTracezA tracing classFNc                 C   s"   t jrt jrdS t  |tj¡ dS )zShow a debug messageN)r   Ú	debugmodeÚ	quietmodeÚshowÚsysÚstdout©ÚclsÚmessage© r   ú?/usr/lib/python3/dist-packages/docutils/utils/math/math2html.pyÚdebug4   s   zTrace.debugc                 C   s2   t jrdS t jrt jrt j| }t  |tj¡ dS )zShow a trace messageN)r   r   ÚprefixÚshowlinesmoder   r	   r
   r   r   r   r   r   :   s
   
zTrace.messagec                 C   s0   d| }t jrt jrt j| }t  |tj¡ dS )zShow an error messagez* N)r   r   r   r   r	   Ústderrr   r   r   r   ÚerrorB   s   
zTrace.errorc                 C   s   t  d| ¡ tdƒ dS )z#Show an error message and terminatezFATAL: éÿÿÿÿN)r   r   Úexitr   r   r   r   ÚfatalI   s   zTrace.fatalc                 C   s&   t jdk r
| d¡}| |d ¡ dS )zShow a message out of a channelr   úutf-8Ú
N)r	   Úversion_infoÚencodeÚwrite)r   r   Úchannelr   r   r   r   N   s   

z
Trace.show)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r   Úclassmethodr   r   r   r   r   +   s     r   c                   @   sÔ   e Zd ZdZddddœZddddœZd	d
dd
dœZi 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#d$“d%d“Zd&d'd'd(œZd)d*d$d+dœZ	d,d-d.d/d$d0d1œZ
d2d3d$d4dœZd5S )6ÚBibStylesConfigú+Configuration class from elyxer.config filezy$authors. $title. <i>$journal</i>,{ {$volume:}$pages,} $month $year.{ doi: $doi.}{ URL <a href="$url">$url</a>.}{ $note.}z$surname($year)zS$authors. <i>$title</i>. $publisher, $year.{ URL <a href="$url">$url</a>.}{ $note.})ú@articleÚciteÚdefaultz˜$authors. $title.{ <i>$journal</i>{, {$volume}{($number)}}{: $pages}{, $year}.}{ <a href="$url">$url</a>.}{ <a href="$filename">$filename</a>.}{ $note.}z$Sur$YYzt$authors. $title.{ <i>$journal</i>,} $year.{ <a href="$url">$url</a>.}{ <a href="$filename">$filename</a>.}{ $note.}zr$authors. $year. $title. <i>$journal</i>, <b>$volume</b>($number), $pages.{ URL <a href="$url">$url</a>.}{ $note.}zS$authors. $year. <i>$title</i>. $publisher.{ URL <a href="$url">$url</a>.}{ $note.}z$surname, $year)r%   ú@bookr&   r'   r%   ue   $authors: â€œ$titleâ€�, <i>$journal</i>,{ pp. $pages,} $year.{ URL <a href="$url">$url</a>.}{ $note.}r(   zj{$authors: }<i>$title</i>{ ($editor, ed.)}.{{ $publisher,} $year.}{ URL <a href="$url">$url</a>.}{ $note.}z@bookletzW$authors: <i>$title</i>.{{ $publisher,} $year.}{ URL <a href="$url">$url</a>.}{ $note.}z@conferencez@inbookú@incollectionz$authors: <i>$title</i>{ in <i>$booktitle</i>{ ($editor, ed.)}}.{{ $publisher,} $year.}{ URL <a href="$url">$url</a>.}{ $note.}ú@inproceedingsug   $authors: â€œ$titleâ€�, <i>$booktitle</i>,{ pp. $pages,} $year.{ URL <a href="$url">$url</a>.}{ $note.}z@manualz@mastersthesisz@misczh$authors: <i>$title</i>.{{ $publisher,}{ $howpublished,} $year.}{ URL <a href="$url">$url</a>.}{ $note.}z
@phdthesisz@proceedingsz@techreportzG$authors: <i>$title</i>, $year.{ URL <a href="$url">$url</a>.}{ $note.}z@unpublisheduW   $authors: â€œ$titleâ€�, <i>$journal</i>, $year.{ URL <a href="$url">$url</a>.}{ $note.}r&   z$indexr'   z??Ú )ÚYYÚauthorsÚsurnameu~   $authors, â€œ$titleâ€�, <i>$journal</i>, vol. $volume, no. $number, pp. $pages, $year.{ URL <a href="$url">$url</a>.}{ $note.}zS$authors, <i>$title</i>. $publisher, $year.{ URL <a href="$url">$url</a>.}{ $note.}uF   $authors, â€œ$titleâ€�. $year.{ URL <a href="$url">$url</a>.}{ $note.}zv$authors. $title.{ <i>$journal</i>{, {$volume}{($number)}}{:$pages}{, $year}.}{ URL <a href="$url">$url</a>.}{ $note.}z\$authors. <i>$title</i>. $publisher,{ $month} $year.{ URL <a href="$url">$url</a>.}{ $note.}z~$authors. $title.{ In <i>$booktitle</i> {($editor, ed.)}.} $publisher,{ $month} $year.{ URL <a href="$url">$url</a>.}{ $note.}zy$authors. $title. { <i>$booktitle</i>{, {$volume}{($number)}}{:$pages}{, $year}.}{ URL <a href="$url">$url</a>.}{ $note.}zR{$authors. }$title.{{ $publisher,} $year.}{ URL <a href="$url">$url</a>.}{ $note.})r%   r(   r)   r*   r&   r'   zy$authors. $title. <i>$journal</i>, $year{;{<b>$volume</b>}{($number)}{:$pages}}.{ URL: <a href="$url">$url</a>.}{ $note.}zO$authors. $title. {$publisher, }$year.{ URL: <a href="$url">$url</a>.}{ $note.}z`$authors. $title; {$publisher, }$year.{ $howpublished.}{ URL: <a href="$url">$url</a>.}{ $note.}N)r   r   r    r!   ÚabbrvnatÚalphaÚauthordate2r'   ÚdefaulttagsÚieeetrÚplainÚ	vancouverr   r   r   r   r#   [   s†    ýýüÿþýüûúùø	÷
öõôóòñðÿüú

ür#   c                   @   s   e Zd ZdZdddœZdS )ÚBibTeXConfigr$   õ   â€”Ú.)ú--z..N)r   r   r    r!   Úreplacedr   r   r   r   r6   Ÿ   s    
ÿr6   c                
   @   s¶  e Zd ZdZi 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d“dd“d d!“d"d#d$œ¥Zg d%¢d&gg d'¢d(œZd)ddd*œZi d&d+“d,d-“d.d-“d/d“d0d1“d2d“d3d“dd“d4d-“d5d-“d6d-“d7d8“d9d-“d:d“d;d<“d=d>“d?d@“i dAdB“dCdD“dEdF“dGdH“dIdJ“dKdL“dMdN“dOdP“dQdR“dSdT“dUdV“dWdX“dYdZ“d[d\“d]d^“d_d`“dadb“¥i dcdb“ddde“dfdg“dhdi“djdk“dldm“dndo“dpdq“drds“dtdu“dvdD“dwdF“dxdH“dydH“dzdH“d{dH“d|dJ“¥i d}ds“d~dP“ddV“d€dX“d�dN“d‚dT“dƒdX“d„dZ“d…dJ“d†dX“d‡db“dˆd‰“dŠd‹“dŒd�“dŽd<“d�d�“d‘d’“¥i 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®d­“d¯d°“d±d²“¥i 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Ãd“d"dÄ“dÅd-“¥i 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Úd“dÛd-“dÜd-“¥dd-d-dd-dÝd-d dÞœ¥ZdßdàiZdádâdãgiZ	däS )åÚContainerConfigr$   ÚAlignz\end_layoutÚ
BarredTextú\barÚBoldTextz\seriesÚCellz</cellÚChangeDeletedz\change_unchangedÚChangeInsertedÚ	ColorTextú\colorÚEmphaticTextz\emphÚHfillú\hfillÚInsetz
\end_insetÚLayoutÚ	LyXFooterz\end_documentÚ	LyXHeaderz\end_headerÚRowz</rowÚ
ShapedTextú\shapeÚSizeTextú\sizeÚ	StrikeOutz
\strikeoutz\familyz\noun)Ú
TextFamilyÚVersalitasText)ÚStringContainerÚConstantÚFormulaConstantr+   )ÚPlainLayoutÚ
TaggedTextr<   ÚCaptionrR   rE   rS   r=   rO   rC   ÚLangLineÚFormulaÚBracketÚRawTextÚBibTagÚFormulaNumberÚAlphaCommandÚEmptyCommandÚOneParamFunctionÚSymbolFunctionÚTextFunctionÚFontFunctionÚCombiningFunctionÚDecoratingFunctionÚFormulaSymbolÚBracketCommandÚTeXCode©ÚallowedÚclonedÚ	extractedz\end_deeper)ú\begin_deeperz\begin_insetú\begin_layoutrT   z#LyXÚBlackBoxz</lyxtabularz<cellz<columnÚColumnz<rowz\alignz\bar defaultz\bar noz\begin_bodyro   Ú
DeeperListz\begin_documentz\begin_headerz\begin_inset ArgumentÚ
ShortTitlez\begin_inset BoxÚBoxInsetz\begin_inset BranchÚBranchz\begin_inset CaptionrY   z!\begin_inset CommandInset bibitemÚBiblioEntryz \begin_inset CommandInset bibtexÚBibTeXz"\begin_inset CommandInset citationÚBiblioCitationz\begin_inset CommandInset hrefÚURLz!\begin_inset CommandInset includeÚIncludeInsetz%\begin_inset CommandInset index_printÚ
PrintIndexz\begin_inset CommandInset labelÚLabelz\begin_inset CommandInset lineÚ	LineInsetz'\begin_inset CommandInset nomencl_printÚPrintNomenclaturez&\begin_inset CommandInset nomenclatureÚNomenclatureEntryz\begin_inset CommandInset refÚ	Referencez\begin_inset CommandInset tocÚTableOfContentsz\begin_inset ERTÚERTz\begin_inset FlexÚ	FlexInsetz\begin_inset Flex ChunkrefÚNewfangledChunkRefz\begin_inset Flex MarginnoteÚSideNotez\begin_inset Flex Sidenotez\begin_inset Flex URLÚFlexURLz\begin_inset FloatÚFloatz\begin_inset FloatListÚListOfz\begin_inset FootÚFootnotez\begin_inset Formular[   z\begin_inset FormulaMacroÚFormulaMacroz\begin_inset GraphicsÚImagez\begin_inset IndexÚIndexReferencez\begin_inset InfoÚ	InfoInsetz!\begin_inset LatexCommand bibitemz \begin_inset LatexCommand bibtexz\begin_inset LatexCommand citez!\begin_inset LatexCommand citealtz\begin_inset LatexCommand citepz\begin_inset LatexCommand citetz!\begin_inset LatexCommand htmlurlz\begin_inset LatexCommand indexz\begin_inset LatexCommand labelz&\begin_inset LatexCommand nomenclaturez#\begin_inset LatexCommand prettyrefz$\begin_inset LatexCommand printindexz+\begin_inset LatexCommand printnomenclaturez\begin_inset LatexCommand refz)\begin_inset LatexCommand tableofcontentsz\begin_inset LatexCommand urlz\begin_inset LatexCommand vrefz\begin_inset Marginalz\begin_inset NewlineÚNewlineInsetz\begin_inset NewpageÚNewPageInsetz\begin_inset NoteÚNotez\begin_inset OptArgz\begin_inset PhantomÚPhantomTextz\begin_inset QuotesÚQuoteContainerz\begin_inset TabularÚTablez\begin_inset TextÚ	InsetTextz\begin_inset VSpaceÚVerticalSpacez\begin_inset WrapÚWrapz\begin_inset listingsÚListingz\begin_inset scriptÚScriptInsetz\begin_inset spaceÚSpacerp   z\begin_layout AbstractÚAbstractz\begin_layout AuthorÚAuthorz\begin_layout BibliographyÚBibliographyz\begin_layout ChunkÚNewfangledChunkz\begin_layout DescriptionÚDescriptionz\begin_layout EnumerateÚListItemz\begin_layout Itemizez\begin_layout ListÚListz\begin_layout LyX-CodeÚLyXCodez\begin_layout PlainrW   z\begin_layout StandardÚStandardLayoutz\begin_layout TitleÚTitleú\begin_preambleÚLyXPreamblez\change_deletedz\change_insertedz\color inheritz\color nonez\emph defaultz	\emph offz\emph onz\emph togglez	\end_bodyrR   z\family defaultz\family romanz\labelwidthstringú\langrZ   z\lengthÚInsetLengthz
\lyxformatÚ	LyXFormatz\lyxlineÚLyXLineú\newlineÚNewlinez\newpageÚNewPageú	\noindentz\noun defaultz	\noun offz\noun onrS   z\paragraph_spacingz\series boldz\series defaultz\series mediumÚStartAppendix)rN   z\shape defaultz	\shape uprP   z\size normalz\start_of_appendixz\strikeout defaultz\strikeout onÚstartcommandú\Úheadersz<lyxtabularz	<featuresN)
r   r   r    r!   ÚendingsÚextracttextÚstartendingsÚstartsÚstringÚtabler   r   r   r   r;   ¦   sL   ÿÿþþýüüûûûúúùùùøø	÷ýþÿÿÿþþþýýüüûûúúùøø	÷
öõôóòñðïîíìëêêéèçææååäãâá à!ß"Þ#Ý$Ü%Û&Ú'Ù(Ø)×*Ö+Õ,Ô-Ó.Ò/Ñ0Ð1Ï2Î3Í4Ì4Ì5Ë6Ê7É8È8È9Ç9Ç:Æ;Å;Å<Ä<Ä=Ã>Â?Á@ÀA¿B¾B¾C½D¼E»FºFºG¹H¸I·I·J¶J¶KµKµL´L´M³M³N²N²O±O±P°P°Q¯Q¯R®R®S­S­T¬T¬U«U«VªVªW¦^ÿÿr;   c                   @   sd   e Zd ZdZddddddœZddddd	d
ddddddœZddddœZddiZddddœZddiZ	dS )ÚEscapeConfigr$   r+   u    â€” õ   â€™õ   â€˜)r   z -- 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&amp;z&lt;ú&gt;)ú&ú<ú>ú/>rÇ   z&nbsp;z&emsp;z&#8197;)r¾   õ   â€ƒõ   â�ŸrÊ   õ   â€…N)
r   r   r    r!   ÚcharsÚcommandsÚentitiesÚhtmlÚ	iso885915Ú
nonunicoder   r   r   r   r¹   %  s&    
ÿú
ÿÿÿÿr¹   c                   @   s”&  e Zd ZdZi 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d“d d!“d"d#“i d$d%“d&d'“d(d)“d*d+“d,d-“d.d'“d/d0“d1d2“d3d2“d4d5“d6d7“d8d7“d9d:“d;d<“d=d>“d?d@“dAdB“¥i dCdD“dEdF“dGdH“dIdJ“dKdL“dMdN“dOdP“dQdR“dSdT“dUdV“dWdX“dYdZ“d[d\“d]d^“d_d`“dadb“dcdd“¥i dedf“dgdh“didj“dkdl“dmdn“dodp“dqdr“dsdt“dudv“dwdx“dydz“d{d|“d}d~“dd€“d�d‚“dƒdL“d„d…“¥d†d‡dˆd‰dŠd‹œ¥ZdŒd�dŽd�d�œZg d‘¢g d’¢g d“¢g d”¢g d•¢d–gg d—¢d˜gd™œZdšd›gdœd�gdžœZdŸd dŸdŸd¡d¢œZi 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»d¼“d½d¾“d¿dÀ“d¼dÁdÂdÃdÄd³dÀdÄdÅœ¥Z	i 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ádâ“dãdä“dådæ“i 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�d“�d�d“�d�d“¥i �d	�d
“�d�d“�d�d“�d�d“�d�d“�d�d“�d�d“�ddj“�d�d“�d�d“�d�d“�d�d“�d �d!“�d"dl“�d#�d$“�d%�d&“�d'�d(“¥i �d)�d*“�d+�d,“�d-�d.“�d/�d0“�d1�d2“�d3�d4“�d5�d6“�d7dn“�d8�d9“�d:dp“�d;dr“�d<�d=“�d>dt“�d?�d@“�dA�dB“�dC�dD“�dE�dF“¥i �dG�dH“�dI�dJ“�dK�dL“�dM�dN“�dO�dP“�dQ�dR“�dSdv“�dT�dU“�dV�dW“�dX�dY“�dZ�d[“�d\dx“�d]�d^“�d_�d`“�dadz“�db�dc“�ddd˜“¥i �de�df“�dg�dh“�did|“�dj�dk“d��dl“�dm�dn“�do�dp“�dq�dr“�ds�dt“�du�dv“�dw�dx“�dy�dz“�d{�d|“�d}�d~“�d�d€“�d��d‚“�dƒ�d„“¥i �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 �d¡“�d¢�d£“�d¤�d¥“¥i �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Â�dB“�dÃ�dÄ“�dÅ�dÆ“¥i �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ã�dä“�då�dœ“�dæ�dç“¥i �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�d“�d�d“�d�d	“¥i �d
�d“�d�d“�d�d“�d�d“�d�d“�d�d“�d�dr“�d�d“�d�d“�d�d“�d�d“�d�d “�d!�d"“�d#�dŸ“�d$�d%“�d&�d'“�d(�d)“¥i �d*�d+“�d,�d-“�d.�d-“�d/�d0“�d1�d2“�d3�d4“�d5�d6“�d7�d6“�d8�d9“�d:�d;“�d<�d=“�d>�d?“�d@�dA“�dB�dC“�dD�d“�dE�dF“�dG�dH“¥i �dI�dJ“�dK�dL“�dM�dN“�dO�dP“�dQ�dR“�dS�dT“�dU�dV“�dW�dX“�dY�dZ“�d[�d\“�d]�d^“�d_�d`“�da�db“�dc�dd“�de�df“�dg�dh“�di�dj“¥i �dk�dl“�dm�dn“�do�dp“�dq�d“�dr�ds“�dt�du“�dv�dw“�dx�dy“�dz�d{“�d|�d}“�d~�d“�d€�d�“�d‚�dƒ“�d„�d…“�d†�d‡“�dˆ�d‰“�dŠ�d‹“¥i �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§�d¨“�d©�dª“�d«�d¬“¥i �d­�d®“�d¯�d°“�d±�d²“�d³�d´“�dµ�dª“�d¶�d·“�d¸�d¹“�dº�d»“d3d2“�d¼�d½“�d¾�d¿“�dÀ�dÁ“�dÂ�dÃ“�dÄ�dÅ“�dÆ�dÇ“d8d7“�dÈ�dÉ“¥i �dÊ�dË“�dÌ�d³“�dÍ�dÎ“�dÏ�dÐ“�dÑ�dÒ“�dÓ�dÔ“�dÕ�dÖ“�d×�dÖ“�dØ�dÙ“�dÚ�dÛ“�dÜ�dV“�dÝ�dÞ“�dß�d�“�dà�dá“�dâ�dã“�dä�då“�dæ�dç“¥i �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�d“�d�d“�d�d“¥i �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%�d&“�d'�d(“�d)�d*“¥i �d+�d,“�d-�d.“�d/�d0“�d1�d2“�d3�d4“�d5�d6“�d7�d±“�d8�d9“�d:�d;“�d<�d=“�d>dÉ“�d?�d@“�dA�dB“�dC�dD“�dE�dF“�dG�dH“�dI�dJ“¥i �dK�dL“�dM�dN“�dO�dP“�dQ�dR“�dS�dT“�dU�dV“�dW�dX“�dY�dZ“�d[�d\“�d]�d^“�d_�d`“�da�db“�dc�dd“�de�df“�dg�dh“�di�dj“�dk�dl“¥i �dm�dn“�do�dp“�dq�d&“�dr�d&“�ds�dt“�du�dv“�dw�dl“�dx�dy“�dz�d{“�d|�d}“�d~�d“�d€�d�“�d‚�d�“�dƒ�d„“�d…�d†“�d‡�dˆ“�d‰�dŠ“¥i �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¢�d£“�d¤�d¥“�d¦�d§“¥i �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Ã�d“�dÄ�dÅ“�dÆ�dÇ“¥i �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ß�dà“�dá�dâ“�dã�dä“¥i �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ÿ�d “�d�d“�d�d“¥i �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�d“�d �d!“�d"�d#“¥i �d$�d%“�d&�d'“�d(�d)“�d*�d+“�d,�d-“�d.�d/“�d0�d1“�d2�d3“�d4�d5“�d6�d7“�d8�d9“�d:�d;“�d<�d=“�d>�d?“�d@�dA“�dB�dC“�dD�dE“¥i �dF�dG“�dH�dI“�dJ�dK“�dL�dM“�dN�dO“�dP�dQ“�dR�dC“�dS�dT“�dU�dV“�dW�dX“�dY�dZ“�d[�d\“�d]�d^“�d_�d`“�da�db“�dcdÉ“�dd�de“¥i �df�dg“�dh�di“�dj�dk“�dl�d§“�dm�dn“�do�dp“�dq�dr“�ds�dt“�dudê“�dv�dw“�dx�dy“�dz�d{“�d|�d}“�d~�d“�d€�d�“�d‚�dƒ“�d„�dƒ“¥i �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Ÿ�dH“�d �di“�d¡�d�“�d¢�d£“¥i �d¤�d¥“�d¦�dV“�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»�dR“�d¼�d½“�d¾�d¿“¥i �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Ù�dÚ“�dÛ�dÊ“�dÜ�dÐ“¥i �dÝ�dÐ“�dÞ�dß“�dà�dá“�dâ�dã“�dä�då“�dæ�d¯“�dç�dè“�dé�dê“�dë�dì“�dí�dZ“�dî�dï“�dð�dF“�dñ�d¬“�dò�dj“�dó�dô“�dõ�dö“�d÷�dø“¥i �dù�d±“�dú�d±“�dû�dü“�dý�dV“�dþ�dÿ“�d �d“�d�d“�d�d³“�d�d³“�d�d“�d�d	“�d
�d“�d�d“�d�dÖ“�dd˜“�d�d“¥Z
i Z�d,�d2�dH�dœZ�d�d�d�d�d�dœZ�d�dgg �d¢�d�dg�dœZi �d�d“�d�d“�d�d“�d�d “�d!�d"“�d#�d$“�d%�d&“�d'�d(“�d)�d*“�d+�d,“�d-�d.“�d/�d0“�d1�d2“�d3�d4“�d5�d6“�d7�d8“�d9�d:“i �d;�d<“�d=�d>“�d?�d@“�dA�dB“�dC�dD“�dE�d“�dF�dG“�dH�dI“�dJ�dK“�dL�dM“�dN�dO“�dP�dQ“�dR�dS“�dT�dU“�dV�dW“�dX�dY“�dZ�d[“¥i �d\�d]“�d^�d_“�d`�d“�da�dJ“�db�dc“�dd�de“�dfd“�dg�dh“�did“�dj�dk“�dl�dm“�dn�do“�dp�dq“�dr�dG“�ds�dI“�dt�dK“�du�dM“¥�dO�dQ�dS�dU�dW�dv�dw�dxœ¥Zi �dyg �dz¢“�d{g �d|¢“�d}g �d~¢“�dg �d€¢“�d�g �d‚¢“�dƒg �d„¢“�d…g �d†¢“�d‡g �dˆ¢“�d‰g �dŠ¢“�d‹g �dŒ¢“�d�g �dŽ¢“�d�g �d�¢“�d‘g �d�¢“�d’g �d“¢“�d”g �d•¢“�d–g �d•¢“�d—g �d˜¢“i �d™g �dš¢“�d›g �dœ¢“�d�g �d~¢“�džg �dŸ¢“�d g �d¡¢“�d¢g �d£¢“�d¤g �d~¢“�d¥g �d|¢“�d¦g �d•¢“�d§g �d¨¢“�d©g �dª¢“�d«g �d¬¢“�d­�d®dÉg“�d¯g �d°¢“�d±g �d²¢“�d³g �d´¢“�dµg �d¶¢“¥g �d·¢g �dŠ¢g �d†¢g �d¸¢g �d•¢g �d¹¢g �dº¢g �d»¢g �d¼¢g �d½¢�d¾œ
¥Z�d¿�d¿�dÀ�d¿�d¿�dÀ�dÁœZ�dÂ�dÃiZi �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Þ�dß“�dà�dá“�dâ�dã“Z�dä�då�då�dæ�dç�dç�dè�déœZdÉdÉdÉ�dê�d¸�dë�dì�dí�dî�dï�dð�dñ�dòdÉdÉ�dóœZi �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�d“�d�d“�d�d“�d�di¥Zi �d�d“�d�dR“�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/“�d0�d1“i �d2�d3“�d4�d5“�d6�d7“�d8�d9“�d:�d;“�d<�d=“�d>�d?“�d@�d“�dA�dB“�dC�dD“�dE�dF“�dG�dH“�dI�d“�dJ�dK“�dL�dM“�dN�dO“�dP�dQ“¥i �dR�dS“�dT�dU“�dV�dW“�dX�dY“�dZ�d[“�d\�d]“�d^�d_“�d`�da“�db�dc“�dd�de“�df�dg“�dh�di“�dj�dk“�dl�dm“�dn�do“�dp�dq“�dr�ds“¥i �dt�d“�dudþ“�dv�dw“�dx�dy“�dz�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‹“¥i �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¬�d­“�d®�d¯“�d°�d±“¥i �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Í�d”“�dÎ�d”“�dÏ�d{“¥i �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è�dé“�dê�dó“�dë�dì“¥i �dí�d“�dî�dï“�dð�dñ“�dò�dó“�dô�dõ“�dö�dÞ“�d÷�dø“�dù�di“�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œ	¥Z�d�d�dÖ�d�dÏ�ddÍ�dÙ�d�dœ	Z�dŒ�d�dœZ�d�d�d�d�de�d�d�d�d�de�dw�d �d!œZ�d"g �d#¢iZ�d$�d%iZ�d&S ('  ÚFormulaConfigr$   z\AAõ   Ã…z\AEõ   Ã†z\AmSz#<span class="versalitas">AmS</span>z
\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\beginrÅ   z\endz\\)ÚbeginÚcellseparatorÚendÚrowseparator)u   âŽ›u   âŽœu   âŽ�)u   âŽžu   âŽŸu   âŽ )u   âŽ¡u   âŽ¢u   âŽ£)u   âŽ¤u   âŽ¥u   âŽ¦)u   âŽ§õ   âŽªu   âŽ¨u   âŽ©ú|)u   âŽ«rã   u   âŽ¬u   âŽ­õ   âˆ¥)ú(ú)ú[ú]ú{rä   ú}rå   u   âŽ²u   âŽ³u   âŒ u   âŒ¡)õ   âˆ‘õ   âˆ«úspan class="symbol"z<span class="leftdot"></span>z<span class="rightdot"></span>)ú\leftz\left.z\middleú\rightz\right.z\"u   Ìˆz\'u   Ì�z\^u   Ì‚z\`u   Ì€z\acuter>   u   Ì„z\breveu   Ì†z\cu   Ì§z\checku   ÌŒz\dddotu   âƒ›z\ddotz\dotu   Ì‡z\gravez\hatz	\mathringu   ÌŠú\overleftarrowu   âƒ–ú\overrightarrowu   âƒ—u   Ì©u   âƒ�u   Ì¥u   Ìƒ)z\rz\sz\textcircledz\textsubringz\tildez\vz\vecz\~z\ r¾   z\!r+   z\#ú#z\$ú$z\%ú%z\&z\,ú z\:rÊ   z\;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\PrÚPrz\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<br/>z\_Ú_z\alephu   â„µz\amalgu   âˆ�z\anchoru   âš“z\angleu   âˆ z	\aquariusu   â™’z\arccosÚarccosz\arcsinÚarcsinz\arctanÚarctanz\argÚargz\ariesu   â™ˆz\arrowbulletu   âž¢z\astu   âˆ—z\asympu   â‰�z\backepsilonu   âˆ�z
\backprimeu   â€µz
\backsimequ   â‹�rÃ   r±   z\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\cosÚcosz\coshÚcoshz\cotÚcotz\cothÚcothz\cscÚcscz\cupz	\curlyveeu   â‹Žz\curlywedgeu   â‹�z\curvearrowleftu   â†¶z\curvearrowrightu   â†·z\dagõ   â€ z\daggerz\dalethu   â„¸z\dashleftarrowu   â‡ z\dashvu   âŠ£z\ddagõ   â€¡z\ddaggerz\ddotsu   â‹±z\degÚdegz\detÚdetz	\diagdownu   â•²z\diagupu   â•±z	\diameteru   âŒ€z\diamondz\diamondsuitu   â™¦z\dimÚdimz\divõ   Ã·z\divideontimesu   â‹‡z\dotdivu   âˆ¸z\dotequ   â‰�z	\doteqdotu   â‰‘z\dotplusu   âˆ”z\dotsrÀ   z\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\expÚexpz\fallingdotsequ   â‰’z\fcmpu   â¨¾z\femaleu   â™€z\flatu   â™­z\forallu   âˆ€z\fourthu   â�—z\frownu   âŒ¢z\frownieu   â˜¹z\gcdÚgcdz\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   ú<span class="hfill"> </span>z\homÚhomz\hookleftarrowu   â†©z\hookrightarrowu   â†ªz\hslashz	\idotsintu(   <span class="bigsymbol">âˆ«â‹¯âˆ«</span>z\iiintu"   <span class="bigsymbol">âˆ­</span>z\iintu"   <span class="bigsymbol">âˆ¬</span>z\infÚinfz\inftyu   âˆžz	\intercalu   âŠºz\interleaveu   â«´z\invampu   â…‹z\invnegu   âŒ�z\jupiteru   â™ƒz\kerÚkerz\landz
\landupintu"   <span class="bigsymbol">âˆ±</span>r§   u   âŸªz\langleu   âŸ¨z\lblotu   â¦‰z\lbracerê   z\lbrace)z\lbrackrè   z\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\lgÚlgz\lgroupu   âŸ®z\lhdu   âŠ²z\librau   â™Žz
\lightningu   â†¯z\limgu   â¦‡z\liminfÚliminfz\limsupÚlimsupz\llu   â‰ªz
\llbracketu   âŸ¦z	\llcorneru   âŒžz\lllu   â‹˜z\lnÚlnz\lneqqu   â‰¨z\lnotõ   Â¬z\lnsimu   â‹¦z\logÚlogz\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\maxÚmaxz\measuredangleu   âˆ¡z
\medbulletu   âš«z\medcircu   âšªz\mercuryu   â˜¿z\mhou   â„§z\midu   âˆ£z\minÚminz\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   â‰¢r«   z\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\not<z\not=u   â‰ z\not>z\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"   <span class="bigsymbol">âˆ°</span>z\oiintu"   <span class="bigsymbol">âˆ¯</span>z\ointu"   <span class="bigsymbol">âˆ®</span>z\ointclockwiseu"   <span class="bigsymbol">âˆ²</span>z\ointctrclockwiseu"   <span class="bigsymbol">âˆ³</span>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\rbracerë   z\rbrace)z\rbrackré   z\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\secÚsecz\secondu   â€³z	\setminusu   âˆ–z\sharpu   â™¯z\simequ   â‰ƒz\sinÚsinz\sinhÚsinhz\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\supÚsupz
\supseteqqu   â«†z\supsetneqqu   â«Œz\surdu   âˆšz\swarrowu   â†™z\swordsu   âš”z\talloblongu   â«¾z\tanÚtanz\tanhÚtanhz\taurusu   â™‰z\textasciicircumz\textasciitildez\textbackslashz\textcopyrightu   Â©'z\textdegreeõ   Â°z\textellipsisz\textemdashr7   z\textendashz	\texteuroz\textgreaterrÇ   z	\textlessrÆ   z\textordfeminineõ   Âªz\textordmasculineõ   Âºz\textquotedblleftõ   â€œz\textquotedblrightõ   â€�z\textquoterightrº   z\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\})rñ   rò   z\widehatú\]z\end{)ÚbracketÚcomplexÚendafterÚ	endbeforeÚsquarebracketÚrÚl)r;  Úcr<  )ÚalignÚeqnarrayÚgatheredz\boldsymbolÚbz\mathbbzspan 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\mathcalzspan 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	\mathfrakzspan 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\mathitÚiz\mathring{A}z\mathring{U}u   Å®z\mathring{a}z\mathring{u}u   Å¯z\mathring{w}u   áº˜z\mathring{y}u   áº™z\mathrmzspan class="mathrm"z\mathscrz\mathscr{B}z\mathscr{E}z\mathscr{F}zspan 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!}rD  rE  z\backmatter)r+   rD  rE  ú\binom)ú{$1}{$2}zf2{(}f0{f1{$1}f1{$2}}f2{)}zspan class="binom"zspan class="binomstack"úspan class="bigsymbol"z\boxed)ú{$1}úf0{$1}zspan class="boxed"ú\cfrac)z[$p!]{$1}{$2}ú!f0{f3{(}f1{$1}f3{)/(}f2{$2}f3{)}}úspan class="fullfraction"zspan class="numerator align-$p"úspan class="denominator"úspan class="ignored"rD   )ú	{$p!}{$1}rJ  zspan style="color: $p;"z	\colorbox)rP  rJ  z-span class="colorbox" style="background: $p;"ú\dbinom)rG  u%   (f0{f1{f2{$1}}f1{f2{â€…}}f1{f2{$2}}})zspan class="binomial"zspan class="binomrow"zspan class="binomcell"ú\dfrac)rG  rL  rM  úspan class="numerator"rN  rO  z\displaystyle)rI  rJ  zspan class="displaystyle"z
\fancyfoot)z
[$p!]{$q!}rD  rE  z
\fancyheadz\fbox)rI  rJ  zspan class="fbox"z	\fboxrule)ú{$p!}rD  rE  z\fboxsepz
\fcolorbox)z{$p!}{$q!}{$1}rJ  z<span class="boxed" style="border-color: $p; background: $q;"ú\frac)rG  rL  úspan class="fraction"rS  rN  rO  z	\framebox)z[$p!][$q!]{$1}rJ  z1span class="framebox align-$q" style="width: $p;"z\frontmatterz\href)z[$o]{$u!}{$t!}zf0{$t}úa href="$u"z\hspace)rT  úf0{ }z&span class="hspace" style="width: $p;"z	\leftroot)rT  rX  z*span class="leftroot" style="width: $p;px"z\mainmatterz	\markbothz
\markrightz	\nicefrac)rG  u   f0{f1{$1}â�„f2{$2}}rV  zsup class="numerator"zsub class="denominator"rO  z\parbox)z[$p!]{$w!}{$1}zf0{1}z$div class="Boxed" style="width: $w;"z	\raisebox)rP  zf0{$1.font}z1span class="raisebox" style="vertical-align: $p;"z\renewenvironmentz{$1!}{$2!}{$3!}z\rule)z[$v!]{$w!}{$h!}zf0/z.hr class="line" style="width: $w; height: $h;"z\scriptscriptstyle)rI  rJ  zspan class="scriptscriptstyle"z\scriptstyle)rI  rJ  zspan class="scriptstyle"z\sqrt)ú[$0]{$1}u!   f0{f1{$0}f2{âˆš}f4{(}f3{$1}f4{)}}zspan class="sqrt"zsup class="root"zspan class="radical"zspan class="root"rO  )rG  zf0{f1{$1}f2{$2}}zspan class="stackrel"zspan class="upstackrel"zspan class="downstackrel")rI  rJ  zspan class="textstyle")rY  z$0f0{$1.font}zspan class="unit")z[$0]{$1}{$2}u   $0f0{f1{$1.font}â�„f2{$2.font}}rV  zsup class="unit"zsub class="unit")rT  rX  z(span class="uproot" style="width: $p;px")z{$u!}zf0{$u}rW  )rT  rX  z'span class="vspace" style="height: $p;")
z	\stackrelú\tbinomz
\textcolorz
\textstylez\thispagestylez\unitz	\unitfracz\uprootz\urlz\vspacez$1+$2z$1+$2+1)rF  rK  rQ  rR  rU  rZ  z\labelz
a name="#"z\biginterleaveu   â«¼z	\bigsqcapu   â¨…z\fintu   â¨�z\iiiintu   â¨Œz\intrí   z\intopz\limÚlimz\produ   âˆ�z	\smallintz\sqintu   â¨–z\sumrì   z\varointclockwiseu   âˆ²z\varprodu   â¨‰z\zcmpu   â¨Ÿz\zhideu   â§¹z\zpipeu   â¨ z	\zprojectu   â¨¡ÚLimitPreviousCommandÚMacroDefinitionÚSetCounterFunctionÚ
FormulaTagÚTodayCommand)z\limitsz\newcommandz\renewcommandz\setcounterz\tagz\tag*z\todayú	u   â�Ÿ+â�Ÿu   ,â�Ÿu	   â�Ÿâˆ’â�Ÿu	   â�Ÿâ�„â�Ÿz : u
   â�Ÿ&lt;â�Ÿu   â�Ÿ=â�Ÿu
   â�Ÿ&gt;â�Ÿ)r   rö   rô   rÅ   r¼   ú+ú,rÁ   rÂ   ú:rÆ   ú=rÇ   ú@r(  z\BigrH  z\Biggzspan class="hugesymbol"zspan class="bar"z\begin{array}zspan class="arraydef"z\bigz\biggzspan class="largesymbol"z\biglz\bigrz
\centeringzspan class="align-center"z\ensuremathzspan class="ensuremath"z	\hphantomzspan class="phantom"r®   zspan class="noindent"z
\overbracezspan class="overbrace"z	\overlinezspan class="overline"z\phantomz\underbracezspan class="underbrace"z
\underlineÚuz	\vphantomz\Botu   â««z\Doteqz\DownArrowBaru   â¤“z\DownLeftTeeVectoru   â¥žz\DownLeftVectorBaru   â¥–z\DownRightTeeVectoru   â¥Ÿz\DownRightVectorBaru   â¥—z\Equalu   â©µz\LeftArrowBarz\LeftDownTeeVectoru   â¥¡z\LeftDownVectorBaru   â¥™z\LeftTeeVectoru   â¥šz\LeftTriangleBaru   â§�z\LeftUpTeeVectoru   â¥ z\LeftUpVectorBaru   â¥˜z\LeftVectorBaru   â¥’z\Leftrightarrowu   â‡”z\Longmapsfromu   âŸ½z\Longmapstou   âŸ¾z	\MapsDownu   â†§z\MapsUpu   â†¥z\Nearrowu   â‡—z\NestedGreaterGreateru   âª¢z\NestedLessLessu   âª¡z\NotGreaterLessz\NotGreaterTildeu   â‰µz\NotLessTildeu   â‰´z\Nwarrowu   â‡–z\Proportionu   âˆ·z\RightArrowBarz\RightDownTeeVectoru   â¥�z\RightDownVectorBaru   â¥•z\RightTeeVectoru   â¥›z\RightTriangleBaru   â§�z\RightUpTeeVectoru   â¥œz\RightUpVectorBaru   â¥”z\RightVectorBaru   â¥“z\Rightarrowu   â‡’z\Sameu   â©¶z\Searrowu   â‡˜z\Swarrowu   â‡™z\Topu   â«ªz\UpArrowBaru   â¤’z\VDashu   âŠ«z\approxu   â‰ˆz	\approxequ   â‰Šz\backsimu   âˆ½z\barinu   â‹¶z\barleftharpoonu   â¥«z\barrightharpoonu   â¥­z\biju   â¤–z\coloneqz\correspondsz\curlyeqprecu   â‹žz\curlyeqsuccu   â‹Ÿz\dashrightarrowu   â‡¢z\dlshu   â†²z\downdownharpoonsu   â¥¥z\downuparrowsu   â‡µz\downupharpoonsu   â¥¯z\drshu   â†³z\eqslantgtru   âª–z\eqslantlessu   âª•z\equivu   â‰¡z\ffunu   â‡»z\finju   â¤•z\gez\geqz\ggcurlyu   âª¼z	\gnapproxu   âªŠz\gnequ   âªˆz
\gtrapproxu   âª†z\hashu   â‹•z\iddotsu   â‹°z\impliesu	   â�Ÿâ‡’â�Ÿz\inu   âˆˆz\lez
\leftarrowz\leftarrowtriangleu   â‡½z\leftbarharpoonu   â¥ªz\leftrightarrowtriangleu   â‡¿z\leftrightharpoonu   â¥Šz\leftrightharpoondownu   â¥�z\leftrightharpoonupu   â¥Žz\leftrightsquigarrowu   â†­z
\leftsliceu   âª¦z\leftsquigarrowu   â‡œz\leftupdownharpoonu   â¥‘z\leqz\lessapproxu   âª…z\llcurlyu   âª»z	\lnapproxu   âª‰z\lnequ   âª‡z\longmapsfromu   âŸ»z\multimapbothu   â§Ÿz\multimapdotbothAu   âŠ¶z\multimapdotbothBu   âŠ·z\multimapinvu   âŸœz\nVdashu   âŠ®z\nez\neqz\ngeqz\nleqz\nniz\not\inz	\notasympu   â‰­z\nprecequ   â‹ z\nsqsubsetequ   â‹¢z\nsqsupsetequ   â‹£z\nsubsetu   âŠ„z\nsucceqz\pfunu   â‡¸z\pinju   â¤”z\precapproxu   âª·z\preceqqu   âª³z\precnapproxu   âª¹z	\precnsimu   â‹¨z\proptoz\psuru   â¤€z\rightarrowz\rightarrowtriangleu   â‡¾z\rightbarharpoonu   â¥¬z\rightleftharpoonu   â¥‹z\rightsliceu   âª§z\rightsquigarrowz\rightupdownharpoonu   â¥�z\simz	\strictfiu   â¥¼z	\strictifu   â¥½z\subsetu   âŠ‚z	\subsetequ   âŠ†z
\subsetnequ   âŠŠz\succapproxu   âª¸z\succeqqu   âª´z\succnapproxu   âªºz\supsetu   âŠƒu   âŠ‡u   âŠ‹õ   Ã—u   â‡…u   â¥®u   â¥£)	z	\supseteqz
\supsetneqz\timesz\toz\updownarrowsz\updownharpoonsz\upupharpoonsz\vartriangleleftz\vartrianglerightz\begin{ú\[Ú*)	Ú
beginafterÚbeginbeforer6  ÚcommandÚcommentr7  Úsimpler:  Ú
unnumberedÚsub)r  rû   zspan class="mbox"zspan class="text"zspan class="textipa"zspan class="textnormal"zspan class="textrm"úspan class="versalitas"zspan class="textsf"zspan class="normal")z\mboxz\textz\textbfz\textipaz\textitz\textnormalz\textrmz\textscz\textsfz\textslz\textttz\textupÚ
characters)r8   rj  r÷   ræ   rç   rè   ré   õ   Â·ú!ú;rä   rú   ú"Úgooglechartsz-http://chart.googleapis.com/chart?cht=tx&chl=N)r   r   r    r!   ÚalphacommandsÚarrayÚbigbracketsÚ
bigsymbolsÚbracketcommandsÚcombiningfunctionsrÍ   ÚdecoratedcommandÚdecoratingfunctionsr³   ÚenvironmentsÚfontfunctionsÚhybridfunctionsÚhybridsizesÚlabelfunctionsÚlimitcommandsÚmisccommandsÚmodifiedÚonefunctionsÚspacedcommandsr¶   ÚsymbolfunctionsÚtextfunctionsÚ
unmodifiedÚurlsr   r   r   r   rÒ   E  s8   ÿÿþþýýýýýüüüüûûûûúúúúùùùùøøøø	÷	÷	÷	÷
ö
ö
ö
ö
öõõõõôôôôóóóóòòòñññððððïïïîîîííìþ
ýÿüÿÿÿÿÿþþþþýýýýüüüûù
ÿÿÿÿÿþþþþþýýýüüüûûûúúúùùùøøø	÷	÷	÷	÷
ö
ö
öõõõôôôôóóóóòòòòññðððïïïïîîîîîíííììììëëëëêêêêéééèèèèççççææææåååäääããããâââááá à à à à!ß!ß!ß"Þ"Þ"Þ#Ý#Ý#Ý$Ü$Ü$Ü%Û%Û%Û&Ú&Ú'Ù'Ù(Ø(Ø(Ø)×)×)×)×*Ö*Ö*Ö+Õ+Õ+Õ,Ô,Ô,Ô-Ó-Ó-Ó-Ó.Ò.Ò.Ò.Ò/Ñ/Ñ/Ñ/Ñ0Ð0Ð0Ð1Ï1Ï1Ï2Î2Î2Î3Í3Í3Í3Í4Ì4Ì4Ì5Ë5Ë5Ë5Ë6Ê6Ê6Ê6Ê7É7É8È8È8È9Ç9Ç9Ç:Æ:Æ:Æ:Æ;Å;Å;Å<Ä<Ä<Ä=Ã=Ã=Ã>Â>Â>Â>Â?Á?Á?Á@À@ÀA¿A¿A¿B¾B¾B¾C½C½C½C½D¼D¼D¼E»E»E»E»FºFºFºFºG¹G¹G¹G¹H¸H¸H¸H¸I·I·I·I·J¶J¶J¶KµKµKµL´L´M³M³M³N²N²O±P°P°Q¯Q¯Q¯R®R®R®S­S­S­S­T¬T¬U«U«U«U«VªVªVªVªW©W©W©X¨X¨Y§Y§Y§Z¦Z¦[¥[¥[¥\¤\¤\¤\¤]£]£]£^¢^¢^¢^¢_¡_¡_¡_¡` ` ` aŸaŸaŸaŸbžbžbžbžc�c�dœdœdœe›e›e›fšfšfšfšg™g™g™h˜h˜h˜i—i—i—i—j–j–j–j–k•k•k•l”l”l”m“m“m“m“n’n’n’n’o‘o‘o‘p�p�p�p�q�q�q�rŽrŽrŽrŽs�s�s�s�tŒtŒtŒtŒu‹u‹u‹vŠvŠvŠw‰w‰w‰xˆxˆxˆy‡y‡z†z†z†{…{…{…|„|„}ƒ~‚�  �ÿ  �þ  �þ  �þ  �þ  �ý  �ý  �ý  �ý  �ü  �ü  �ü  �ü  �û  �û  �û  �û  �ú  �ú  �ú  �ù  �ù  �ù  �ù  �ø  �ø  �ø 	 �÷ 	 �÷ 	 �÷ 	 �÷ 
 �ö 
 �ö 
 �ö 
 �ö  �õ  �õ  �õ  �õ  �ô  �ô  �ô  �ó  �ó  �ò  �ò  �ñ  �ñ  �ð  �ð  �ï  �ï  �î  �î  �î  �í  �í  �í  �ì  �ì  �ì  �ë  �ë  �ë  �ë  �ê  �ê  �ê  �ê  �é  �é  �é  �è  �è  �ç  �ç  �æ  �æ  �æ  �å  �å  �å  �ä  �ä  �ä  �ã  �ã  �ã  �â  �â  �â  �á  �á  �á  �á   �à   �à   �à ! �ß ! �ß ! �ß " �Þ " �Þ " �Þ " �Þ # �Ý # �Ý # �Ý $ �Ü $ �Ü $ �Ü % �Û % �Û % �Û & �Ú & �Ú ' �Ù ' �Ù ' �Ù ( �Ø ( �Ø ( �Ø ) �× ) �× ) �× * �Ö * �Ö + �Õ + �Õ , �Ô , �Ô - �Ó - �Ó . �Ò . �Ò / �Ñ / �Ñ / �Ñ / �Ñ 0 �Ð 0 �Ð 0 �Ð 1 �Ï 1 �Ï 2 �Î 2 �Î 3 �Í 3 �Í 3 �Í 3 �Í 4 �Ì 4 �Ì 4 �Ì 5 �Ë 5 �Ë 5 �Ë 6 �Ê 6 �Ê 6 �Ê 7 �É 7 �É 7 �É 8 �È 8 �È 8 �È 9 �Ç 9 �Ç 9 �Ç 9 �Ç : �Æ : �Æ : �Æ : �Æ ; �Å ; �Å ; �Å < �Ä < �Ä < �Ä < �Ä = �Ã = �Ã = �Ã = �Ã @ÿþ
þÿÿþþþýýýüüüûûûúúúùùùøøø	÷	÷
ö
ö
öõõõôôóóóòòòñññðððïïîîíí
êÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#
Ô0þÿÿÿÿþþþþýýýýüüüûûû	üýÿÿþþýýüüûúùø	÷
öõôôóÿÿÿþþýýüüüûûúúùùøøø	÷	÷	÷
ö
öõõôôôóóòòññððïïïîîîîííííìììëëëêêêééèèèççççææææååååääääããââáá à à!ß!ß!ß"Þ"Þ"Þ#Ý#Ý#Ý$Ü$Ü%Û%Û%Û%Û&Ú&Ú&Ú&Ú'Ù'Ù'Ù(Ø(Ø(Ø)×)×)×)×*Ö*Ö*Ö+Õ+Õ+Õ,Ô,Ô-Ó-Ó.Ò.Ò.Ò/Ñ/Ñ/Ñ0Ð0Ð0Ð1Ï1Ï1
Ì8ýÿùÿ
ÿrÒ   c                   @   s   e Zd ZdZddddœZdS )ÚGeneralConfigr$   z
2015-02-26Ú413z1.2.5)ÚdateÚ	lyxformatÚnumberN)r   r   r    r!   Úversionr   r   r   r   r�    s    
ÿr�  c                   @   s@   e Zd ZdZdddddddd	d
ddddœZg d¢g d¢dœZdS )ÚHeaderConfigr$   r¥   z\branchz
\textclassz\end_branchz\end_preamblez	\languagez\lstsetz\output_changesz\paragraph_separationz
\pdf_titlez\secnumdepthz	\tocdepth)ÚbeginpreambleÚbranchÚdocumentclassÚ	endbranchÚendpreambleÚlanguageÚlstsetÚoutputchangesÚparagraphseparationÚpdftitleÚsecnumdepthÚtocdepth)0ÚarticleÚaastexÚaapaperÚacmsiggraphÚsigplanconfÚachemsoÚamsartÚapazarab-articlezarmenian-articlezarticle-beamerÚchessÚdtkÚ
elsarticlezheb-articleÚIEEEtranÚiopartÚkluwerzscrarticle-beamerÚscrartclÚ
extarticleÚpaperÚmwartÚrevtex4ÚspieÚ	svglobal3Últugboatzagu-dtdÚjgrgaÚagumsÚentcsÚegsÚijmpcÚijmpdzsinglecol-newzdoublecol-newÚisprsÚtarticleÚ	jsarticleÚjarticleÚjsszliterate-articleÚsiamltexÚcl2emultÚllncsÚsvglobalÚsvjogÚsvprobth)ÚbookÚamsbookÚscrbookÚextbookz
tufte-bookÚreportÚ	extreportÚscrreprtÚmemoirÚtbookÚjsbookÚjbookÚmwbkÚsvmonoÚsvmultÚtreportÚjreportÚmwrep)r¢  rÉ  N)r   r   r    r!   Ú
parametersÚstylesr   r   r   r   r•    s    ù
þr•  c                   @   s6   e Zd ZdZddddœZddddœZd	d
dgdœZdS )ÚImageConfigr$   zOconvert[ -density $scale][ -define $format:use-cropbox=true] "$input" "$output"z(inkscape "$input" --export-png="$output"zlyx -C "$input" "$output")ÚimagemagickÚinkscapeÚlyxÚpsÚpdf)ú.epsz.pdfz.psz.pngz.svgrâ  )r'   ÚvectorN)r   r   r    r!   Ú
convertersÚcropboxformatsÚformatsr   r   r   r   rÜ  1  s    ýÿ
ÿrÜ  c                   @   s   e Zd ZdZdg d¢iZdS )ÚLayoutConfigr$   rl   ©rT   rU   rX   r<   rR   rE   rS   r=   rO   rC   rZ   r[   N)r   r   r    r!   Ú	groupabler   r   r   r   rç  B  s    ÿrç  c                   @   s    e Zd ZdZddddddœZdS )	ÚNewfangleConfigr$   z	chunkref{rë   rÄ   r±   z=&lt;)ÚchunkrefÚ
endcommandÚendmarkr°   Ú	startmarkN)r   r   r    r!   Ú	constantsr   r   r   r   rê  I  s
    
þrê  c                   @   s.   e Zd ZdZg d¢ddgdœZdg d¢iZdS )	ÚNumberingConfigr$   )ÚChapterÚSectionÚ
SubsectionÚSubsubsectionÚ	ParagraphÚPartÚBook)ÚorderedÚromanÚsymbols)
rj  z**r	  r
  rú   u   Â§Â§rø   u   Â¶Â¶ró   z##N)r   r   r    r!   ÚlayoutsÚsequencer   r   r   r   rð  Q  s    þÿrð  c                   @   sÖ   e Zd ZdZdddddddddddd	œZi 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"d#“d$d%“d&d“d!d'd(d'd'd)œ¥Zd*d+d,d-d.d/d0d1œZd2g d3¢iZd4d5d6d7d8d9œZd:S );ÚStyleConfigr$   u   â€‚r  rÉ   r+   u   â€ƒâ€ƒr¾   r¿   )z	\enskip{}z\hfill{}z\hspace*{\fill}z
\hspace*{}z	\hspace{}z\negthinspace{}z\qquad{}z\quad{}z\space{}z\thinspace{}r(  Úaldr  Úalsu   â€ºÚardr  Úarsu   â€¹Úeldz&ldquo;Úelsz&lsquo;Úerdz&rdquo;Úersz&rsquo;ÚfldÚflsÚfrdÚfrsÚgldu   â€žÚglsu   â€šÚgrdr/  Úgrsr»   Úpldr0  rº   )ÚplsÚprdÚprsÚsldÚsrdu   (@â†•)u   Â¶â†•u   $â†•u   #â†•u   @â†•u   on-page#â†•u   @on-page#â†•)ÚeqrefÚ	formattedÚnamerefÚpagerefÚrefÚvpagerefÚvrefÚignoredtexts)ÚcolÚtextÚlineÚpageÚtheightÚpheightz<div class="bigskip"> </div>z<div class="defskip"> </div>z<div class="medskip"> </div>z<div class="smallskip"> </div>z<div class="vfill"> </div>)ÚbigskipÚdefskipÚmedskipÚ	smallskipÚvfillN)	r   r   r    r!   ÚhspacesÚquotesÚreferenceformatsÚsizeÚvspacesr   r   r   r   rý  ]  sp    üÿÿÿÿÿþþþþýýýýýüüüû	þÿ
ûrý  c                   @   s<   e Zd ZdZg d¢dgdgdœZg d¢g d¢g d¢dœZdS )	Ú	TOCConfigr$   rè  r+   rk   )rT   rU   rš   )rR   rE   rS   r=   rO   rC   rZ   r[   )rW   rX   r<   rY   r£   r„   N)r   r   r    r!   ÚextractplainÚextracttitler   r   r   r   r,  €  s    þ
ýr,  c                   @   s†   e Zd ZdZddiZdddœZddddd	d
dœZdddgiZdddddddddddœ
ZdddœZ	ddddœZ
dddœZdddd œZd!S )"Ú	TagConfigr$   Úunderrg  zspan class="sans"rC  )ÚsansÚ
typewriterzspan class="code"zspan class="menuitem"zspan class="noun"zspan class="strong")zCharStyle:CodezCharStyle:MenuItemÚCodeÚMenuItemÚNounÚStrongrû  Ú	QuotationÚQuoteÚdivzh?Úh2Úh1Ú
blockquote)
ÚCenterrñ  ÚDaterõ  rö  r7  r8  rò  ró  rô  ÚolÚul)Ú	EnumerateÚItemizer+   zspan class="greyedout")ÚCommentÚ	Greyedoutr‘   rq  r)  )Ú	subscriptÚsuperscriptrB  rr  )ÚitalicÚslantedÚ	smallcapsN)r   r   r    r!   ÚbarredÚfamilyÚflexÚgrouprû  Ú	listitemsÚnotesÚscriptÚshapedr   r   r   r   r/  Ž  s2    ÿÿüÿýÿÿÿ
ÿr/  c                
   @   s  e Zd ZdZi 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d“dd“dd“i dd“dd“dd “d!d"“d#d$“d%d&“d'd(“d)d*“d+d,“d-d.“d/d0“d1d2“d3d4“d5d6“d7d8“d9d:“d;d<“¥d=d>d?œ¥Zd@d@dAdBd@dCdAdDdEdFœ	ZdGS )HÚTranslationConfigr$   ÚAppendixr÷  rñ  rõ  rö  rò  ró  rô  Úabstractr›   Úbibliographyr�   Úfigurezfloat-algorithmz
Algorithm zfloat-figurezFigure zfloat-listingzListing zfloat-tablezTable zfloat-tableauzTableau Ú	footnotesÚ	Footnoteszgenerated-byzDocument generated by zgenerated-onz on ÚindexÚIndexzjsmath-enablez)Please enable JavaScript on your browser.zjsmath-requireszH requires JavaScript to correctly process the mathematics on this page. zjsmath-warningz	Warning: zlist-algorithmzList of Algorithmszlist-figurezList of Figuresz
list-tablezList of Tableszlist-tableauzList of Tableauxz	main-pagez	Main pageÚnextÚNextÚnomenclatureÚNomenclatureúon-pagez	 on page ÚprevÚPrevÚ
referencesÚ
ReferencesÚtoczTable of ContentszContents for ÚUp)ztoc-forÚupÚenÚdeÚnlÚfrÚruÚes)	ÚamericanÚbritishÚdeutschÚdutchÚenglishÚfrenchÚngermanÚrussianÚspanishN)r   r   r    r!   rï  Ú	languagesr   r   r   r   rR  º  sš    ÿÿÿþþþýýüüûûúúùùøø	÷	÷
öõôôóóòòññðððïï
ýrR  c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚCommandLineParserzA parser for runtime optionsc                 C   s
   || _ d S ©N©Úoptions)Úselfrz  r   r   r   Ú__init__Û  ó   
zCommandLineParser.__init__c                 C   s„   t |ƒdkrdS t |ƒdkr@|d  d¡r@|  |¡\}}|s$d| d S |s,d| d S t| j||ƒ t |ƒdkr@|d  d¡sdS )úParse command line optionsr   Nr9   zOption z not recognizedz needs a value)ÚlenÚ
startswithÚ
readoptionÚsetattrrz  )r{  ÚargsÚkeyÚvaluer   r   r   ÚparseoptionsÞ  s   úzCommandLineParser.parseoptionsc                 C   sâ   |d dd… }|d= d|v r|   ||¡}n| dd¡}t| j|ƒs&d|fS t| j|ƒ}t|tƒr5|dfS t|ƒdkr?|dfS |d  d¡rU|d }|d= ||  	||¡fS |d  
d	¡}|d= t|tƒrm| |¡ ||fS ||fS )
z$Read the key and value for an optionr   é   Nre  rÁ   r+   Trw  r   )ÚreadequalskeyÚreplaceÚhasattrrz  ÚgetattrÚ
isinstanceÚboolr  r€  Ú
readquotedÚdecodeÚlistÚappend)r{  rƒ  rÿ   r„  ÚcurrentÚinitialr…  r   r   r   r�  ë  s,   


zCommandLineParser.readoptionc                 C   sÄ   t  d¡ |dd… }t|ƒdkrG|d  d¡sG|d  d¡sGt  d|d  ¡ |d|d  7 }|d= t|ƒdkrG|d  d¡sG|d  d¡rt|ƒdksT|d  d¡rVdS |d|dd	…  7 }|S )
zRead a value between quotesÚOopsé   Nr   rw  r9   z
Appending rö   r   )r   r   r  Úendswithr€  )r{  rƒ  r“  r…  r   r   r   rŽ    s   
((ýzCommandLineParser.readquotedc                 C   s,   |  dd¡}|d }|d }| d|¡ |S )zRead a key using equalsre  r•  r   )ÚsplitÚinsert)r{  rÿ   rƒ  r—  r„  r…  r   r   r   rˆ    s
   zCommandLineParser.readequalskeyN)	r   r   r    r!   r|  r†  r�  rŽ  rˆ  r   r   r   r   rw  Ø  s    rw  c                   @   s*  e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdZdZdZdZdZg ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5g Z6e7ƒ Z8dd„ Z9d	d
„ Z:dd„ Z;dd„ Z<dd„ Z=dd„ Z>dd„ Z?dd„ Z@dd„ ZAdS )ÚOptionszA set of runtime optionsNFTr+   rÝ  c                 C   sD   |d t _|d= tt ƒ}| |¡}|rt |¡ |  ¡  |  ¡  dS )r~  r   N)r™  Úlocationrw  r†  r   r   ÚusageÚprocessoptions)r{  rƒ  ÚparserÚresultr   r   r   r†  V  s   


zOptions.parseoptionsc              	   C   s|  t jr|  ¡  t jr|  ¡  t jr|  ¡  t jr|  ¡  t j	r#|  
¡  t jrMztt jƒt _t jdkr;t d¡ |  ¡  W n   t dt j ¡ |  ¡  Y t jsVt jsVt jrYdt _|  ¡  t jrgt jsgt jt _t jdkrodt _t jg krxdgt _t jdkr~	 t jr„dt _t jr“t js“t d	¡ t jt _t jr›t d
¡ t jr£t d¡ ttƒD ]}| d¡r»t t|t!| |dd… ƒƒ q§dS )zProcess all options parsed.r   z.--splitpart requires a number bigger than zeroz*--splitpart needs a numeric argument, not FÚcopyTz 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 insteadÚmodeNéüÿÿÿ)"r™  Úhelpr›  r”  ÚshowversionÚhardversionÚshowhardversionÚversiondateÚshowversiondater’  ÚshowlyxformatÚ	splitpartÚintr   r   Úlowmemrd  ÚtocforÚmemoryÚparsefootnotesÚforceformatÚimageformatÚ
copyimagesÚcssÚfaviconrÏ   Ú
simplemathÚ	toctargetÚnocopyÚjsmathÚdirr–  r‚  r‹  )r{  Úparamr   r   r   rœ  a  sZ   

€







€þzOptions.processoptionsc                 C   sF   t  dtj tj¡ d ¡ t  d¡ t  d¡ t  d¡ |  ¡  dS )zShow correct usagezUsage: 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)r   r   ÚosÚpathÚbasenamer™  rš  Úshowoptions©r{  r   r   r   r›  �  s
   


zOptions.usagec                 C   s–   t jsdS dt _dt _dt _t j d¡}|D ]}|d }tt |ƒr(tt |dƒ qt 	d| ¡ qt j
s<t js<t js<dt _t jsGt jsIdt _dS dS dS )zParse footnotes options.NFrc  ÚfootTzUnknown footnotes option: )r™  rW  Ú
marginfootÚ
letterfootÚ	hoverfootr—  rŠ  r‚  r   r   ÚendfootÚ
numberfootÚ
symbolfoot)r{  rz  ÚoptionÚ
footoptionr   r   r   r®  —  s    

ÿzOptions.parsefootnotesc                 C   s  t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d	¡ t  d
¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d¡ t  d ¡ t  d!¡ t  d"¡ t  d#¡ t  d$¡ t  d%¡ t  d&¡ t  d'¡ t  d(¡ t  d)¡ t  d*¡ t  d+¡ t  d,¡ t  d-¡ t  d.¡ t  d/¡ t  d0¡ t  d1¡ t  d2¡ t  d3¡ t  d4¡ t ¡  d5S )6zShow 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 <!--$content-->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)r   r   r	   r   r¾  r   r   r   r½  ª  sj   



















































zOptions.showoptionsc                 C   s:   dt jd  }|dt jd  d 7 }t |¡ t ¡  dS )z(Return the current eLyXer version stringzeLyXer version r“  ú (r‘  rç   N)r�  r”  r   r   r	   r   ©r{  r·   r   r   r   r£  â  s   
zOptions.showversionc                 C   ó   t  tjd ¡ t ¡  dS )zReturn just the version stringr“  N©r   r   r�  r”  r	   r   r¾  r   r   r   r¥  é  ó   zOptions.showhardversionc                 C   rÊ  )zReturn just the version dter‘  NrË  r¾  r   r   r   r§  î  rÌ  zOptions.showversiondatec                 C   rÊ  )z#Return just the lyxformat parameterr’  NrË  r¾  r   r   r   r¨  ó  rÌ  zOptions.showlyxformat)Br   r   r    r!   Úinstancerš  r¶  Ú	copyrightr   Úquietr”  r¤  r¦  rÏ   r¢  Ú	showlinesÚunicoderÐ   r²  r³  ÚtitleÚ	directoryÚdestdirectoryrd  rµ  r¬  r¯  r’  Útargetr©  r­  r«  ÚnobibÚ	converterÚrawr·  ÚmathjaxÚnofooterr´  ÚtemplateÚ	noconvertÚnotoclabelsrÁ  rÄ  rÅ  rÂ  rÀ  rÃ  ÚsupfootÚ	alignfootrW  r°  r±  rx  ÚembedcssÚdictÚbranchesr†  rœ  r›  r®  r½  r£  r¥  r§  r¨  r   r   r   r   r™    s~    .8r™  c                   @   óB   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zej	d
kreZ
dS dS )ÚBranchOptionszA set of options for a branchc                 C   s   || _ ddi| _d S )NÚcolorz#ffffff)Únamerz  ©r{  ræ  r   r   r   r|  û  s   zBranchOptions.__init__c                 C   sB   |  tjd ¡st d| ¡ dS | tjd d¡}|| j|< dS )zSet a branch optionr°   zInvalid branch option Nr+   )r€  r;   r·   r   r   r‰  rz  ©r{  r„  r…  r   r   r   Úsetÿ  s
   zBranchOptions.setc                 C   s   d| j vrdS | j d dkS )z Return if the branch is selectedÚselectedFÚ1ry  r¾  r   r   r   Ú
isselected  s   
zBranchOptions.isselectedc                 C   s   d| j  d t| jƒ S )zString representationzoptions for r  )ræ  rÑ  rz  r¾  r   r   r   Ú__unicode__  ó   zBranchOptions.__unicode__r   N)r   r   r    r!   r|  ré  rì  rí  r	   r   Ú__str__r   r   r   r   rä  ø  s    
ÿrä  c                   @   s0   e Zd ZdZdd„ Zdd„ ZeeƒZeeƒZdS )ÚClonerz&An object used to clone other objects.c                 C   s   	 |   |j¡S )z"Return an exact copy of an object.)ÚcreateÚ	__class__)r   Úoriginalr   r   r   Úclone  s   zCloner.clonec                 C   s   |  |¡}| ¡  |S )z"Create an object of a given class.)Ú__new__r|  )r   Útyperô  r   r   r   rñ    s   
zCloner.createN)r   r   r    r!   rô  rñ  r"   r   r   r   r   rð    s    rð  c                   @   ó0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚContainerExtractorz&A class to extract certain containers.c                 C   s,   	 	 	 	 	 |d | _ |d | _|d | _dS )zTThe config parameter is a map containing three lists: allowed, copied and extracted.rl   rm   rn   Nrk   )r{  Úconfigr   r   r   r|  )  s   

zContainerExtractor.__init__c                    s<   g ‰ ‡fdd„}‡fdd„}‡ ‡fdd„}|  |||¡ ˆ S )z?Extract a group of selected containers from elyxer.a container.c                    s   | j jˆ jˆ j v S rx  )rò  r   rl   rm   ©r=  r¾  r   r   Ú<lambda>7  ó    z,ContainerExtractor.extract.<locals>.<lambda>c                    s   | j jˆ jv S rx  )rò  r   rn   rú  r¾  r   r   rû  8  s    c                    s   ˆ  | ˆ ¡S rx  )Úprocessrú  ©r�  r{  r   r   rû  9  ó    )Úrecursivesearch)r{  Ú	containerÚlocateÚ	recursiverý  r   rþ  r   Úextract4  s   zContainerExtractor.extractc                 C   sP   |j j}|| jv r| |¡ dS || jv r| |  |¡¡ dS t d| ¡ dS )zBAdd allowed containers, clone cloned containers and add the clone.zUnknown container class N)rò  r   rl   r‘  rm   Ú	safecloner   r   )r{  r  r�  ræ  r   r   r   rý  =  s   

zContainerExtractor.processc                 C   s"   t  |¡}|j|_|  |¡|_|S )zFReturn a new container with contents only in a safe list, recursively.)rð  rô  Úoutputr  Úcontents)r{  r  rô  r   r   r   r  G  s   
zContainerExtractor.safecloneN)r   r   r    r!   r|  r  rý  r  r   r   r   r   rø  &  s    	
rø  c                   @   sZ   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
ejdkr+e
ZdS dS )ÚParserzA generic parserc                 C   s   d| _ tƒ | _d S )Nr   )rß   rá  rÚ  r¾  r   r   r   r|  V  s   zParser.__init__c                 C   s    |  ¡  ¡ }| ¡  |j| _|S )zParse the header)Úcurrentliner—  ÚnextlineÚ
linenumberrß   )r{  ÚreaderÚheaderr   r   r   ÚparseheaderZ  s   zParser.parseheaderc                 C   s¾   |  ¡  ¡  d¡r|  |¡\}}|| j|< dS |  ¡  ¡  dd¡}| ¡  t|ƒdkr-dS |d }t|ƒdkr>d| j|< dS d|d vrO|d  ¡ | j|< dS |d  d¡}|d | j|< dS )zParse a parameterrÆ   Nrö   r•  r   Trw  )r	  Ústripr€  ÚparsexmlrÚ  r—  r
  r  )r{  r  r„  r…  r—  Údoublesplitr   r   r   Úparseparametera  s"   

zParser.parseparameterc           
      C   sè   |  ¡  ¡ }| ¡  | d¡st d| d ¡ |dd…  ¡ }t|ƒdkr-t d¡ dS |d }|d= t|ƒdkr?|tƒ fS tƒ }|D ]+}d	|vrYt d
| d | ¡ |d7 }| d	¡}|d }|d  d¡d }	|	||< qD||fS )z5Parse a parameter in xml form: <param attr1=value...>rÇ   zXML parameter z should be <...>r•  r   r   zEmpty XML parameter <>©NNre  zErroneous attribute for r  z="0"rw  )	r	  r  r
  r–  r   r   r—  r  rá  )
r{  r  r  r—  r„  ÚattrsÚattrÚpartsÚattrkeyr…  r   r   r   r  u  s,   




zParser.parsexmlc                 C   sJ   | j st dt| ƒ ¡ dS | ¡  | j ¡s#|ƒ  | ¡  | j ¡rdS dS )z'Parse until the current ending is foundzNo ending for N)Úendingr   r   rÑ  r	  r€  )r{  r  rý  r   r   r   ÚparseendingŽ  s   ÿzParser.parseendingc                 C   s*   | j  |¡}|r| j|_| |¡ d S d S rx  )ÚfactoryÚcreatecontainerÚparentr‘  )r{  r  r  r  r   r   r   Úparsecontainer–  s
   þzParser.parsecontainerc                 C   s   | j jd t| jƒ d S )zReturn a descriptionrÈ  rç   )rò  r   rÑ  rß   r¾  r   r   r   rí  œ  ó   zParser.__unicode__r   N)r   r   r    r!   r|  r  r  r  r  r  rí  r	   r   rï  r   r   r   r   r  S  s    
ÿr  c                   @   ó   e Zd ZdZdd„ ZdS )ÚLoneCommandz"A parser for just one command linec                 C   ó   g S )zRead nothingr   ©r{  r  r   r   r   Úparse§  ó   zLoneCommand.parseN©r   r   r    r!   r#  r   r   r   r   r   ¤  ó    r   c                   @   s,   e Zd ZdZg Zdd„ Zdd„ Zdd„ ZdS )	Ú
TextParserz(A parser for a command and a bit of textc                 C   s8   t  | ¡ d | _|jjtjv rtj|jj | _g | _d S rx  )r  r|  r  rò  r   r;   r³   ©r{  r  r   r   r   r|  °  s
   

zTextParser.__init__c                 C   sV   t j | j¡ t jtjd tjd | jg | _g }|  |¡s)|  ||¡ |  |¡r|S )z$Parse lines as long as they are textrI   rH   )r'  Ústackr‘  r  r;   r³   Úisendingr  ©r{  r  r  r   r   r   r#  ·  s   ÿ

ÿzTextParser.parsec                 C   sZ   |  ¡  ¡ }t|ƒdkrdS |d | jv r+|d tjv r&tj |d ¡ dS g t_dS dS )zCheck if text is endingr   FT)r	  r—  r  r³   r'  r)  Úremove)r{  r  r’  r   r   r   r*  Á  s   ÿzTextParser.isendingN)r   r   r    r!   r)  r|  r#  r*  r   r   r   r   r'  «  s    
r'  c                   @   r  )ÚExcludingParserz%A parser that excludes the final linec                    s    g ‰ ˆ  ˆ‡ ‡‡fdd„¡ ˆ S )z5Parse everything up to (and excluding) the final linec                      ó   ˆ  ˆˆ ¡S rx  )r  r   ©r  r  r{  r   r   rû  Ô  rÿ  z'ExcludingParser.parse.<locals>.<lambda>)r  r"  r   r/  r   r#  Ñ  s   zExcludingParser.parseNr%  r   r   r   r   r-  Î  r&  r-  c                   @   r  )ÚBoundedParserzA parser bound by a final linec                 C   s   t  | |¡}| ¡  |S )z*Parse everything, including the final line)r-  r#  r
  r+  r   r   r   r#  Ú  s   zBoundedParser.parseNr%  r   r   r   r   r0  ×  r&  r0  c                   @   r  )ÚBoundedDummyz&A bound parser that ignores everythingc                    s    |   ˆ ‡ fdd„¡ ˆ  ¡  g S )z#Parse the contents of the containerc                      s   ˆ   ¡ S rx  )r
  r   ©r  r   r   rû  æ  s    z$BoundedDummy.parse.<locals>.<lambda>©r  r
  r"  r   r2  r   r#  ä  s   zBoundedDummy.parseNr%  r   r   r   r   r1  á  r&  r1  c                   @   ó    e Zd ZdZdd„ Zdd„ ZdS )ÚStringParserzParses just a stringc                 C   s   |j d | _g S )zDo nothing, just take noter•  ©r  rß   r"  r   r   r   r  î  s   zStringParser.parseheaderc                 C   s   |  ¡ }| ¡  |S )zParse a single line)r	  r
  r+  r   r   r   r#  ó  s   zStringParser.parseN©r   r   r    r!   r  r#  r   r   r   r   r5  ë  ó    r5  c                   @   r  )ÚInsetParserzParses a LyX insetc                 C   sT   t jd }| ¡ dkr$| ¡  |¡s$|  |¡ | ¡ dkr$| ¡  |¡rt | |¡S )z(Parse inset parameters into a dictionaryr°   r+   )r;   r·   r	  r€  r  r0  r#  )r{  r  r°   r   r   r   r#  ü  s
   

ÿzInsetParser.parseNr%  r   r   r   r   r9  ù  r&  r9  c                   @   r4  )ÚContainerOutputz(The generic HTML output for a container.c                 C   ó   t  dt| ƒ ¡ dS )zShow an error.zgethtml() not implemented for N©r   r   rÑ  r(  r   r   r   Úgethtml  ó   zContainerOutput.gethtmlc                 C   ó   dS )z5Decide if the output is empty: by default, not empty.Fr   r¾  r   r   r   Úisempty  r$  zContainerOutput.isemptyN)r   r   r    r!   r=  r@  r   r   r   r   r:    ó    r:  c                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚEmptyOutputc                 C   r!  )zReturn empty HTML code.r   r(  r   r   r   r=    r$  zEmptyOutput.gethtmlc                 C   r?  )z"This output is particularly empty.Tr   r¾  r   r   r   r@    r$  zEmptyOutput.isemptyN)r   r   r    r=  r@  r   r   r   r   rB    s    rB  c                   @   r  )ÚFixedOutputzFixed outputc                 C   s   |j S )zReturn constant HTML code©rÏ   r(  r   r   r   r=     ó   zFixedOutput.gethtmlN©r   r   r    r!   r=  r   r   r   r   rC    r&  rC  c                   @   r  )ÚContentsOutputz&Outputs the contents converted to HTMLc                 C   s^   g }|j dkr	|S |j D ] }t|dƒs&t d|jj d t|ƒ ¡ |  S || ¡ 7 }q|S )úReturn the HTML codeNr=  zNo html in r  )r  rŠ  r   r   rò  r   rÑ  r=  )r{  r  rÏ   Úelementr   r   r   r=  '  s   


zContentsOutput.gethtmlNrF  r   r   r   r   rG  $  r&  rG  c                   @   sV   e Zd ZdZdZdZdZddd„Zdd„ Zdd	„ Z	d
d„ Z
dd„ Zdd„ Zdd„ ZdS )ÚTaggedOutputz-Outputs an HTML tag surrounding the contents.NFc                 C   s   || _ |r|| _|r|| _| S )z/Set the value for the tag and other attributes.)ÚtagÚ
breaklinesÚempty)r{  rK  rL  rM  r   r   r   Úsettag:  s   zTaggedOutput.settagc                 C   ó
   || _ | S )zSet the value for breaklines.)rL  )r{  rL  r   r   r   ÚsetbreaklinesC  ó   zTaggedOutput.setbreaklinesc                 C   sB   | j r	|  |¡gS |  |¡g}|t | |¡7 }| |  |¡¡ |S )zReturn the HTML code.)rM  ÚselfclosingÚopenrG  r=  r‘  Úclose)r{  r  rÏ   r   r   r   r=  H  s   zTaggedOutput.gethtmlc                 C   ó.   |   |¡sdS d| j d }| jr|d S |S )zGet opening line.r+   rÆ   rÇ   r   ©ÚchecktagrK  rL  )r{  r  rS  r   r   r   rS  Q  ó   
zTaggedOutput.openc                 C   s:   |   |¡sdS d| j ¡ d  d }| jrd| d S |S )zGet closing line.r+   z</r   rÇ   r   )rW  rK  r—  rL  )r{  r  rT  r   r   r   rT  Z  s   
zTaggedOutput.closec                 C   rU  )zGet self-closing line.r+   rÆ   rÈ   r   rV  )r{  r  rR  r   r   r   rR  c  rX  zTaggedOutput.selfclosingc                 C   s.   | j st dt|ƒ ¡ dS | j dkrdS dS )zCheck that the tag is valid.z
No tag in Fr+   T)rK  r   r   rÑ  r(  r   r   r   rW  l  s   
zTaggedOutput.checktag)FF)r   r   r    r!   rK  rL  rM  rN  rP  r=  rS  rT  rR  rW  r   r   r   r   rJ  3  s    
					rJ  c                   @   s2   e Zd ZdZ	 dd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚFilteredOutputz1Returns the output in the contents, but filtered:c                 C   s
   g | _ dS )zInitialize the filters.N)Úfiltersr¾  r   r   r   r|  y  ó   
zFilteredOutput.__init__c                 C   s   | j  ||f¡ dS )z:Add a new filter: replace the original by the replacement.N)rZ  r‘  )r{  ró  Úreplacementr   r   r   Ú	addfilter}  ó   zFilteredOutput.addfilterc                 C   s.   g }t  | |¡}|D ]
}| |  |¡¡ q
|S )rH  )rG  r=  r‘  Úfilter)r{  r  rž  rÏ   r  r   r   r   r=  �  s
   zFilteredOutput.gethtmlc                 C   s(   | j D ]\}}||v r| ||¡}q|S )z0Filter a single line with all available filters.)rZ  r‰  )r{  r  ró  r\  r   r   r   r_  ‰  s
   €zFilteredOutput.filterN)r   r   r    r!   r|  r]  r=  r_  r   r   r   r   rY  u  s    rY  c                   @   r  )ÚStringOutputzReturns a bare string as outputc                 C   s   |j gS )zReturn a bare string©r·   r(  r   r   r   r=  “  ó   zStringOutput.gethtmlNrF  r   r   r   r   r`  �  r&  r`  c                   @   óP   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ ZdS )Ú
LineReaderzReads a file line by linec                 C   s‚   t |tƒr	|| _nt |dd¡| _d| _d | _d | _d| _d| _z|  	¡  W d S  t
y@   dd l}| |d¡| _|  	¡  Y d S w )NÚrUr   r•  TFr   Úrb)rŒ  ÚfileÚcodecsrS  r  Úlastliner’  ÚmustreadÚdepletedÚreadlineÚUnicodeDecodeErrorÚgzip)r{  Úfilenamern  r   r   r   r|  ›  s   
üzLineReader.__init__c                 C   s"   t |ƒD ]}| j ¡  q|| _dS )zSet the first line to read.N)Úrangerg  rl  r  )r{  Ú	firstlinerB  r   r   r   Úsetstart­  s   
zLineReader.setstartc                 C   ó
   || _ dS )zSet the last line to read.N)ri  )r{  ri  r   r   r   Úsetend³  r[  zLineReader.setendc                 C   s   | j r|  ¡  | jS )zGet the current line)rj  rl  r’  r¾  r   r   r   r	  ·  s   zLineReader.currentlinec                 C   s   | j rt d¡ d| _dS )zGo to next linezRead beyond file endTN)rk  r   r   rj  r¾  r   r   r   r
  ½  s   

zLineReader.nextlinec                 C   s’   | j  ¡ | _t| j tjƒs| j d¡| _t| jƒdkrd| _| j 	d¡| _|  j
d7  _
d| _dt| j
ƒ d t_| j
d	 dkrGt d
¡ dS dS )zRead a line from elyxer.filer   r   Tz
r•  FúLine r  éè  ÚParsingN)rg  rl  r’  rŒ  rh  ÚStreamReaderWriterr�  r  rk  Úrstripr  rj  rÑ  r   r   r   r¾  r   r   r   rl  Ã  s   ÿzLineReader.readlinec                 C   s*   | j r| j| j krdS | jr|  ¡  | jS )z Find out if the file is finishedT)ri  r  rj  rl  rk  r¾  r   r   r   ÚfinishedÑ  s
   zLineReader.finishedc                 C   ó   | j  ¡  d S rx  ©rg  rT  r¾  r   r   r   rT  Ù  ó   zLineReader.closeN)r   r   r    r!   r|  rr  rt  r	  r
  rl  rz  rT  r   r   r   r   rd  ˜  s    rd  c                   @   s<   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dS )Ú
LineWriterz"Writes a file as a series of listsFc                 C   s$   t |tƒr|| _d | _d S || _d S rx  )rŒ  rg  ro  ©r{  ro  r   r   r   r|  á  s   


zLineWriter.__init__c                 C   sF   |D ]}t |tƒst dt|ƒ d t|ƒ ¡  dS |  |¡ qdS )zWrite a list of stringszNot a string: ú in N)rŒ  Ú
basestringr   r   rÑ  Úwritestring)r{  Ústringsr·   r   r   r   r   è  s   
üzLineWriter.writec                 C   sH   | j st | jdd¡| _ | j tjkrtjdk r| d¡}| j  |¡ dS )zWrite a stringÚwr   r   N)	rg  rh  rS  ro  r	   r
   r   r   r   rÉ  r   r   r   r‚  ð  s
   
zLineWriter.writestringc                 C   s   |   |d ¡ dS )zWrite a line to filer   N)r‚  ©r{  r  r   r   r   Ú	writelineø  ó   zLineWriter.writelinec                 C   r{  rx  r|  r¾  r   r   r   rT  ü  r}  zLineWriter.closeN)
r   r   r    r!   rg  r|  r   r‚  r†  rT  r   r   r   r   r~  Ü  s    r~  c                   @   s¸   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd,d%d&„Zd-d(d)„Zd*d+„ Zd'S ).ÚGlobablez A bit of text which can be globbed (lumped together in bits).
  Methods current(), skipcurrent(), checkfor() and isout() have to be
  implemented by subclasses.Fc                 C   ó   t ƒ | _d S rx  )Ú
EndingListÚ
endinglistr¾  r   r   r   r|    ó   zGlobable.__init__c                 C   s,   |   ¡ rdS t|  ¡ ƒdkr|  ¡  dS dS )z*Check for a Unicode byte mark and skip it.Niÿþ  )rz  Úordr’  Úskipcurrentr¾  r   r   r   Úcheckbytemark  s
   ÿzGlobable.checkbytemarkc                 C   ó   t  d¡ dS )z+Find out if we are out of the position yet.zUnimplemented isout()T©r   r   r¾  r   r   r   Úisout  ó   
zGlobable.isoutc                 C   r�  )zReturn the current character.zUnimplemented current()r+   r‘  r¾  r   r   r   r’    r“  zGlobable.currentc                 C   r�  )z3Check for the given string in the current position.zUnimplemented checkfor()Fr‘  rÉ  r   r   r   Úcheckfor  r“  zGlobable.checkforc                 C   s(   |   ¡ r| js| j ¡  dS | j | ¡S )z*Find out if the current text has finished.T)r’  Úleavependingr‹  ÚcheckpendingÚcheckinr¾  r   r   r   rz  $  s
   
zGlobable.finishedc                 C   r�  )ú)Return the current character and skip it.zUnimplemented skipcurrent()r+   r‘  r¾  r   r   r   rŽ  ,  r“  zGlobable.skipcurrentc                 C   s0   d}|   ¡ s|ƒ r||  ¡ 7 }|   ¡ s|ƒ s	|S )z>Glob a bit of text that satisfies a check on the current char.r+   )rz  rŽ  )r{  ÚcurrentcheckÚglobr   r   r   rš  1  s
   ÿzGlobable.globc                    ó   ˆ   ‡ fdd„¡S )zGlob a bit of alpha textc                      ó   ˆ   ¡  ¡ S rx  ©r’  Úisalphar   r¾  r   r   rû  :  rÿ  z$Globable.globalpha.<locals>.<lambda>©rš  r¾  r   r¾  r   Ú	globalpha8  r‡  zGlobable.globalphac                    r›  )zGlob a row of digits.c                      rœ  rx  ©r’  Úisdigitr   r¾  r   r   rû  >  rÿ  z%Globable.globnumber.<locals>.<lambda>rŸ  r¾  r   r¾  r   Ú
globnumber<  r‡  zGlobable.globnumberc                 C   s    |   ¡  ¡ s|   ¡ dkrdS dS )z5Return if the current character is alphanumeric or _.rû   TF)r’  Úisalnumr¾  r   r   r   Úisidentifier@  s   zGlobable.isidentifierc                 C   ó   |   | j¡S )z Glob alphanumeric and _ symbols.)rš  r¥  r¾  r   r   r   ÚglobidentifierF  ó   zGlobable.globidentifierc                 C   s&   	 |   ¡  ¡ r	dS |   ¡ dv rdS dS )z5Return if the current character is a value character:Fz{}()T©r’  Úisspacer¾  r   r   r   ÚisvalueJ  s   zGlobable.isvaluec                 C   r¦  )z'Glob a value: any symbols but brackets.)rš  r«  r¾  r   r   r   Ú	globvalueS  r¨  zGlobable.globvaluec                    r›  )z(Skip all whitespace at current position.c                      rœ  rx  r©  r   r¾  r   r   rû  Y  rÿ  z$Globable.skipspace.<locals>.<lambda>rŸ  r¾  r   r¾  r   Ú	skipspaceW  r‡  zGlobable.skipspacec                    s&   ˆ  ‡ ‡fdd„¡ˆ  }ˆ ˆ ¡ |S )z4Glob a bit of text up to (including) the magic char.c                      s   ˆ  ¡ ˆ kS rx  ©r’  r   ©Ú	magiccharr{  r   r   rû  ]  rÿ  z(Globable.globincluding.<locals>.<lambda>)rš  Úskip)r{  r°  rš  r   r¯  r   Úglobincluding[  s   
zGlobable.globincludingc                    s   ˆ  ‡ ‡fdd„¡S )z?Glob a bit of text up until (excluding) any excluded character.c                      s   ˆ  ¡ ˆ vS rx  r®  r   ©Úexcludedr{  r   r   rû  c  rÿ  z(Globable.globexcluding.<locals>.<lambda>rŸ  )r{  r´  r   r³  r   Úglobexcludinga  r^  zGlobable.globexcludingc                 C   s   | j  ||¡ dS )zPush a new ending to the bottomN)r‹  Úadd©r{  r  Úoptionalr   r   r   Ú
pushendinge  r‡  zGlobable.pushendingNc                 C   sN   |   ¡ r	| jr	|S | j | ¡}|r ||kr t d| d | ¡ |  |¡ |S )z,Pop the ending found at the current positionzExpected ending z, got )r’  r•  r‹  Úpopr   r   r±  )r{  Úexpectedr  r   r   r   Ú	popendingi  s   
zGlobable.popendingc                 C   s   | j  | ¡}|s
dS |jS )z$Return the next ending in the queue.N)r‹  Ú
findendingr  )r{  Ú
nextendingr   r   r   r¾  s  s   zGlobable.nextending©Frx  )r   r   r    r!   r•  r|  r�  r’  r’  r”  rz  rŽ  rš  r   r£  r¥  r§  r«  r¬  r­  r²  rµ  r¹  r¼  r¾  r   r   r   r   rˆ    s.    	


rˆ  c                   @   sd   e Zd ZdZdd„ Zddd„Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zejdkr0eZdS dS )rŠ  zA list of position endingsc                 C   s
   g | _ d S rx  )r³   r¾  r   r   r   r|  }  r}  zEndingList.__init__Fc                 C   s   | j  t||ƒ¡ dS )zAdd a new ending to the listN)r³   r‘  ÚPositionEndingr·  r   r   r   r¶  €  r>  zEndingList.addc                 C   s   |  j |jj 7  _ dS )z/Pick any pending endings from a parse position.N)r³   r‹  ©r{  Úposr   r   r   Úpickpending„  r>  zEndingList.pickpendingc                 C   s   |   |¡rdS dS )zSearch for an endingTF)r½  rÁ  r   r   r   r—  ˆ  s   
zEndingList.checkinc                 C   sŠ   |  ¡ rt d¡ dS |  |¡}|st d| ¡  ¡ dS t| jƒD ]}| j |¡ ||kr3|j  S |j	s=t d| ¡ q"t d¡ dS )z)Remove the ending at the current positionzNo ending out of boundsr+   zNo ending at zRemoved non-optional ending zNo endings left)
r’  r   r   r½  r’  Úreversedr³   r,  r  r¸  )r{  rÂ  r  Úeachr   r   r   rº  Ž  s    


€
zEndingList.popc                 C   sL   t | jƒdkr	dS tt| jƒƒD ]\}}| |¡r|  S |js# dS qdS )z'Find the ending at the current positionr   N)r  r³   Ú	enumeraterÄ  r—  r¸  )r{  rÂ  rY  r  r   r   r   r½     s   
ÿzEndingList.findendingc                 C   s,   t | jƒdkrt dt| ƒ d ¡ dS dS )z&Check if there are any pending endingsr   zPending z
 left openN)r  r³   r   r   rÑ  r¾  r   r   r   r–  «  s   ÿzEndingList.checkpendingc                 C   sB   d}| j D ]
}|t|ƒd 7 }qt| j ƒdkr|dd… }|d S )úPrintable representationz	endings [rc  r   Nr   ré   )r³   rÑ  r  )r{  r·   r  r   r   r   rí  °  s   
zEndingList.__unicode__r   Nr¿  )r   r   r    r!   r|  r¶  rÃ  r—  rº  r½  r–  rí  r	   r   rï  r   r   r   r   rŠ  z  s    

	ÿrŠ  c                   @   ó:   e Zd ZdZdd„ Zdd„ Zdd„ ZejdkreZ	d	S d	S )
rÀ  z An ending for a parsing positionc                 C   s   || _ || _d S rx  ©r  r¸  r·  r   r   r   r|  À  ó   
zPositionEnding.__init__c                 C   ó   |  | j¡S )zCheck for the ending)r”  r  rÁ  r   r   r   r—  Ä  r¨  zPositionEnding.checkinc                 C   s   d| j  }| jr|d7 }|S )rÇ  zEnding z (optional)rÉ  rÉ  r   r   r   rí  È  s   
zPositionEnding.__unicode__r   N)
r   r   r    r!   r|  r—  rí  r	   r   rï  r   r   r   r   rÀ  ½  s    
ÿrÀ  c                   @   sn   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zejdk r-eZdd„ Zdd„ ZdS )ÚPositionz¡A position in a text to parse.
  Including those in Globable, functions to implement by subclasses are:
  skip(), identifier(), extract(), isout() and current().c                 C   s   t  | ¡ d S rx  )rˆ  r|  r¾  r   r   r   r|  Ø  r}  zPosition.__init__c                 C   r�  )zSkip a stringzUnimplemented skip()Nr‘  rÉ  r   r   r   r±  Û  ó   zPosition.skipc                 C   r�  )z.Return an identifier for the current position.zUnimplemented identifier()ÚErrorr‘  r¾  r   r   r   Ú
identifierß  r“  zPosition.identifierc                 C   s   	 t  d¡ dS )zHExtract the next string of the given length, or None if not enough text,zUnimplemented extract()Nr‘  ©r{  Úlengthr   r   r   r  ä  s   
zPosition.extractc                 C   s   ||   t|ƒ¡kS )z)Check for a string at the given position.)r  r  rÉ  r   r   r   r”  ê  r‡  zPosition.checkforc                 C   s0   |   t|ƒ¡}|sdS | ¡ |   t|ƒ¡ ¡ kS )z!Check for a string in lower case.F)r  r  Úlower)r{  r·   rn   r   r   r   Úcheckforlowerî  s   zPosition.checkforlowerc                 C   s   |   ¡ }|  |¡ |S )r˜  )r’  r±  ©r{  r’  r   r   r   rŽ  õ  s   
zPosition.skipcurrentc                 C   s   |   ¡  |  ¡ S )z3Advance the position and return the next character.)rŽ  r’  r¾  r   r   r   Ú__next__û  s   zPosition.__next__r   c                 C   s   |   |¡sdS |  |¡ dS )z;Check for a string at the given position; if there, skip itFT)r”  r±  rÉ  r   r   r   Ú	checkskip  s   

zPosition.checkskipc                 C   s   t  |d |  ¡  ¡ dS )z2Show an error message and the position identifier.r  N)r   r   rÏ  )r{  r   r   r   r   r   
  r  zPosition.errorN)r   r   r    r!   r|  r±  rÏ  r  r”  rÓ  rŽ  rÕ  r	   r   r[  rÖ  r   r   r   r   r   rÌ  Ó  s    
rÌ  c                   @   ó@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )ÚTextPositionz%A parse position based on a raw text.c                 C   s"   t  | ¡ d| _|| _|  ¡  dS )z*Create the position from elyxer.some text.r   N)rÌ  r|  rÂ  r  r�  ©r{  r  r   r   r   r|    s   
zTextPosition.__init__c                 C   s   |  j t|ƒ7  _ dS )úSkip a string of characters.N)rÂ  r  rÉ  r   r   r   r±    r>  zTextPosition.skipc                 C   sF   d}| j | t| jƒkrt| jƒ| j  }d| j| j | j | …  d S )z&Return a sample of the remaining text.é   rj  ©rÂ  r  r  rÐ  r   r   r   rÏ    s   zTextPosition.identifierc                 C   s   | j t| jƒkS )ú'Find out if we are out of the text yet.rÜ  r¾  r   r   r   r’  #  ó   zTextPosition.isoutc                 C   s   | j | j S )ú6Return the current character, assuming we are not out.)r  rÂ  r¾  r   r   r   r’  '  r¨  zTextPosition.currentc                 C   s.   | j | t| jƒkrdS | j| j | j | … S ©zHExtract the next string of the given length, or None if not enough text.NrÜ  rÐ  r   r   r   r  +  s   zTextPosition.extractN)
r   r   r    r!   r|  r±  rÏ  r’  r’  r  r   r   r   r   rØ    s    rØ  c                   @   óX   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )ÚFilePositionz-A parse position based on an underlying file.c                 C   s&   t  | ¡ t|ƒ| _d| _|  ¡  dS )z Create the position from a file.r   N)rÌ  r|  rd  r  rÂ  r�  r  r   r   r   r|  4  s   

zFilePosition.__init__c                 C   sn   t |ƒ}| j| t | j ¡ ƒkr.|t | j ¡ ƒ| j d 8 }|  ¡  | j| t | j ¡ ƒks|  j|7  _dS )rÚ  r•  N)r  rÂ  r  r	  r
  )r{  r·   rÑ  r   r   r   r±  ;  s   þzFilePosition.skipc                 C   ó
   | j  ¡ S )z,Get the current line of the underlying file.)r  r	  r¾  r   r   r   r	  C  r[  zFilePosition.currentlinec                 C   s   | j  ¡  d| _dS )zGo to the next line.r   N)r  r
  rÂ  r¾  r   r   r   r
  G  ó   

zFilePosition.nextlinec                 C   s   | j jd S )z#Return the line number of the file.r•  )r  r  r¾  r   r   r   r  L  r¨  zFilePosition.linenumberc                 C   sL   | j  ¡ d| jd … }| j  ¡ | jd… }dt|  ¡ ƒ d | d | S )z4Return the current line and line number in the file.Nr•  zline r  rj  )r  r	  rÂ  rÑ  Úgetlinenumber)r{  ÚbeforeÚafterr   r   r   rÏ  P  s    zFilePosition.identifierc                 C   s`   | j t| j ¡ ƒkr+| j t| j ¡ ƒd kr't d| j ¡  d t| j ƒ ¡ |  ¡  | j ¡ S )rÝ  r•  úOut of the line r  )	rÂ  r  r  r	  r   r   rÑ  r
  rz  r¾  r   r   r   r’  V  s
   "
zFilePosition.isoutc                 C   sb   | j t| j ¡ ƒkrdS | j t| j ¡ ƒkr)t d| j ¡  d t| j ƒ ¡ dS | j ¡ | j  S )rß  r   rè  r  rj  )rÂ  r  r  r	  r   r   rÑ  r¾  r   r   r   r’  ^  s   "zFilePosition.currentc                 C   s6   | j | t| j ¡ ƒkrdS | j ¡ | j | j | … S rà  )rÂ  r  r  r	  rÐ  r   r   r   r  g  s   zFilePosition.extractN)r   r   r    r!   r|  r±  r	  r
  r  rÏ  r’  r’  r  r   r   r   r   râ  1  s    	râ  c                   @   sÎ   e Zd ZdZdZdZdZdd„ Zdd„ Zdd„ Z	d	d
„ Z
ejfdd„Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd+d d!„Zd"d#„ Zd$d%„ Zd&d'„ Zd(d)„ Zejd*kreeZdS dS ),Ú	Containerz.A container for text and objects in a lyx fileNc                 C   r‰  rx  )r�  r  r¾  r   r   r   r|  v  rŒ  zContainer.__init__c                 C   r?  )úProcess contentsNr   r¾  r   r   r   rý  y  r$  zContainer.processc                 C   s4   | j  | ¡}t|tƒrt d| ¡ |g}|  |¡S )zGet the resulting HTMLzRaw string )r  r=  rŒ  r�  r   r   Ú	escapeall)r{  rÏ   r   r   r   r=  }  s
   

zContainer.gethtmlc                 C   sd   g }|D ]+}t jr|  |tj¡}t jr |  |tj¡}|  |¡}n
t js*|  |tj¡}| |¡ q|S )z=Escape all lines in an array according to the output options.)	r™  rÏ   Úescaper¹   rÐ   ÚescapeentitiesrÑ  rÑ   r‘  )r{  Úlinesrž  r  r   r   r   rë  …  s   zContainer.escapeallc                 C   s2   t | ¡ ƒ}|D ]}||v r| ||| ¡}q|S )z1Escape a line with replacements from elyxer.a map)ÚsortedÚkeysr‰  )r{  r  ÚreplacementsÚpiecesÚpiecer   r   r   rì  “  s   €zContainer.escapec                 C   sŠ   d}t |ƒ}| ¡ sCt| ¡ ƒdkr5tt| ¡ ƒƒ}|dkr(ttt|ƒƒd ƒ}|d|dd…  d 7 }n|| ¡ 7 }| ¡  | ¡ r
|S )	z/Escape all Unicode characters to HTML entities.r+   é€   Ú0xd835i ø  z&#r•  Nrv  )rØ  rz  r�  r’  Úhexr[  rŽ  )r{  r  rž  rÂ  Ú	codepointr   r   r   rí  œ  s   ø	zContainer.escapeentitiesc                    s   g ‰ |   |‡ fdd„¡ ˆ S )z2Search for all embedded containers of a given typec                    s
   ˆ   | ¡S rx  )r‘  ©r  ©r�  r   r   rû  ®  ó   
 z%Container.searchall.<locals>.<lambda>)Úsearchprocess©r{  rö  r   rù  r   Ú	searchall«  s   zContainer.searchallc                 C   s&   |   |¡}|D ]	}|jj |¡ q|S )z3Search for all containers of a type and remove them)rý  r  r  r,  )r{  rö  r�  r  r   r   r   Úsearchremove±  s   
zContainer.searchremovec                    s   |   ‡ fdd„|¡ dS )z4Search for elements of a given type and process themc                    s
   t | ˆ ƒS rx  )rŒ  rø  ©rö  r   r   rû  º  rú  z)Container.searchprocess.<locals>.<lambda>N)Úlocateprocess)r{  rö  rý  r   rÿ  r   rû  ¸  rî  zContainer.searchprocessc                 C   s,   | j D ]}| ||¡ ||ƒr||ƒ qdS )z3Search for all embedded containers and process themN)r  r   )r{  r  rý  r  r   r   r   r   ¼  s   
€ýzContainer.locateprocessc                 C   s6   | j D ]}||ƒr| |||¡ ||ƒr||ƒ qdS )z,Perform a recursive search in the container.N)r  r   )r{  r  r  rý  r  r   r   r   r   Ã  s   
€üzContainer.recursivesearchc                 C   s,   d}t tjƒ | ¡}|D ]}||j7 }q|S )z0Extract all text from elyxer.allowed containers.r+   )rø  r;   r´   r  r·   )r{  rž  rï  Úconstantr   r   r   r´   Ë  s
   zContainer.extracttextc                 C   sš   |t | jƒkr	dS t| j| dƒrdS |t | jƒk rD|| j| ƒrDd| j| _|j | j| ¡ | j |¡ |t | jƒk rD|| j| ƒs!| j ||¡ dS )z*Group some adjoining elements into a groupNÚgroupedT)r  r  rŠ  r  r‘  rº  r˜  )r{  rY  rM  Ú	isingroupr   r   r   rM  Ó  s   ýzContainer.groupc                 C   sN   | j | }| j  |¡ t|j ƒdkr%| j  ||j  ¡ ¡ t|j ƒdksdS dS )z)Remove a container but leave its contentsr   N)r  rº  r  r˜  )r{  rY  r  r   r   r   r,  ß  s
   
ÿzContainer.remover   c                 C   s4   t  d| t| ƒ ¡ | jD ]	}| |d ¡ qdS )zShow in a treer#  r•  N)r   r   rÑ  r  Útree)r{  Úlevelr  r   r   r   r  æ  s   
ÿzContainer.treec                 C   ó   || j vrdS | j | S )z)Get the value of a parameter, if present.N)rÚ  rç  r   r   r   Úgetparameterì  ó   

zContainer.getparameterc                 C   s   |   |¡}|s	g S | d¡S )z7Get the value of a comma-separated parameter as a list.rc  )r  r—  )r{  ræ  Ú	paramtextr   r   r   Úgetparameterlistò  s   

zContainer.getparameterlistc                 C   s&   | j }|r|j ¡ rdS |j }|sdS )z&Check if the parent's output is empty.TF)r  r  r@  rÔ  r   r   r   Úhasemptyoutputù  s   
ýzContainer.hasemptyoutputc                 C   s$   | j s| jjS | jjd t| j ƒ S )zGet a descriptionrf  )rß   rò  r   rÑ  r¾  r   r   r   rí  	  s   zContainer.__unicode__r   )r   )r   r   r    r!   Úpartkeyr  rß   r|  rý  r=  rë  r¹   rÎ   rì  rí  rý  rþ  rû  r   r   r´   rM  r,  r  r  r
  r  rí  r	   r   rï  r   r   r   r   ré  o  s6    	
	
ÿré  c                   @   r  )rq   z)A container that does not output anythingc                 C   s   t ƒ | _tƒ | _g | _d S rx  )r   r�  rB  r  r  r¾  r   r   r   r|  	  ó   
zBlackBox.__init__N©r   r   r    r!   r|  r   r   r   r   rq   	  r&  rq   c                   @   r  )r©   zRead the lyxformat commandc                 C   sT   t | jd ƒ}|dk rt dt|ƒ ¡ |t tjd ƒkr(t dt|ƒ ¡ dS dS )zShow warning if version < 276r•  i  z(Warning: unsupported old format version r’  z(Warning: unsupported new format version N)rª  r  r   r   Ústrr�  r”  )r{  r”  r   r   r   rý  	  s   ÿzLyXFormat.processN©r   r   r    r!   rý  r   r   r   r   r©   	  r&  r©   c                   @   sV   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z	dd„ Z
ejdkr)e
ZdS dS )rT   zA container for a single stringNc                 C   s   t ƒ | _tƒ | _d| _d S )Nr+   )r5  r�  r`  r  r·   r¾  r   r   r   r|  $	  r  zStringContainer.__init__c                 C   s"   | j r|  | j ¡| _d| _ dS dS )z/Replace special chars from elyxer.the contents.N)ÚparsedÚreplacespecialr·   r¾  r   r   r   rý  )	  s   
þzStringContainer.processc                 C   sf   |   |tj¡}|  |¡}tjd |v r1t|ƒdkr1| jr&dt| jƒ d }nd}t	 
|| ¡  ¡ |S )z,Replace all special chars from elyxer.a liner°   r•  zUnknown command at r  zUnknown command: )rì  r¹   rÎ   Ú
changeliner;   r·   r  rß   rÑ  r   r   r  )r{  r  r:   r   r   r   r   r  /	  s   
zStringContainer.replacespecialc                 C   s2   |   |tj¡}tjd |vr|S |   |tj¡}|S )Nr°   )rì  r¹   rÌ   r;   r·   rÍ   r…  r   r   r   r  <	  s
   zStringContainer.changelinec                 C   ó   | j S )zReturn all text.ra  r¾  r   r   r   r´   C	  rE  zStringContainer.extracttextc                 C   sX   d}| j r|dt| j ƒ 7 }d}t| j ¡ ƒdkrd}|d | j ¡ dd…  | d S )	ú"Return a printable representation.rT   rf  z...é   r+   rÈ  Nrç   )rß   rÑ  r  r·   r  )r{  rž  Úellipsisr   r   r   rí  G	  s   "zStringContainer.__unicode__r   )r   r   r    r!   r  r|  rý  r  r  r´   rí  r	   r   rï  r   r   r   r   rT   	  s    

ÿrT   c                   @   ó2   e Zd ZdZdd„ Zdd„ ZejdkreZdS dS )rU   zA constant stringc                 C   s   g | _ || _tƒ | _d S rx  )r  r·   r`  r  rÙ  r   r   r   r|  X	  s   zConstant.__init__c                 C   ó
   d| j  S )Nz
Constant: ra  r¾  r   r   r   rí  ]	  r}  zConstant.__unicode__r   N©	r   r   r    r!   r|  rí  r	   r   rï  r   r   r   r   rU   U	  s    
ÿrU   c                   @   sJ   e Zd ZdZdZdd„ Zddd„Zddd	„Zd
d„ Ze	j
dkr#eZdS dS )rX   zText inside a tagNc                 C   s   t | ƒ| _tƒ | _d S rx  )r'  r�  rJ  r  r¾  r   r   r   r|  i	  s   
zTaggedText.__init__Fc                 C   s   || _ || j_|| j_| S )z&Complete the tagged text and return it)r  r  rK  rL  ©r{  r  rK  rL  r   r   r   Úcompletem	  s   zTaggedText.completec                 C   s   t |ƒ}|  |g||¡S )z(Complete the tagged text with a constant)rU   r  )r{  r  rK  rL  r  r   r   r   r  t	  ó   zTaggedText.constantc                 C   s,   t | jdƒsdS | jjsdS d| jj d S )r  rK  zEmtpy tagged textzTagged <unknown tag>zTagged <rÇ   )rŠ  r  rK  r¾  r   r   r   rí  y	  s
   zTaggedText.__unicode__r   r¿  )r   r   r    r!   r  r|  r  r  rí  r	   r   rï  r   r   r   r   rX   d	  s    


ÿrX   c                   @   s4   e Zd ZdZdZdZdZdZdZdZ	dZ
dZdZdS )ÚDocumentParametersz#Global parameters for the document.NFé
   r   )r   r   r    r!   rŸ  Úindentstandardr¡  ÚstartinglevelÚmaxdepthr›  rU  r�  Údisplaymoder   r   r   r   r  …	  s    r  c                   @   r×  )ÚFormulaParserzParses a formulac                 C   sR   |j d | _|  |¡}|s&| ¡  |  |¡}|s&t d| ¡  ¡  ¡ dgS |gS )úSee if the formula is inlinedr•  zUnknown formula type in Úunknown)r  rß   Ú	parsetyper
  r   r   r	  r  )r{  r  rö  r   r   r   r  š	  s   

zFormulaParser.parseheaderc                 C   st   |  ¡  tjd ¡dkrdS |  ¡  tjd ¡dkrdS |  ¡  tjd ¡dkr*dS |  ¡  tjd ¡dkr8dS d	S )
z)Get the formula type from the first line.ro  r   Úinliner7  Úblockrp  rl  ÚnumberedN)r	  ÚfindrÒ   r¶   r"  r   r   r   r'  ¦	  s   zFormulaParser.parsetypec                 C   sd   |   |¡}| ¡  | j¡s,| ¡  ¡ }t|ƒdkr t d| ¡ | ¡  | ¡  | j¡r| ¡  |S )úParse the formula until the endr   zUnparsed formula line )	Úparseformular	  r€  r  r  r  r   r   r
  )r{  r  ÚformulaÚstrippedr   r   r   r#  ²	  s   
üzFormulaParser.parsec                 C   s’  t jd }|| ¡ v r'| ¡  |d¡d }||v r |  |||¡S |  |||¡S t jd | ¡ v r=|  |t jd t jd ¡S t jd }t jd }|| ¡ v rš| ¡  ¡  |¡r‹| ¡  ¡ }| |¡d  |¡}||d  | }t jd }	t jd }
|	|d  |
 }||  |||¡ | S t	 
d	| d
 | ¡  ¡ dS t jd }t jd }|| ¡ v r¼|| ¡ v r¼t jd }|  |||¡S t	 
d| ¡  d ¡ dS )zParse the formula contentsro  r•  r7  rl  rk  r   r9  r8  zMissing r€  r+   rm  r6  zFormula beginning z is unknown)rÒ   r¶   r	  r—  ÚparsesinglelinerÚparsemultilinerr³   r  r–  r   r   )r{  r  ro  Úrestrl  rk  r’  ÚendsplitÚ
startpiecer9  r8  ÚendpieceÚbegincommandÚbeginbracketÚ
endbracketr   r   r   r-  ½	  s<   
ÿ






zFormulaParser.parseformulac                 C   s‚   |  ¡  ¡ }||vrt d| d | ¡ dS | |¡s)t d| d | ¡ dS | |¡}||t|ƒ t|ƒ … }| ¡  |S )zParse a formula in one lineru  ú  does not contain formula start r+   zFormula z does not end with )r	  r  r   r   r–  rY  r  r
  )r{  r  Ústartr  r  rY  r2  r   r   r   r0  à	  s   

zFormulaParser.parsesinglelinerc                 C   s¦   d}|  ¡ }||vrt d| ¡  d | ¡ dS | |¡}||t|ƒ d…  ¡ }| |¡sB||d 7 }| ¡  |  ¡ }| |¡r/||dt|ƒ … 7 }| ¡  |S )z!Parse a formula in multiple linesr+   ru  r9  Nr   )r	  r   r   r  rY  r  r–  r
  )r{  r  r:  r  r.  r  rY  r   r   r   r1  î	  s   


ýzFormulaParser.parsemultilinerN)
r   r   r    r!   r  r'  r#  r-  r0  r1  r   r   r   r   r$  —	  s    #r$  c                   @   r4  )ÚMacroParserzA parser for a formula macro.c                 C   s   |j d | _dgS )r%  r•  r(  r6  r"  r   r   r   r  
  s   zMacroParser.parseheaderc                 C   s    |   || jj| j¡}| ¡  |S )r,  )r1  r  r:  r  r
  )r{  r  r.  r   r   r   r#  
  s   zMacroParser.parseNr7  r   r   r   r   r;  ÿ	  r8  r;  c                   @   sf   e Zd ZdZdZdZdZdd„ Zdd„ Zd	d
„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zejdkr1eZdS dS )Ú
FormulaBitzA bit of a formulaNr•  r+   c                 C   s   g | _ tƒ | _dS )z6The formula bit type can be 'alpha', 'number', 'font'.N)r  rG  r  r¾  r   r   r   r|  
  ó   zFormulaBit.__init__c                 C   rO  )z!Set the internal formula factory.)r  )r{  r  r   r   r   Ú
setfactory
  rQ  zFormulaBit.setfactoryc                 C   s&   | j  |¡ |  j|j7  _| |_dS )z-Add any kind of formula bit already processedN)r  r‘  ró  r  ©r{  Úbitr   r   r   r¶  
  s   
zFormulaBit.addc                 C   s:   |  j |7  _ | |¡st d| d | ¡  ¡ dS dS )z0Skip a string and add it to the original formulazString z not at N)ró  rÖ  r   r   rÏ  )r{  r·   rÂ  r   r   r   Úskiporiginal%
  s   
ÿzFormulaBit.skiporiginalc                 C   s.   t | jƒdkr	dS tdd„ | jD ƒƒ| _| jS )zDCompute the size of the bit as the max of the sizes of all contents.r   r•  c                 S   ó   g | ]}|j ‘qS r   ©r*  ©Ú.0rI  r   r   r   Ú
<listcomp>/
  ó    z*FormulaBit.computesize.<locals>.<listcomp>)r  r  r  r*  r¾  r   r   r   Úcomputesize+
  s   zFormulaBit.computesizec                 C   s   | j  | j¡S ©zReturn a copy of itself.)r  r-  ró  r¾  r   r   r   rô  2
  rÍ  zFormulaBit.clonec                 C   s   | j jd | j S )zGet a string representationz	 read in )rò  r   ró  r¾  r   r   r   rí  6
  r‡  zFormulaBit.__unicode__r   )r   r   r    r!   rö  r*  ró  r|  r>  r¶  rA  rH  rô  rí  r	   r   rï  r   r   r   r   r<  
  s    
ÿr<  c                   @   s*   e Zd ZdZdd„ Zd
dd„Zdd„ Zd	S )Ú	TaggedBitzA tagged string in a formulac                 C   s    t ƒ  |¡| _|  t|ƒ¡ | S ©zSet the constant and the tag)rJ  rN  r  r¶  rV   )r{  r  rK  r   r   r   r  A
  s   zTaggedBit.constantFc                 C   s   || _ tƒ  ||¡| _| S rK  )r  rJ  rN  r  r  r   r   r   r  G
  s   zTaggedBit.completec                 C   s   t ƒ j|dd�| _| S )z4Set the self-closing tag, no contents (as in <hr/>).T)rM  )rJ  rN  r  ©r{  rK  r   r   r   ÚselfcompleteM
  s   zTaggedBit.selfcompleteNr¿  )r   r   r    r!   r  r  rM  r   r   r   r   rJ  >
  s
    
rJ  c                   @   rã  )rV   zA constant string in a formulac                 C   s"   t  | |¡ || _d| _d| _dS )zSet the constant stringr•  N)rU   r|  ró  r*  rö  rÉ  r   r   r   r|  U
  s   
zFormulaConstant.__init__c                 C   r  )z+Compute the size of the constant: always 1.rC  r¾  r   r   r   rH  \
  rE  zFormulaConstant.computesizec                 C   ó
   t | jƒS rI  )rV   ró  r¾  r   r   r   rô  `
  r[  zFormulaConstant.clonec                 C   r  )r  zFormula constant: ra  r¾  r   r   r   rí  d
  r[  zFormulaConstant.__unicode__r   N)r   r   r    r!   r|  rH  rô  rí  r	   r   rï  r   r   r   r   rV   R
  s    
ÿrV   c                   @   r4  )r]   zA bit of text inside a formulac                 C   ó   |  ¡  ¡ S )zDetect a bit of raw textr�  rÁ  r   r   r   Údetecto
  r¨  zRawText.detectc                 C   s    |  ¡ }|  t|ƒ¡ d| _dS )zParse alphabetic textr0   N)r   r¶  rV   rö  )r{  rÂ  r0   r   r   r   Úparsebits
  s   
zRawText.parsebitN©r   r   r    r!   rP  rQ  r   r   r   r   r]   l
  rA  r]   c                   @   s8   e Zd ZdZejZejd Zdd„ Zdd„ Zdd„ Z	d	S )
rh   zA symbol inside a formulars  c                 C   s(   |  ¡ tjv r	dS |  ¡ tjv rdS dS )zDetect a symbolTF)r’  rh   r�  rˆ  rÁ  r   r   r   rP  
  s
   zFormulaSymbol.detectc                 C   sd   |  ¡ tjv r|  |  ¡ |¡ dS |  ¡ tjv r%|  tj|  ¡  |¡ dS t d|  ¡  d ¡ dS )úParse the symbolNzSymbol ú
 not found)r’  rh   r�  Ú	addsymbolrˆ  r   r   rÁ  r   r   r   rQ  ‡
  s   zFormulaSymbol.parsebitc                 C   s$   |   | ¡ |¡ | j t|ƒ¡ dS )zAdd a symbolN)rA  r’  r  r‘  rV   )r{  ÚsymbolrÂ  r   r   r   rU  ‘
  s   zFormulaSymbol.addsymbolN)
r   r   r    r!   rÒ   rˆ  r�  rP  rQ  rU  r   r   r   r   rh   y
  s    

rh   c                   @   r4  )r_   zA string of digits in a formulac                 C   rO  )zDetect a digitr¡  rÁ  r   r   r   rP  ™
  r¨  zFormulaNumber.detectc                    s*   ˆ   ‡ fdd„¡}|  t|ƒ¡ d| _dS )zParse a bunch of digitsc                      rœ  rx  r¡  r   ©rÂ  r   r   rû  Ÿ
  rÿ  z(FormulaNumber.parsebit.<locals>.<lambda>r“  N)rš  r¶  rV   rö  )r{  rÂ  Údigitsr   rW  r   rQ  �
  s   
zFormulaNumber.parsebitNrR  r   r   r   r   r_   –
  rA  r_   c                   @   s*   e Zd ZdZejd Zdd„ Zdd„ ZdS )rC  z*A LaTeX comment: % to the end of the line.rn  c                 C   s   |  ¡ | jkS )zDetect the %.)r’  r:  rÁ  r   r   r   rP  ¨
  rÍ  zComment.detectc                 C   s   |  j | d¡7  _ dS )zParse to the end of the line.r   N)ró  r²  rÁ  r   r   r   rQ  ¬
  rî  zComment.parsebitN)	r   r   r    r!   rÒ   r¶   r:  rP  rQ  r   r   r   r   rC  £
  s
    
rC  c                   @   rÈ  )
Ú
WhiteSpacez"Some white space inside a formula.c                 C   rO  )zDetect the white space.r©  rÁ  r   r   r   rP  ³
  r¨  zWhiteSpace.detectc                 C   s   |  j | ¡ 7  _ dS )zParse all whitespace.N)ró  r­  rÁ  r   r   r   rQ  ·
  r>  zWhiteSpace.parsebitc                 C   s   d| j  d S )r  zWhitespace: *rj  )ró  r¾  r   r   r   rí  »
  rÍ  zWhiteSpace.__unicode__r   N)
r   r   r    r!   rP  rQ  rí  r	   r   rï  r   r   r   r   rY  °
  s    
ÿrY  c                   @   sl   e Zd ZdZejd Zejd Zdd„ Z	dd„ Z
dd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r\   zA {} bracket inside a formular6  c                 C   s   t  | ¡ d| _dS )z'Create a (possibly literal) new bracketN)r<  r|  Úinnerr¾  r   r   r   r|  É
  rä  zBracket.__init__c                 C   rË  )zDetect the start of a bracket)r”  r:  rÁ  r   r   r   rP  Î
  r¨  zBracket.detectc                 C   ó   |   || j¡ | S )zParse the bracket)ÚparsecompleteÚinnerformularÁ  r   r   r   rQ  Ò
  ó   zBracket.parsebitc                 C   r[  )zParse a text bracket)r\  Ú	innertextrÁ  r   r   r   Ú	parsetext×
  r^  zBracket.parsetextc                 C   r[  )zParse a literal bracket)r\  ÚinnerliteralrÁ  r   r   r   ÚparseliteralÜ
  r^  zBracket.parseliteralc                 C   sp   |  | j¡st d| j d | ¡  ¡ dS |  | j|¡ | | j¡ ||ƒ |  j| 	| j¡7  _|  
¡  dS )zParse the start and end markszBracket should start with z at N)r”  r:  r   r   rÏ  rA  r¹  r  ró  r¼  rH  )r{  rÂ  Úinnerparserr   r   r   r\  á
  s   zBracket.parsecompletec                 C   ó*   |  ¡ s|  | j |¡¡ |  ¡ rdS dS )z(Parse a whole formula inside the bracketN©rz  r¶  r  ÚparseanyrÁ  r   r   r   r]  ì
  ó   ÿzBracket.innerformulac                 C   sœ   t tj ¡ ƒ}| tjd ¡ | tjd ¡ | tj¡ | ¡ sL| 	¡ |v r=|  
| j |¡¡ | d¡r<|  jd7  _n	|  
t| ¡ ƒ¡ | ¡ r!dS dS )z<Parse some text inside the bracket, following textual rules.rm  r6  rö   N)r�  rÒ   r‹  rð  r‘  r¶   rC  r:  rz  r’  r¶  r  rf  rÖ  ró  rV   rŽ  )r{  rÂ  Úspecialcharsr   r   r   r_  ñ
  s   
€úzBracket.innertextc                 C   sr   d| _ | ¡ s/| ¡ | jks/| ¡ | jkr|  |¡ n	|  j | ¡ 7  _ | ¡ s/| ¡ | jkr|  j| j 7  _dS )zAParse a literal inside the bracket, which does not generate HTML.r+   N)Úliteralrz  r’  r  r:  rb  rŽ  ró  rÁ  r   r   r   ra  ÿ
  s   üzBracket.innerliteralN)r   r   r    r!   rÒ   r¶   r:  r³   r  r|  rP  rQ  r`  rb  r\  r]  r_  ra  r   r   r   r   r\   Ã
  s    

r\   c                   @   s,   e Zd ZdZejd Zejd Zdd„ Z	dS )ÚSquareBracketzA [] bracket inside a formular:  c                 C   s   t ƒ }| j|_|S )z3Return a new square bracket with the same contents.)rj  r  )r{  r6  r   r   r   rô    s   zSquareBracket.cloneN)
r   r   r    r!   rÒ   r¶   r:  r³   r  rô  r   r   r   r   rj  	  s
    

rj  c                   @   r  )ÚMathsProcessorzAA processor for a maths construction inside the FormulaProcessor.c                 C   r;  )z$Process an element inside a formula.zUnimplemented process() in Nr<  ©r{  r  rY  r   r   r   rý    r>  zMathsProcessor.processc                 C   s   d| j j S )zReturn a printable description.zMaths processor )rò  r   r¾  r   r   r   rí    r¨  zMathsProcessor.__unicode__r   N)	r   r   r    r!   rý  rí  r	   r   rï  r   r   r   r   rk    ó    
ÿrk  c                   @   sD   e Zd ZdZg Zdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Z	dd„ Z
dS )ÚFormulaProcessorz&A processor specifically for formulas.c                 C   s"   |   |¡ |  |¡ |  |¡ dS )z7Process the contents of every formula bit, recursively.N)ÚprocesscontentsÚprocessinsidesÚtraversewholer?  r   r   r   rý  *  s   

zFormulaProcessor.processc                 C   s0   t |tƒsdS | ¡  |jD ]}|  |¡ qdS )z&Process the contents of a formula bit.N)rŒ  r<  rý  r  ro  )r{  r@  rI  r   r   r   ro  0  s   

ÿz FormulaProcessor.processcontentsc                 C   sJ   t |tƒsdS t|jƒD ]\}}| jD ]	}| |j|¡ q|  |¡ qdS )z8Process the insides (limits, brackets) in a formula bit.N)rŒ  r<  rÆ  r  Ú
processorsrý  rp  )r{  r@  rY  rI  Ú	processorr   r   r   rp  8  s   

üzFormulaProcessor.processinsidesc                 C   sb   d}|   |¡D ]'\}}|jdkr|  ||¡ n|jdkr,|r,|jdkr,|j dtdƒ¡ |}qdS )z>Traverse over the contents to alter variables and space units.Nr0   Úfontr“  r   rÊ   )Útraverserö  Ú	italicizer  r˜  rV   )r{  r.  Úlastr@  r  r   r   r   rq  B  s   
ûzFormulaProcessor.traversewholec                 c   sP   � |j D ]!}t|dƒr|jr||j fV  qt|tƒr%|  |¡D ]}|V  qqdS )zHTraverse a formula and yield a flattened structure of (bit, list) pairs.rö  N)r  rŠ  rö  rŒ  r<  ru  )r{  r@  rI  Úpairr   r   r   ru  L  s   €

€ûzFormulaProcessor.traversec                 C   s"   |  |¡}tƒ  |gd¡||< dS )z Italicize the given bit of text.rB  N)rY  rJ  r  )r{  r@  r  rY  r   r   r   rv  U  s   
zFormulaProcessor.italicizeN)r   r   r    r!   rr  rý  ro  rp  rq  ru  rv  r   r   r   r   rn  %  s    

	rn  c                   @   s’   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZejdkrGeZdS dS ) r[   zA LaTeX formulac                 C   ó   t ƒ | _tƒ  d¡| _d S )Nzspan class="formula")r$  r�  rJ  rN  r  r¾  r   r   r   r|  `  ó   zFormula.__init__c                 C   sl   | j d dkrdt_n
dt_| j dd¡ tjr|  ¡  dS tjr'|  ¡  dS tjr0|  ¡  dS |  	¡  dS )zConvert the formula to tagsr   r(  FTzdiv class="formula"N)
r  r  r#  r  rN  r™  r·  rÙ  rx  Úclassicr¾  r   r   r   rý  d  s   zFormula.processc                 C   s>   | j d dkrtƒ  d¡| _ntƒ  d¡| _t| jƒg| _dS )zMake the contents for jsMath.r   r(  zdiv class="math"zspan class="math"N)r  rJ  rN  r  rU   r  r  r¾  r   r   r   r·  t  s   zFormula.jsmathc                 C   s@   d| j _d}| jd dkr|d7 }tƒ  | j|d d¡g| _dS )	zMake the contents for MathJax.zspan class="MathJax_Preview"zscript type="math/texr   r(  z;mode=displayrw  TN)r  rK  r  rX   r  r  r  rL  r   r   r   rÙ  |  s
   zFormula.mathjaxc                 C   s:   t jd t| jƒ }d| d | j d }t|ƒg| _dS )zIMake the contents using Google Charts http://code.google.com/apis/chart/.rx  z<img class="chart" src="z" alt="z"/>N)rÒ   rŽ  r   r  rU   r  )r{  ÚurlÚimgr   r   r   rx  „  s   zFormula.googlechartsc                 C   s,   t ƒ  | j¡}tƒ  |¡ | |_|g| _dS )zEMake the contents using classic output generation with XHTML and CSS.N)ÚFormulaFactoryr-  r  rn  rý  r  r  )r{  Úwholer   r   r   r{  Š  s   zFormula.classicc                 C   sr   |  d¡r|  |¡ n(|  d¡r|  |¡ n|  d¡r"|  |d¡ n|  d¡r.|  |d¡ n| d¡ |  ¡  | S )z4Parse using a parse position instead of self.parser.z$$rô   z\(z\)ri  r5  zUnparseable formula)rÖ  ÚparsedollarblockÚparsedollarinlineÚparseinlinetoÚparseblocktor   rý  rÁ  r   r   r   r#  ‘  s   




zFormula.parsec                 C   s   dg| _ |  |¡ dS )zParse a $...$ formula.r(  N)r  ÚparsedollarrÁ  r   r   r   r�     s   zFormula.parsedollarinlinec                 C   s.   dg| _ |  |¡ | d¡s| d¡ dS dS )zParse a $$...$$ formula.r)  rô   z1Formula should be $$...$$, but last $ is missing.N)r  r„  rÖ  r   rÁ  r   r   r   r€  ¥  s
   

ÿzFormula.parsedollarblockc                 C   s$   |  d¡ | d¡| _| d¡ dS )zParse to the next $.rô   N)r¹  rµ  r  r¼  rÁ  r   r   r   r„  ¬  s   
zFormula.parsedollarc                 C   ó   dg| _ |  ||¡ dS )zParse a \(...\) formula.r(  N©r  Ú	parseupto©r{  rÂ  Úlimitr   r   r   r‚  ²  r  zFormula.parseinlinetoc                 C   r…  )zParse a \[...\] formula.r)  Nr†  rˆ  r   r   r   rƒ  ·  r  zFormula.parseblocktoc                 C   s(   |  |¡ | dd„ ¡| _| |¡ dS )z1Parse a formula that ends with the given command.c                   S   r?  ©NTr   r   r   r   r   rû  ¿  s    z#Formula.parseupto.<locals>.<lambda>N)r¹  rš  r  r¼  rˆ  r   r   r   r‡  ¼  s   
zFormula.parseuptoc                 C   s"   | j r| j jrd| j j d S dS )r  z	Formula (rç   zUnnumbered formula)r  r“  r¾  r   r   r   rí  Â  s   zFormula.__unicode__r   N)r   r   r    r!   r|  rý  r·  rÙ  rx  r{  r#  r�  r€  r„  r‚  rƒ  r‡  rí  r	   r   rï  r   r   r   r   r[   ]  s&    
ÿr[   c                   @   r4  )ÚWholeFormulazParse a whole formulac                 C   s
   |  ¡  S )z"Not outside the formula is enough.)rz  rÁ  r   r   r   rP  Ï  r[  zWholeFormula.detectc                 C   rd  )zParse with any formula bitNre  rÁ  r   r   r   rQ  Ó  rg  zWholeFormula.parsebitNrR  r   r   r   r   r‹  Ì  rA  r‹  c                   @   st   e Zd ZdZeeeeee	gZ
ee	gZdZdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )r~  zConstruct bits of formulaFc                 C   s   t ƒ | _dS )z Initialize the map of instances.N)rá  Ú	instancesr¾  r   r   r   r|  à  r¨  zFormulaFactory.__init__c                 C   s   |  ¡ rdS |  |¡ |¡S )zDetect a bit of a given type.F)rz  rÍ  rP  )r{  rö  rÂ  r   r   r   Ú
detecttypeä  s   zFormulaFactory.detecttypec                 C   s.   || j vs
| j | s|  |¡| j |< | j | S )z"Get an instance of the given type.)rŒ  rñ  rü  r   r   r   rÍ  ê  s   
zFormulaFactory.instancec                 C   s   t  |¡ | ¡S )z+Create a new formula bit of the given type.)rð  rñ  r>  rü  r   r   r   rñ  ð  rÞ  zFormulaFactory.createc                 C   s"   |  ¡ s|  |¡sdS |  ¡ rdS )zClear any skipped types.N)rz  ÚskipanyrÁ  r   r   r   Úclearskippedô  s
   
þzFormulaFactory.clearskippedc                 C   s0   | j D ]}|  |¡ |¡r|  ||¡  S qdS )zSkip any skipped types.N)ÚskippedtypesrÍ  rP  r'  ©r{  rÂ  rö  r   r   r   rŽ  û  s
   
ÿzFormulaFactory.skipanyc                 C   sL   | j | j D ]}|  ||¡r|  ||¡  S qt d| ¡  ¡ t| ¡ ƒS )z.Parse any formula bit at the current location.zUnrecognized formula at )	Útypesr�  r�  r'  r   r   rÏ  rV   rŽ  r‘  r   r   r   rf    s   ÿzFormulaFactory.parseanyc                 C   s0   |   |¡}d| j|< | |¡}|r| | ¡S |S )z#Parse the given type and return it.N)rÍ  rŒ  rQ  r>  )r{  rö  rÂ  r@  Úreturnedbitr   r   r   r'  
  s   



zFormulaFactory.parsetypec                 C   s\   t |ƒ}|  t¡}| |¡r| |¡ |S | ¡ s,t d| ¡  ¡ | 	t
ƒ  |d¡¡ |S )z5Parse a string of text that contains a whole formula.zUnknown formula at: úspan class="unknown")rØ  rñ  r‹  rP  rQ  rz  r   r   rÏ  r¶  rJ  r  )r{  r.  rÂ  r  r   r   r   r-    s   


zFormulaFactory.parseformulaN)r   r   r    r!   rh   r]   r_   r\   rC  rY  r’  r�  Údefiningr|  r�  rÍ  rñ  r�  rŽ  rf  r'  r-  r   r   r   r   r~  Ø  s    	r~  c                   @   sF   e Zd ZdZ	 dZdd„ ZeeƒZdd„ Zdd„ Zd	d
„ Z	dd„ Z
dS )Ú
Translatorz=Reads the configuration file and tries to find a translation.Nc                 C   s   | j  |¡S )z%Get the translated message for a key.)rÍ  Ú
getmessage)r   r„  r   r   r   Ú	translate'  r¨  zTranslator.translatec                 C   s   d | _ d| _d S rŠ  )ÚtranslationÚfirstr¾  r   r   r   r|  -  rÊ  zTranslator.__init__c                 C   sš   d| _ tjst d¡ dS tjtjvrt dtj ¡ dS tjtj dkr'dS tjtj g}zt dd|¡| _W dS  t	yL   t dt
|ƒ ¡ Y dS w )z/Find the translation for the document language.NzNo language in documentzUnknown language rg  ÚelyxerzNo translation for )Ú	langcodesr  r›  r   r   rR  rv  Úgettextr™  ÚIOErrorrÑ  )r{  rœ  r   r   r   Úfindtranslation1  s   
ÿzTranslator.findtranslationc                 C   sP   | j r
|  ¡  d| _ |  |¡}| js|S z	| j |¡}W |S  ty'   Y |S w )z-Get the translated message for the given key.F)rš  rŸ  Úgetuntranslatedr™  Úugettextrž  )r{  r„  r   r   r   r   r—  B  s   
þþzTranslator.getmessagec                 C   s&   |t jvrt d| ¡ |S t j| S )zGet the untranslated message.zCannot translate )rR  rï  r   r   ©r{  r„  r   r   r   r   P  s   

zTranslator.getuntranslated)r   r   r    r!   rÍ  r˜  r"   r|  rŸ  r—  r   r   r   r   r   r–  !  s    r–  c                   @   sª   e Zd ZdZ	 dZdZdZdZdZe	j
d Zg d¢Zdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZejdkrSeZdS dS )ÚNumberCounterz#A counter for numbers (by default).NÚABCDEFGHIJKLMNOPQRSTUVWXYZrú  ))ÚMrv  )ÚCMi„  )ÚDiô  )ÚCDi�  )ÚCéd   )ÚXCéZ   )ÚLé2   )ÚXLé(   )ÚXr  )ÚIXé	   )ÚVé   )ÚIVé   )ÚIr•  c                 C   rs  )zGive a name to the counter.N)ræ  rç  r   r   r   r|  l  r[  zNumberCounter.__init__c                 C   rO  )z0Set the counter mode. Can be changed at runtime.)r   )r{  r   r   r   r   Úsetmodep  rQ  zNumberCounter.setmodec                 C   rs  )zSet an initial value.N©r…  ©r{  r…  r   r   r   Úinitu  r[  zNumberCounter.initc                 C   rN  )z$Get the next value as a text string.)rÑ  r…  r¾  r   r   r   r�  y  r[  zNumberCounter.gettextc                 C   r¦  )zGet the next value as a letter.)ÚgetsequenceÚlettersr¾  r   r   r   Ú	getletter}  r¨  zNumberCounter.getletterc                 C   r¦  )zGet the next value as a symbol.)r½  rú  r¾  r   r   r   Ú	getsymbol�  r¨  zNumberCounter.getsymbolc                 C   s   || j d t|ƒ  S )z*Get the next value from elyxer.a sequence.r•  )r…  r  )r{  rü  r   r   r   r½  …  r>  zNumberCounter.getsequencec                 C   s>   d}| j }| jD ]\}}||kr||||  7 }|| }q|S )z%Get the next value as a roman number.r+   )r…  Úromannumerals)r{  rž  r“  Únumeralr…  r   r   r   Úgetroman‰  s   €zNumberCounter.getromanc                 C   s|   | j r| j dv r|  ¡ S | j dkr|  ¡ S | j dkr |  ¡  ¡ S | j dkr)|  ¡ S | j dkr2|  ¡ S t d| j  ¡ |  ¡ S )z8Get the current value as configured in the current mode.)r  rë  ÚAÚar¸  rj  zUnknown counter mode )r   r�  r¿  rÒ  rÃ  rÀ  r   r   r¾  r   r   r   Úgetvalue“  s   



zNumberCounter.getvaluec                 C   s"   | j sd| _ |  j d7  _ |  ¡ S )z@Increase the current value and get the next value as configured.r   r•  )r…  rÆ  r¾  r   r   r   Úgetnext¢  s   zNumberCounter.getnextc                 C   ó
   d| _ dS )zReset the counter.r   Nrº  r¾  r   r   r   Úreset©  r[  zNumberCounter.resetc                 C   s"   d| j  }| jr|d| j 7 }|S )r  zCounter z	 in mode )ræ  r   ©r{  rž  r   r   r   rí  ­  s   
zNumberCounter.__unicode__r   )r   r   r    r!   ræ  r…  r   Úmasterr¾  rð  rü  rú  rÁ  r|  r¹  r¼  r�  r¿  rÀ  r½  rÃ  rÆ  rÇ  rÉ  rí  r	   r   rï  r   r   r   r   r£  [  s2    


ÿr£  c                   @   ó(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚDependentCounterz4A counter which depends on another one (the master).c                 C   s   || _ | j  ¡ | _| S )zSet the master counter.)rË  rÆ  rw  )r{  rË  r   r   r   Ú	setmaster»  s   zDependentCounter.setmasterc                 C   s2   | j | j ¡ kr|  ¡  t | ¡}| j ¡ | _ |S )z8Increase or, if the master counter has changed, restart.)rw  rË  rÆ  rÉ  r£  rÇ  r»  r   r   r   rÇ  Á  s
   
zDependentCounter.getnextc                 C   s   | j  ¡ d t | ¡ S )z8Get the value of the combined counter: master.dependent.r8   )rË  rÆ  r£  r¾  r   r   r   rÆ  É  rî  zDependentCounter.getvalueN)r   r   r    r!   rÎ  rÇ  rÆ  r   r   r   r   rÍ  ¸  s
    rÍ  c                   @   sÂ   e Zd ZdZ	 	 	 	 dZdZdd„ ejd D ƒZdd„ ejd D ƒZ	e
ƒ ZdZdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ ZdS )$ÚNumberGeneratorzMA number generator for unique sequences and hierarchical structures. Used in:Nc                 C   ó   g | ]}|  ¡ ‘qS r   ©rÒ  ©rE  Úxr   r   r   rF  ×  rü  zNumberGenerator.<listcomp>rù  c                 C   rÐ  r   rÑ  rÒ  r   r   r   rF  Ø  rü  rø  c                 C   s   |  dd¡S )z.Remove the possible asterisk in a layout type.rj  r+   )r‰  rü  r   r   r   Ú
deasteriskÝ  r¨  zNumberGenerator.deasteriskc                 C   s
   |   |¡S )z9Find out if the layout type corresponds to a unique part.)Úisromanrü  r   r   r   Úisuniqueá  r[  zNumberGenerator.isuniquec                 C   ó   |   |¡ ¡ | jv S )z9Find out if the layout type should have roman numeration.)rÔ  rÒ  Úromanlayoutsrü  r   r   r   rÕ  å  r^  zNumberGenerator.isromanc                 C   r×  )z?Find out if the layout type corresponds to an (un)ordered part.)rÔ  rÒ  Úorderedlayoutsrü  r   r   r   Úisinorderedé  r^  zNumberGenerator.isinorderedc                 C   s@   d|v rdS |   |¡rdS |  |¡sdS |  |¡tjkrdS dS )zCFind out if the type for a layout corresponds to a numbered layout.rj  FT)rÕ  rÚ  Úgetlevelr  r"  rü  r   r   r   Ú
isnumberedí  s   

zNumberGenerator.isnumberedc                 C   s   d|v S )z5Find out if the type contains an asterisk, basically.rj  r   rü  r   r   r   Úisunorderedù  rb  zNumberGenerator.isunorderedc                 C   sR   |   |¡rdS |  |¡st d| ¡ dS |  |¡ ¡ }| j |¡d }|tj	 S )z0Get the level that corresponds to a layout type.r   zUnknown layout type r•  )
rÖ  rÚ  r   r   rÔ  rÒ  rÙ  rY  r  r!  )r{  rö  r  r   r   r   rÛ  ý  s   


zNumberGenerator.getlevelc                 C   s$   	 t jr|  |¡dkrdS |  |¡S )z4Obtain the type for the part: without the asterisk, r•  rS  )rÏ  ÚappendixrÛ  rÔ  rü  r   r   r   Úgetparttype  s   
zNumberGenerator.getparttypec                 C   s   	 	 	 	 |   |¡ ¡ S )z$Generate a number for a layout type.)Ú
getcounterrÇ  rü  r   r   r   Úgenerate  s
   zNumberGenerator.generatec                 C   s,   |  ¡ }|| jvr|  |¡| j|< | j| S )z#Get the counter for the given type.)rÒ  Úcountersrñ  rü  r   r   r   rà    s   

zNumberGenerator.getcounterc                 C   sh   |   |¡r$|  |¡dkr$| j |¡}| j|d  }|  |¡}|  ||¡S t|ƒ}|  |¡r2| d¡ |S )z$Create a counter for the given type.r•  r¸  )	rÜ  rÛ  rÙ  rY  rà  Úcreatedependentr£  rÕ  r¹  )r{  rö  rY  ÚaboverË  Úcounterr   r   r   rñ    s   


zNumberGenerator.createc                 C   s2   || j vs| j | js|  ||¡| j |< | j | S )zDGet (or create) a counter of the given type that depends on another.)râ  rË  rã  ©r{  rö  rË  r   r   r   Úgetdependentcounter*  s   
z#NumberGenerator.getdependentcounterc                 C   s   t |ƒ |¡S )z,Create a dependent counter given the master.)rÍ  rÎ  ræ  r   r   r   rã  0  rÍ  zNumberGenerator.createdependentc                 C   s.   | j tj }|  |¡}| d¡ ¡  dt_dS )zStart appendices here.rÄ  TN)rÙ  r  r!  rà  r¹  rÉ  rÏ  rÞ  )r{  Ú	firsttyperå  r   r   r   Ústartappendix4  s   

zNumberGenerator.startappendix)r   r   r    r!   Ú	chapteredÚ	generatorrð  rû  rØ  rÙ  rá  râ  rÞ  rÔ  rÖ  rÕ  rÚ  rÜ  rÝ  rÛ  rß  rá  rà  rñ  rç  rã  ré  r   r   r   r   rÏ  Í  s4    rÏ  c                   @   ó   e Zd ZdZ	 dd„ ZdS )ÚChapteredGeneratorz1Generate chaptered numbers, as in Chapter.Number.c                 C   s2   	 t jdkrtj |¡S |  d¡}|  ||¡ ¡ S )zBGenerate a number which goes with first-level numbers (chapters). r   rñ  )r  r!  rÏ  rë  rá  rà  rç  rÇ  )r{  rö  Úchapterr   r   r   rá  ?  s
   

zChapteredGenerator.generateN)r   r   r    r!   rá  r   r   r   r   rí  ;  ó    rí  c                   @   s�   e Zd ZdZdZdZdZdZdZddd„Z	ddd„Z
dd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚContainerSizezThe size of a container.Nc                 C   ó   |   d|¡ |   d|¡ | S )z*Set the proper size with width and height.ÚwidthÚheight©Úsetvalue©r{  rò  ró  r   r   r   ré  Y  ó   zContainerSize.setc                 C   rñ  )zSet max width and/or height.ÚmaxwidthÚ	maxheightrô  )r{  rø  rù  r   r   r   Úsetmax_  r÷  zContainerSize.setmaxc                 C   s2   |   |d¡ |   |d¡ |   |d¡ |  |¡ | S )z*Read some size parameters off a container.rò  ró  Úscale)ÚsetparameterÚcheckvalidheightr(  r   r   r   Úreadparameterse  s
   
zContainerSize.readparametersc                 C   s   |  |¡}|  ||¡ dS )z=Read a size parameter off a container, and set it if present.N)r  rõ  )r{  r  ræ  r…  r   r   r   rü  m  s   
zContainerSize.setparameterc                 C   s"   |   |¡}|rt| ||ƒ dS dS )z6Set the value of a parameter name, only if it's valid.N)Úprocessparameterr‚  ©r{  ræ  r…  r   r   r   rõ  r  s   
ÿzContainerSize.setvaluec                 C   s>   |  d¡}| jr|  | j¡dkr|dkrd| _dS dS dS dS )z;Check if the height parameter is valid; otherwise erase it.Úheight_specialrë  ÚtotalheightN)r  ró  Úextractnumber)r{  r  Úheightspecialr   r   r   rý  x  s   

ÿzContainerSize.checkvalidheightc                 C   sB   |sdS |   |¡dkrdS tjd D ]}||v r| |d¡}q|S )z&Do the full processing on a parameter.NÚ0r  r+   )r  rý  r*  r‰  )r{  r…  rE  r   r   r   rÿ  ~  s   €zContainerSize.processparameterc                 C   sH   d}d}|D ]}|  ¡ r||7 }q|dkr|s||7 }d}q|  S |S )z+Extract the first number in the given text.r+   Fr8   T)r¢  )r{  r  rž  ÚdecimalÚcharr   r   r   r  ‰  s   
zContainerSize.extractnumberc                 C   s„   |rt |ƒd | _| jr| js|  |¡| _|r*t |ƒd | _| jr*| js*|  |¡| _| jr3| js3d| _| jr>| js@d| _dS dS dS )z-Check image dimensions, set them if possible.ÚpxÚautoN)rÑ  rø  rû  rò  Ú
scalevaluerù  ró  rö  r   r   r   Ú
checkimage—  s   
ÿzContainerSize.checkimagec                 C   s"   |t | jƒ d }tt |ƒƒd S )zFScale the value according to the image scale and return it as unicode.rª  r  )rª  rû  rÑ  )r{  r…  Úscaledr   r   r   r
  ¦  s   zContainerSize.scalevaluec                 C   s8   | j sdS d| j vrdS | j }d| _ | jdkrd| _|S )z?Remove percent width if present, to set it at the figure level.Nrõ   r	  )rò  ró  )r{  rò  r   r   r   Úremovepercentwidth«  s   

z ContainerSize.removepercentwidthc                 C   sª   t |jtƒst dt|ƒ ¡ | js| js| js| j	sdS d}||  
d¡7 }||  
d¡7 }||  
d¡7 }||  
d¡7 }|d d	krG|dd… }|d
7 }|j j|7  _dS )z1Add the proper style attribute to the output tag.zNo tag to add style, in Nz style="rò  rø  ró  rù  r   rö   rw  )rŒ  r  rJ  r   r   rÑ  rò  ró  rø  rù  ÚstyleparameterrK  )r{  r  rK  r   r   r   Úaddstyle·  s   zContainerSize.addstylec                 C   s*   t | |ƒ}|r| dd¡d | d S dS )z%Get the style for a single parameter.r  zmax-r  z; r+   )r‹  r‰  r   r   r   r   r  È  s   
zContainerSize.styleparameterr  )r   r   r    r!   rò  ró  rø  rù  rû  ré  rú  rþ  rü  rõ  rý  rÿ  r  r  r
  r  r  r  r   r   r   r   rð  P  s(    

rð  c                   @   r4  )r“   zA container for a pretty quotec                 C   ó   t ƒ | _tƒ | _d S rx  )r0  r�  rC  r  r¾  r   r   r   r|  Ô  ó   zQuoteContainer.__init__c                 C   sL   | j d | _| jtjvrt d| j d ¡ dg| _dS tj| j g| _dS )rê  r‡  zQuote type rT  rw  N)r  rö  rý  r(  r   r   rÏ   r¾  r   r   r   rý  Ø  s   zQuoteContainer.processN©r   r   r    r!   r|  rý  r   r   r   r   r“   Ñ  rA  r“   c                   @   r4  )rª   z
A Lyx linec                 C   r  rx  ©r   r�  rC  r  r¾  r   r   r   r|  ä  r  zLyXLine.__init__c                 C   s   dg| _ d S )Nz<hr class="line" />rD  r¾  r   r   r   rý  è  rŒ  zLyXLine.processNr  r   r   r   r   rª   á  rA  rª   c                   @   r  )rE   zText with emphatic modec                 C   ó   d| j _d S )NrB  ©r  rK  r¾  r   r   r   rý  î  rŒ  zEmphaticText.processNr  r   r   r   r   rE   ë  r&  rE   c                   @   r  )rM   zText shaped (italic, slanted)c                 C   sL   | j d | _| jtjvrt d| j d  ¡ d| j_d S tj| j | j_d S )Nr•  zUnrecognized shape Úspan)r  rö  r/  rQ  r   r   r  rK  r¾  r   r   r   rý  ô  s   zShapedText.processNr  r   r   r   r   rM   ñ  r&  rM   c                   @   r  )rS   zText in versalitasc                 C   r  )Nrr  r  r¾  r   r   r   rý  ÿ  rŒ  zVersalitasText.processNr  r   r   r   r   rS   ü  r&  rS   c                   @   r  )rC   zColored textc                 C   ó"   | j d | _d| j d | j_d S ©Nr•  zspan class="rw  )r  rå  r  rK  r¾  r   r   r   rý    ó   zColorText.processNr  r   r   r   r   rC     r&  rC   c                   @   r  )rO   z
Sized textc                 C   r  r  )r  r*  r  rK  r¾  r   r   r   rý    r  zSizeText.processNr  r   r   r   r   rO   	  r&  rO   c                   @   r  )r?   z	Bold textc                 C   r  )NrA  r  r¾  r   r   r   rý    rŒ  zBoldText.processNr  r   r   r   r   r?     r&  r?   c                   @   r  )rR   z,A bit of text from elyxer.a different familyc                 C   sF   | j d | _| jtjvrt dt ¡ d| j_dS tj| j | j_dS )zParse the type of familyr•  zUnrecognized family r  N)r  rö  r/  rK  r   r   r  rK  r¾  r   r   r   rý    s   zTextFamily.processNr  r   r   r   r   rR     r&  rR   c                   @   r  )rF   zHorizontall fillc                 C   r  )Nzspan class="hfill"r  r¾  r   r   r   rý  %  rŒ  zHfill.processNr  r   r   r   r   rF   "  r&  rF   c                   @   r  )r=   zText with a bar somewherec                 C   sH   | j d | _| jtjvrt d| j ¡ d| j_dS tj| j | j_dS )zParse the type of barr•  zUnknown bar type r  N)r  rö  r/  rJ  r   r   r  rK  r¾  r   r   r   rý  +  s   zBarredText.processNr  r   r   r   r   r=   (  r&  r=   c                   @   r  )rZ   z A line with language informationc                 C   sF   | j d }|tjvrtƒ | _dS tj| }tƒ  d| d d¡| _dS )zDOnly generate a span with lang info when the language is recognized.r•  Nzspan lang="rw  F)r  rR  rv  rG  r  rJ  rN  )r{  ÚlangÚisolangr   r   r   rý  7  s   


zLangLine.processNr  r   r   r   r   rZ   4  r&  rZ   c                   @   r  )r¨   z!A length measure inside an inset.c                 C   s   | j d | _d S )Nr•  )r  rÑ  r¾  r   r   r   rý  C  s   zInsetLength.processNr  r   r   r   r   r¨   @  r&  r¨   c                   @   rÌ  )	rš   zA space of several typesc                 C   r  rx  ©r9  r�  rC  r  r¾  r   r   r   r|  I  r  zSpace.__init__c                 C   sz   | j d | _| jtjvrt d| j ¡ dg| _d S tj| j g| _|  ¡ }|s*d S tƒ  	dd¡| _
tƒ  |¡ | ¡ d S )Nr‡  zUnknown space type rö   zspan class="hspace"F)r  rö  rý  r'  r   r   rÏ   Ú	getlengthrJ  rN  r  rð  ré  r  rÐ  r   r   r   rý  M  s   zSpace.processc                 C   s.   t | jƒdkst| jd tƒsdS | jd jS )z<Get the space length from elyxer.the contents or parameters.r   N)r  r  rŒ  r¨   rÑ  r¾  r   r   r   r  Z  s   zSpace.getlengthN)r   r   r    r!   r|  rý  r  r   r   r   r   rš   F  s
    rš   c                   @   r4  )r–   z(An inset that contains a vertical space.c                 C   r  rx  r  r¾  r   r   r   r|  c  r  zVerticalSpace.__init__c                 C   sJ   | j d | _| jtjvrtƒ  d| j d d¡| _dS tj| j g| _dS )zSet the correct tagr‡  z"div class="vspace" style="height: z;"TN)r  rö  rý  r+  rJ  rN  r  rÏ   r¾  r   r   r   rý  g  s
   zVerticalSpace.processNr  r   r   r   r   r–   `  rA  r–   c                   @   r4  )r<   zBit of aligned textc                 C   ry  rŠ  )r-  r�  rJ  rP  r  r¾  r   r   r   r|  r  rz  zAlign.__init__c                 C   s   d| j d  d | j_d S )Nzdiv class="r•  rw  )r  r  rK  r¾  r   r   r   rý  v  s   zAlign.processNr  r   r   r   r   r<   o  rA  r<   c                   @   r4  )r¬   z	A newlinec                 C   r  rx  r  r¾  r   r   r   r|  |  r  zNewline.__init__c                 C   ó   dg| _ dS )rê  z<br/>
NrD  r¾  r   r   r   rý  €  r¨  zNewline.processNr  r   r   r   r   r¬   y  rA  r¬   c                   @   r  )r­   z
A new pagec                 C   r  )rê  z<p><br/>
</p>
NrD  r¾  r   r   r   rý  ‡  r¨  zNewPage.processNr  r   r   r   r   r­   „  r&  r­   c                   @   r  )Ú	Separatorz;A separator string which is not extracted by extracttext().c                 C   s   t ƒ | _g | _|g| _d S rx  )rC  r  r  rÏ   )r{  r  r   r   r   r|  Ž  s   zSeparator.__init__Nr  r   r   r   r   r  ‹  r&  r  c                   @   r  )rQ   zStriken out text.c                 C   s   d| j _dS )zSet the output tag to strike.ÚstrikeNr  r¾  r   r   r   rý  –  r¨  zStrikeOut.processNr  r   r   r   r   rQ   “  r&  rQ   c                   @   rì  )r¯   zMark to start an appendix here.c                 C   s   t j ¡  dS )zDActivate the special numbering scheme for appendices, using letters.N)rÏ  rë  ré  r¾  r   r   r   rý  ž  rÍ  zStartAppendix.processNr  r   r   r   r   r¯   š  rï  r¯   c                   @   sh   e Zd ZdZdZdZdZdZdZdZ	dZ
dd„ Zddd„Zdd„ Zd	d
„ Zdd„ Zejdkr2eZdS dS )ÚLinkz&A link to another part of the documentNc                 C   s,   g | _ tƒ | _tƒ | _tjrtj| _dS dS )z.Initialize the link, add target if configured.N)r  r9  r�  Ú
LinkOutputr  r™  rÕ  r¾  r   r   r   r|  ²  s   ÿzLink.__init__c                 C   s8   t |ƒg| _|r|| _|r|| _|r|| _|r|| _| S )zComplete the link.)rU   r  Úanchorr|  rö  rÒ  )r{  r  r#  r|  rö  rÒ  r   r   r   r  º  s   zLink.completec                 C   sF   | j sdS d| _| j jrd| j j | _| j jr!| j j| j | _dS dS )z8Use the destination link to fill in the destination URL.Nr+   ró   )Údestinationr|  r#  r  r¾  r   r   r   ÚcomputedestinationÇ  s   ÿzLink.computedestinationc                 C   s   || _ | |_ dS )zESet another link as destination, and set its destination to this one.N)r$  )r{  r$  r   r   r   ÚsetmutualdestinationÑ  s   
zLink.setmutualdestinationc                 C   s0   d}| j r|d| j  7 }| jr|d| j 7 }|S )r  r!  z #z to )r#  r|  rÊ  r   r   r   rí  Ö  s   zLink.__unicode__r   )NNNN)r   r   r    r!   r#  r|  rö  r  rÕ  r$  rÒ  r|  r  r%  r&  rí  r	   r   rï  r   r   r   r   r!  §  s"    


	ÿr!  c                   @   r  )rz   zA clickable URLc                 C   sV   |   |  d¡¡}|| _|  d¡}|r|   |¡| | _|  d¡}|s#|}t|ƒg| _dS )zRead URL from elyxer.parametersrÕ  rö  ræ  N)rì  r  r|  rU   r  )r{  rÕ  rö  ræ  r   r   r   rý  æ  s   

zURL.processNr  r   r   r   r   rz   ã  r&  rz   c                   @   r  )r‡   zA flexible URLc                 C   s   |   ¡ | _dS )zRead URL from elyxer.contentsN)r´   r|  r¾  r   r   r   rý  õ  rÍ  zFlexURL.processNr  r   r   r   r   r‡   ò  r&  r‡   c                   @   rì  )r"  z#A link pointing to some destinationc                 C   s    |j j}|jr
|j}d| d }|jr|d|j d 7 }|jr#| ¡  |jr/|d|j d 7 }|jr;|d|j d 7 }|jrG|d|j d 7 }t	ƒ  
|¡ |¡S )zGet the HTML code for the linkz	a class="rw  z name="z href="z	 target="z title=")rò  r   rö  r#  r$  r%  r|  rÕ  rÒ  rJ  rN  r=  )r{  Úlinkrö  rK  r   r   r   r=  ý  s   zLinkOutput.gethtmlNrF  r   r   r   r   r"  ù  rï  r"  c                   @   s4   e Zd ZdZg Zdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚPostprocessorz,Postprocess a container keeping some contextc                 C   s   t tj| ƒ| _d | _d | _d S rx  )Ú	StageDictr(  Ústagesr’  rw  r¾  r   r   r   r|    s   
zPostprocessor.__init__c                 C   s(   |   | j¡ |  |¡}| j| _|| _|S )z)Postprocess a container and its contents.)Úpostrecursiver’  Úpostcurrentrw  )r{  r[  rž  r   r   r   Úpostprocess  s
   
zPostprocessor.postprocessc                 C   s’   t |dƒsdS t|jƒdkrdS t |dƒr|jsdS tƒ }g }|jD ]}| |¡}|r0| |¡ q"tdƒD ]}| d¡}|rC| |¡ q5||_dS )z.Postprocess the container contents recursivelyr  Nr   r-  r‡  )rŠ  r  r  r-  r(  r‘  rp  )r{  r  Úpostprocessorr  rI  ÚpostrB  r   r   r   r+  %  s(   




€

€
zPostprocessor.postrecursivec                 C   s*   | j  | j¡}|s| jS | | j| j|¡S )zBPostprocess the current element taking into account next and last.)r*  Úgetstager’  r-  rw  )r{  r[  Ústager   r   r   r,  ;  s   zPostprocessor.postcurrentN)	r   r   r    r!   r*  r|  r-  r+  r,  r   r   r   r   r(    s    r(  c                   @   rÌ  )	r)  z/A dictionary of stages corresponding to classesc                 C   s$   |   ||¡}tdd„ |D ƒƒ| _dS )zGInstantiate an element from elyxer.each class and store as a dictionaryc                 S   s   g | ]}|j |f‘qS r   )ÚprocessedclassrÒ  r   r   r   rF  H  ó    z&StageDict.__init__.<locals>.<listcomp>N)Úinstantiaterá  Ú	stagedict)r{  Úclassesr.  rŒ  r   r   r   r|  E  s   zStageDict.__init__c                 C   s*   dd„ |D ƒ}|D ]	}|  ¡  ||_q	|S )z-Instantiate an element from elyxer.each classc                 S   s   g | ]}|  |¡‘qS r   )rõ  rÒ  r   r   r   rF  L  r3  z)StageDict.instantiate.<locals>.<listcomp>)r|  r.  )r{  r6  r.  r*  rI  r   r   r   r4  J  s
   zStageDict.instantiatec                 C   s   |j | jvrdS | j|j  S )z=Get the stage for a given element, if the type is in the dictN)rò  r5  ©r{  rI  r   r   r   r0  R  s   zStageDict.getstageN)r   r   r    r!   r|  r4  r0  r   r   r   r   r)  B  s
    r)  c                   @   s^   e Zd ZdZeƒ ZdZdd„ Zdd„ Zddd„Z	d	d
„ Z
dd„ Zdd„ Zejdkr-eZdS dS )r}   zA label to be referencedNc                 C   s   t  | ¡ d | _d S rx  )r!  r|  Úlastnumberedr¾  r   r   r   r|  `  s   

zLabel.__init__c                 C   s"   |   d¡}|  d|¡ tj| _dS )zProcess a label container.ræ  rö   N)r  rñ  r}   Ú
lastlayoutr8  r¢  r   r   r   rý  d  s   
zLabel.processc                 C   sD   || _ | j|||d� | tj|< |tjv r tj| D ]}| |_q| S )z!Create the label for a given key.)r#  rö  )r„  r  r}   Únamesr�   rb  r$  )r{  r  r„  rö  Ú	referencer   r   r   rñ  j  s   

zLabel.createc                 C   s   |   | ¡}|r|jr|jS dS )z8Get the part key for the latest numbered container seen.r+   )r*  r  )r{  r*  r   r   r   Úfindpartkeyt  s   

zLabel.findpartkeyc                 C   s,   |j r|S |js| jr| jS dS |  |j¡S )z)Get the numbered container for the label.N)r  r  r8  r*  r(  r   r   r   r*  {  s   zLabel.numberedc                 C   s   t | dƒsdS d| j S )r  r„  zUnnamed labelzLabel )rŠ  r„  r¾  r   r   r   rí  …  r  zLabel.__unicode__r   )r}   )r   r   r    r!   rá  r:  r9  r|  rý  rñ  r<  r*  rí  r	   r   rï  r   r   r   r   r}   Z  s    



ÿr}   c                   @   sL   e Zd ZdZeƒ ZdZdd„ Zdd„ Zdd„ Z	d	d
„ Z
ejdkr$e
ZdS dS )r�   zA reference to a label.Únonec                 C   s€   |   d¡| _| jtjv rd| _tj| j }nd| _tƒ  d| jd¡}|| _|  ¡  | jtj	vr5g tj	| j< tj	| j  
| ¡ dS )z%Read the reference and set the arrow.r;  r2  r  rö   ÚprerefN)r  r„  r}   r:  Ú	directionr  r$  Úformatcontentsr�   rb  r‘  )r{  Úlabelr   r   r   rý  •  s   zReference.processc                 C   s  |   d¡}|s	d}d| _|tjv rtj| | _nt d| ¡ |  d| j¡ |  dd¡ |  dt 	d¡¡ | j
 ¡ }|  d|oA|j¡ |  d	|oJ|j¡ d
| jvsV|rV|js_t| jƒg| _dS | j d
¡}t|d ƒg| _|dd… D ]}|  j|j7  _| j t|ƒ¡ qsdS )zFormat the reference contents.ÚLatexCommandr  r3  zUnknown reference format ró   rë  r_  rf  rø   rô   Nr   r•  )r  r  rý  r)  r   r   r‰  r?  r–  r˜  r$  r<  r“  ÚtocentryÚtitlecontentsrU   r  r—  r‘  )r{  Ú	formatkeyr  rò  ró  r   r   r   r@  ¤  s,   


þzReference.formatcontentsc                 C   s*   || j vrdS |sd}| j  ||¡| _ dS )z2Replace a key in the format template with a value.Nr+   )r  r‰  rè  r   r   r   r‰  ¿  s
   
zReference.replacec                 C   r  )r  z
Reference )r„  r¾  r   r   r   rí  Ç  r[  zReference.__unicode__r   N)r   r   r    r!   rá  rb  r„  rý  r@  r‰  rí  r	   r   rï  r   r   r   r   r�   �  s    
ÿr�   c                   @   sZ   e Zd ZdZg Zejd ZdZdd„ Z	dd„ Z
dd	„ Zd
d„ Zdd„ Zdd„ Zdd„ ZdS )ÚFormulaCommandz A LaTeX command inside a formularm  Nc                 C   s   |  tj¡S )zFind the current command.)r”  rF  r:  rÁ  r   r   r   rP  Ö  r¨  zFormulaCommand.detectc                 C   s|   |   |¡}|  ||¡}|r|S | d¡s| d¡r#|  ||¡}|r#|S | jjs.t d| ¡ tƒ  	d¡| _
|  t|ƒ¡ dS )zParse the command.ú\upú\UpzUnknown command r”  N)ÚextractcommandÚparsewithcommandr€  Úparseupgreekr  r•  r   r   rJ  rN  r  r¶  rV   )r{  rÂ  rm  r@  Úupgreekr   r   r   rQ  Ú  s   
zFormulaCommand.parsebitc                 C   s,   t jD ]}||jv r|  |||¡  S qdS )z0Parse the command type once we have the command.N)rF  r’  Ú
commandmapÚparsecommandtype)r{  rm  rÂ  rö  r   r   r   rJ  ê  s
   

ÿzFormulaCommand.parsewithcommandc                 C   s,   | j  |¡}| |¡ | |¡}|r|S |S )zParse a given command type.)r  rñ  Ú
setcommandrQ  )r{  rm  rö  rÂ  r@  Úreturnedr   r   r   rN  ñ  s   

zFormulaCommand.parsecommandtypec                 C   sh   |  tj¡s| dtj ¡ dS | ¡ r|  |¡S | ¡  ¡ r-tj| ¡  }|  d¡ |S tj| 	¡  S )z5Extract the command from elyxer.the current position.zMissing command start Nrj  )
rÖ  rF  r:  r   rz  Úemptycommandr’  rž  r   rŽ  )r{  rÂ  rm  r   r   r   rI  ú  s   

zFormulaCommand.extractcommandc                 C   s0   d}|  ¡ s| ¡ }|r| |¡r|}tj| S )zqCheck for an empty command: look for command disguised as ending.
    Special case against '{ \{ \} }' situation.r+   )r’  r¾  rÖ  rF  r:  )r{  rÂ  rm  r  r   r   r   rQ  
  s   
zFormulaCommand.emptycommandc                 C   s„   t |ƒdk rdS | d¡rd|dd…  }n| d¡r,d|dd…  ¡  |dd…  }n	t d| ¡ dS |  ||¡}|r@d|_|S )	zParse the Greek \up command..r·  NrG  r±   r   rH  zImpossible upgreek command: rt  )r  r€  rÖ  Úupperr   r   rJ  rö  )r{  rm  rÂ  Ú	upcommandrL  r   r   r   rK    s   

"zFormulaCommand.parseupgreek)r   r   r    r!   r’  rÒ   r¶   r:  rM  rP  rQ  rJ  rN  rI  rQ  rK  r   r   r   r   rF  Ï  s    
	
rF  c                   @   r×  )Ú
CommandBitz%A formula bit that includes a commandc                 C   s0   || _ | jr|  j|7  _| j| j  | _dS dS )zSet the command in the bitN)rm  rM  ró  Ú
translated)r{  rm  r   r   r   rO  '  s
   þzCommandBit.setcommandc                 C   s2   | j  |¡ | ¡ rdS | j  |¡}|  |¡ |S )z)Parse a parameter at the current positionN)r  r�  rz  rf  r¶  )r{  rÂ  Ú	parameterr   r   r   r  .  s   
zCommandBit.parseparameterc                 C   s:   | j  |¡ | j  t|¡sdS | j  t|¡}|  |¡ |S )zParse a square bracketN)r  r�  r�  rj  r'  r¶  ©r{  rÂ  r6  r   r   r   Úparsesquare7  s   
zCommandBit.parsesquarec                 C   sd   | j  |¡ | j  t|¡s | ¡ st d| ¡  ¡ dS | ¡ S tƒ  	| j ¡}|  
| |¡¡ |jS )zParse a literal bracket.zNo literal parameter found at: N)r  r�  r�  r\   r«  r   r   rÏ  r¬  r>  r¶  rb  ri  rW  r   r   r   rb  @  s   zCommandBit.parseliteralc                 C   sB   | j  |¡ | j  t|¡sdS tƒ  | j ¡}|  | |¡¡ |jS )z!Parse a square bracket literally.N)r  r�  r�  rj  r>  r¶  rb  ri  rW  r   r   r   ÚparsesquareliteralL  s   zCommandBit.parsesquareliteralc                 C   sP   | j  |¡ | j  t|¡st d| j ¡ dS tƒ  | j ¡ |¡}|  	|¡ |S )zParse a text parameter.zNo text parameter for N)
r  r�  r�  r\   r   r   rm  r>  r`  r¶  rW  r   r   r   r`  U  s   
zCommandBit.parsetextN)
r   r   r    r!   rO  r  rX  rb  rY  r`  r   r   r   r   rT  $  s    			rT  c                   @   ó   e Zd ZdZejZdd„ ZdS )ra   z%An empty command (without parameters)c                 C   s   t | jƒg| _dS )ú"Parse a command without parametersN©rV   rU  r  rÁ  r   r   r   rQ  d  r‡  zEmptyCommand.parsebitN)r   r   r    r!   rÒ   rÍ   rM  rQ  r   r   r   r   ra   _  ó    ra   c                   @   rZ  )ÚSpacedCommandz<An empty command which should have math spacing in formulas.c                 C   s   t d| j d ƒg| _dS )z4Place as contents the command translated and spaced.rÊ   Nr\  rÁ  r   r   r   rQ  m  r  zSpacedCommand.parsebitN)r   r   r    r!   rÒ   rŠ  rM  rQ  r   r   r   r   r^  h  r]  r^  c                   @   rZ  )r`   z8A command without paramters whose result is alphabeticalc                 C   s   t  | |¡ d| _dS )z'Parse the command and set type to alphar0   N)ra   rQ  rö  rÁ  r   r   r   rQ  v  s   
zAlphaCommand.parsebitN)r   r   r    r!   rÒ   ry  rM  rQ  r   r   r   r   r`   q  r]  r`   c                   @   s*   e Zd ZdZejZdZdd„ Zdd„ Z	dS )rb   zA function of one parameterFc                 C   s&   t ƒ  | j¡| _|  |¡ |  ¡  dS )z#Parse a function with one parameterN)rJ  rN  rU  r  r  ÚsimplifyifpossiblerÁ  r   r   r   rQ  �  s   
zOneParamFunction.parsebitc                 C   s2   | j | jv rtƒ | _| j| j  g| _d| _dS dS )z&Try to simplify to a single character.TN)ró  rM  rC  r  rÏ   Ú
simplifiedr¾  r   r   r   r_  ‡  s
   
ýz#OneParamFunction.simplifyifpossibleN)
r   r   r    r!   rÒ   r‰  rM  r`  rQ  r_  r   r   r   r   rb   {  s    rb   c                   @   ó&   e Zd ZdZejZdd„ Zdd„ ZdS )rc   z>Find a function which is represented by a symbol (like _ or ^)c                 C   s   |  ¡ tjv S )zFind the symbol)r’  rc   rM  rÁ  r   r   r   rP  “  rÍ  zSymbolFunction.detectc                 C   s8   |   | ¡ ¡ | | j¡ tƒ  | j¡| _|  |¡ dS )rS  N)	rO  r’  r±  rm  rJ  rN  rU  r  r  rÁ  r   r   r   rQ  —  s   zSymbolFunction.parsebitN)	r   r   r    r!   rÒ   r‹  rM  rP  rQ  r   r   r   r   rc   Ž  ó
    rc   c                   @   ra  )rd   z-A function where parameters are read as text.c                 C   s   t ƒ  | j¡| _|  |¡ dS )zParse a text parameterN)rJ  rN  rU  r  r`  rÁ  r   r   r   rQ  £  s   zTextFunction.parsebitc                 C   rÈ  )zSet the type to fontrt  Nrÿ  r¾  r   r   r   rý  ¨  r[  zTextFunction.processN)	r   r   r    r!   rÒ   rŒ  rM  rQ  rý  r   r   r   r   rd   ž  s
    rd   c                   @   ra  )ÚLabelFunctionzA function that acts as a labelc                 C   s   |   |¡| _dS )zParse a literal parameterN)rb  r„  rÁ  r   r   r   rQ  ±  rÞ  zLabelFunction.parsebitc                 C   s8   d| _ tƒ jd| jdd�| _| jg| _| jtj| j< dS )z&Add an anchor with the label contents.rt  rö   Úeqnumberrÿ  N)rö  r}   rñ  r„  rA  r  r:  r¾  r   r   r   rý  µ  s   
zLabelFunction.processN)	r   r   r    r!   rÒ   r…  rM  rQ  rý  r   r   r   r   rc  ¬  rb  rc  c                   @   rZ  )re   z1A function of one parameter that changes the fontc                 C   s   d| _ |  ¡  dS )z.Simplify if possible using a single character.rt  N)rö  r_  r¾  r   r   r   rý  Â  r=  zFontFunction.processN)r   r   r    r!   rÒ   r‚  rM  rý  r   r   r   r   re   ½  r]  re   c                   @   s.   e Zd ZdZejZdd„ Zdd„ Zdd„ Z	dS )	Ú	BigSymbolzA big symbol generator.c                 C   rs  )zCreate the big symbol.N)rV  )r{  rV  r   r   r   r|  Ý  r[  zBigSymbol.__init__c                 C   s0   | j | jvr
| j gS |  ¡ r| j gS | j| j  S )zGet an array with all pieces.)rV  rú  Ú
smalllimitr¾  r   r   r   Ú	getpiecesá  s
   zBigSymbol.getpiecesc                 C   s(   t jsdS t| j| j ƒdkrdS tjS )z7Decide if the limit should be a small, one-line symbol.Tr•  )r  r#  r  rú  rV  r™  r´  r¾  r   r   r   rf  é  s
   zBigSymbol.smalllimitN)
r   r   r    r!   rÒ   r|  rú  r|  rg  rf  r   r   r   r   re  Ø  s    re  c                   @   sR   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ ZdS )Ú
BigBracketzA big bracket generator.r<  c                 C   s6   || _ || _|| _d| _|tjv rtj| | _dS dS )z(Set the size and symbol for the bracket.N)r*  ró  Ú	alignmentrò  rÒ   r{  )r{  r*  r6  ri  r   r   r   r|  ô  s   
ÿzBigBracket.__init__c                 C   s    t | dtt| jƒƒ ƒ}||ƒS )z%Return the nth piece for the bracket.Úgetpiece)r‹  rÑ  r  rò  )r{  rY  Úfunctionr   r   r   rj  ý  s   zBigBracket.getpiecec                 C   s
   | j d S )z1Return the only piece for a single-piece bracket.r   )rò  ©r{  rY  r   r   r   Ú	getpiece1  r[  zBigBracket.getpiece1c                 C   s4   |dkr	| j d S || jd kr| j d S | j d S )zGGet the nth piece for a 3-piece bracket: parenthesis or square bracket.r   r•  r   ©rò  r*  rl  r   r   r   Ú	getpiece3  s
   


zBigBracket.getpiece3c                 C   sP   |dkr	| j d S || jd kr| j d S || jd d kr#| j d S | j d S )z7Get the nth piece for a 4-piece bracket: curly bracket.r   r•  r   r‡  rn  rl  r   r   r   Ú	getpiece4  s   



zBigBracket.getpiece4c                 C   s&   |   |¡}d| j d }tƒ  ||¡S )z'Get the bracket piece as an array cell.zspan class="bracket align-rw  )rj  ri  rJ  r  )r{  rY  ró  r  r   r   r   Úgetcell  s   
zBigBracket.getcellc                 C   s\   | j dks| js|  ¡ S g }t| j ƒD ]}|  |¡}| tƒ  |gd¡¡ qtƒ  |d¡gS )z3Get the bracket as an array or as a single bracket.r•  úspan class="arrayrow"úspan class="array")r*  rò  Úgetsinglebracketrp  rq  r‘  rJ  r  )r{  ÚrowsrY  Úcellr   r   r   Úgetcontents  s   
zBigBracket.getcontentsc                 C   s,   | j dkrtƒ  dd¡gS tƒ  | j d¡gS )z$Return the bracket as a single sign.r8   r+   zspan class="emptydot"rî   )ró  rJ  r  r¾  r   r   r   rt  (  s   
zBigBracket.getsinglebracketN)r<  )r   r   r    r!   r|  rj  rm  ro  rp  rq  rw  rt  r   r   r   r   rh  ñ  s    
	

rh  c                   @   ó   e Zd ZdZdZdd„ ZdS )ÚFormulaEquationzA simple numbered equation.Úequationc                 C   s    t ƒ | _|  | j t|¡¡ dS )úParse the arrayN)rG  r  r¶  r  r'  r‹  rÁ  r   r   r   rQ  8  ó   zFormulaEquation.parsebitN©r   r   r    r!   ró  rQ  r   r   r   r   ry  3  ó    ry  c                   @   r4  )ÚFormulaCellzAn array cell inside a rowc                 C   s"   || _ tƒ  d| d d¡| _| S )Nzspan class="arraycell align-rw  T)ri  rJ  rN  r  )r{  ri  r   r   r   Úsetalignment@  s   zFormulaCell.setalignmentc                 C   s0   | j  |¡ | ¡ rd S |  | j  t|¡¡ d S rx  )r  r�  rz  r¶  r'  r‹  rÁ  r   r   r   rQ  E  s   zFormulaCell.parsebitN)r   r   r    r!   r€  rQ  r   r   r   r   r  =  r8  r  c                   @   s2   e Zd ZdZejd Zdd„ Zdd„ Zdd„ Z	d	S )
Ú
FormulaRowzAn array row inside an arrayrà   c                 C   s   || _ tƒ  dd¡| _| S )Nrr  T)Ú
alignmentsrJ  rN  r  )r{  r‚  r   r   r   ÚsetalignmentsP  s   zFormulaRow.setalignmentsc                 C   st   d}|j | jdd� | ¡ s+|  |¡}| |¡ |  |¡ |d7 }| | j¡ | ¡ rt| jƒdkr8t	ƒ | _
dS dS )zParse a whole rowr   T)r¸  r•  N)r¹  rà   rz  Ú
createcellrQ  r¶  rÖ  r  r  rB  r  )r{  rÂ  rY  rv  r   r   r   rQ  U  s   


ûÿzFormulaRow.parsebitc                 C   s&   | j |t| j ƒ  }| j t¡ |¡S )z4Create the cell that corresponds to the given index.)r‚  r  r  rñ  r  r€  )r{  rY  ri  r   r   r   r„  b  s   zFormulaRow.createcellN)
r   r   r    r!   rÒ   rz  rà   rƒ  rQ  r„  r   r   r   r   r�  K  s    
r�  c                   @   r÷  )ÚMultiRowFormulazA formula with multiple rows.c                 C   sP   g | _ d}|  |¡D ]}|rd}n|  ¡  | |¡ |  |¡ q
t| j ƒ| _dS )z,Parse all rows, finish when no more row endsTFN)ru  ÚiteraterowsÚaddemptyrQ  Úaddrowr  r*  )r{  rÂ  rš  Úrowr   r   r   Ú	parserowsj  s   
zMultiRowFormula.parserowsc                 c   sZ   � t jd }	 | |d¡ | j t¡}| | j¡V  | |¡r*|  j	| 
|¡7  _	ndS q)z0Iterate over all rows, end when no more row endsrâ   TN)rÒ   rz  r¹  r  rñ  r�  rƒ  r‚  r”  ró  r¼  )r{  rÂ  râ   r‰  r   r   r   r†  x  s   €

ùzMultiRowFormula.iteraterowsc                 C   s^   | j  t¡ | j¡}t| jd jƒD ]\}}| |¡}| 	t
dƒ¡ | 	|¡ q|  |¡ dS )zAdd an empty row.r   rË   N)r  rñ  r�  rƒ  r‚  rÆ  ru  r  r„  r¶  rV   rˆ  )r{  r‰  rY  Úoriginalcellrv  r   r   r   r‡  „  s   
zMultiRowFormula.addemptyc                 C   s   | j  |¡ |  |¡ dS )z2Add a row to the contents and to the list of rows.N)ru  r‘  r¶  )r{  r‰  r   r   r   rˆ  �  s   zMultiRowFormula.addrowN)r   r   r    r!   rŠ  r†  r‡  rˆ  r   r   r   r   r…  g  s    	r…  c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )ÚFormulaArrayzAn array within a formularz  c                 C   s(   t ƒ  dd¡| _|  |¡ |  |¡ dS )r{  rs  FN)rJ  rN  r  ÚparsealignmentsrŠ  rÁ  r   r   r   rQ  —  s   
zFormulaArray.parsebitc                 C   sD   d| _ |  |¡}|r|| _ |  |¡}g | _|D ]}| j |¡ qdS )zParse the different alignmentsr=  N)ÚvalignrY  rb  r‚  r‘  )r{  rÂ  ri  r<  r   r   r   r�  �  s   

ÿzFormulaArray.parsealignmentsN)r   r   r    r!   ró  rQ  r�  r   r   r   r   rŒ  ’  ó
    rŒ  c                   @   rx  )ÚFormulaMatrixz'A matrix (array with center alignment).Úmatrixc                 C   s,   t ƒ  dd¡| _d| _dg| _|  |¡ dS )z(Parse the matrix, set alignments to 'c'.rs  Fr=  N)rJ  rN  r  rŽ  r‚  rŠ  rÁ  r   r   r   rQ  ¯  s   zFormulaMatrix.parsebitNr}  r   r   r   r   r�  ª  r~  r�  c                   @   rx  )ÚFormulaCaseszA cases statementÚcasesc                 C   sŠ   t ƒ | _ddg| _|  |¡ | jD ]}|jD ]}|j dd¡ |j tdƒ¡ qqtƒ  	| jdd¡}t
t| jƒddƒ}| ¡ |g | _dS )zParse the casesr<  zspan class="case align-l"TrÉ   zspan class="bracketcases"rê   N)rG  r  r‚  rŠ  r  rN  r‘  rV   rJ  r  rh  r  rw  )r{  rÂ  r‰  rv  rz  Úbracer   r   r   rQ  »  s   



þzFormulaCases.parsebitNr}  r   r   r   r   r’  ¶  r~  r’  c                   @   r  )ÚEquationEnvironmentz;A \begin{}...\end equation environment with rows and cells.c                 C   s\   t ƒ  dd¡| _| j dd¡}|tjv rtj| | _nt 	d| j ¡ dg| _|  
|¡ dS )zParse the whole environment.zspan class="environment"Frj  r+   zUnknown equation environment r<  N)rJ  rN  r  ró  r‰  rÒ   r�  r‚  r   r   rŠ  )r{  rÂ  Úenvironmentr   r   r   rQ  Ë  s   
zEquationEnvironment.parsebitN)r   r   r    r!   rQ  r   r   r   r   r•  È  r&  r•  c                   @   s:   e Zd ZdZejd diZeee	e
gZdd„ Zdd„ ZdS )	ÚBeginCommandzEA \begin{}...\end command and what it entails (array, cases, aligned)rß   r+   c                 C   sh   |   |¡}|  |¡}tjd d | d }| |¡ | |¡ |  |¡ |  j| |¡7  _|j	| _	dS )zParse the begin commandrá   rê   rë   N)
rb  ÚfindbitrÒ   rz  r¹  rQ  r¶  ró  r¼  r*  )r{  rÂ  rm  r@  r  r   r   r   rQ  Ý  s   




zBeginCommand.parsebitc                 C   sD   t jD ]}| dd¡|jkr| j |¡  S q| j t¡}||_|S )z7Find the command bit corresponding to the \begin{piece}rj  r+   )r—  r’  r‰  ró  r  rñ  r•  )r{  ró  rö  r@  r   r   r   r˜  è  s   
ÿzBeginCommand.findbitN)r   r   r    r!   rÒ   rz  rM  ry  rŒ  r’  r�  r’  rQ  r˜  r   r   r   r   r—  Ö  s    r—  c                   @   s"   e Zd ZejZdd„ Zdd„ ZdS )rf   c                 C   sp   d| _ | j}|  |¡}|st d| j ¡ nt| ¡ ƒdkr.t d| j d | ¡  d ¡ | j 	t
|ƒ¡ dS )zParse a combining function.r0   z'Empty parameter for combining function r•  zApplying combining function z to invalid string "rw  N)rö  rU  Úparsesingleparameterr   r   rm  r  r´   r  r‘  rU   )r{  rÂ  Ú	combiningrV  r   r   r   rQ  ù  s   
 zCombiningFunction.parsebitc                 C   sj   | j  |¡ | ¡ rt d| ¡  ¡ dS | j  t|¡s#| j  t|¡r(|  	|¡S t
| ¡ ƒ}|  |¡ |S )z&Parse a parameter, or a single letter.z(Error while parsing single parameter at N)r  r�  rz  r   r   rÏ  r�  r\   rF  r  rV   rŽ  r¶  )r{  rÂ  Úletterr   r   r   r™    s   ÿ

z&CombiningFunction.parsesingleparameterN)r   r   r    rÒ   r~  rM  rQ  r™  r   r   r   r   rf   õ  s    rf   c                   @   rZ  )rg   z*A function that decorates some bit of textc                 C   sb   d| _ | j}tƒ  |d¡| _|  |¡| _tƒ  d¡| _	| j
 d| j¡ tƒ  d¡| j_	|  ¡  dS )zParse a decorating functionr0   zspan class="symbolover"zspan class="withsymbol"r   zspan class="undersymbol"N)rö  rU  rJ  r  rV  r  rV  rJ  rN  r  r  r˜  r_  )r{  rÂ  rV  r   r   r   rQ    s   zDecoratingFunction.parsebitN)r   r   r    r!   rÒ   r€  rM  rQ  r   r   r   r   rg     r]  rg   c                   @   rZ  )ÚLimitCommandz@A command which accepts limits above and below, in display mode.c                 C   s@   t | jƒ ¡ }tƒ  d¡| _|D ]}| j tƒ  	|d¡¡ qdS )zParse a limit command.úspan class="limits"zspan class="limit"N)
re  rU  rg  rJ  rN  r  r  r‘  rJ  r  )r{  rÂ  rò  ró  r   r   r   rQ  &  s
   ÿzLimitCommand.parsebitN)r   r   r    r!   rÒ   r†  rM  rQ  r   r   r   r   rœ  !  r]  rœ  c                   @   s6   e Zd ZdZdZdd„ Zdd„ ZejdkreZ	dS dS )r\  z(A command to limit the previous command.Nc                 C   s   t ƒ  d¡| _| j |¡ dS )zDo nothing.r�  N)rJ  rN  r  r  r�  rÁ  r   r   r   rQ  2  s   zLimitPreviousCommand.parsebitc                 C   r?  )r  zLimit previous commandr   r¾  r   r   r   rí  7  r$  z LimitPreviousCommand.__unicode__r   )
r   r   r    r!   rM  rQ  rí  r	   r   rï  r   r   r   r   r\  -  s    
ÿr\  c                   @   rá  )ÚLimitsProcessorz)A processor for limits inside an element.c                 C   sV   t jrdS |  ||¡r|  ||¡ |  ||¡r'|  ||d ¡r)|  ||¡ dS dS dS )z"Process the limits for an element.Nr•  )r™  r´  ÚchecklimitsÚmodifylimitsÚcheckscriptÚmodifyscriptsrl  r   r   r   rý  B  s   ÿzLimitsProcessor.processc                 C   sN   t jsdS |  ||d t¡r|  ||¡ dS t|| tƒsdS |  ||d ¡S )z3Check if the current position has a limits command.Fr•  )r  r#  Úcheckcommandr\  ÚlimitsaheadrŒ  rœ  r¡  rl  r   r   r   rŸ  K  s   zLimitsProcessor.checklimitsc                 C   s*   ||d    ||  ¡ ¡ tƒ || _dS )z,Limit the current element based on the next.r•  N)r¶  rô  rB  r  rl  r   r   r   r¤  V  s   zLimitsProcessor.limitsaheadc                 C   sf   || }|   ||d ¡}|j |¡ |  ||d ¡r#|   ||d ¡}ntƒ  dd¡}|j d|¡ dS )zCModify a limits commands so that the limits appear above and below.r•  rÊ   zsup class="limit"r   N)Úgetlimitr  r‘  r¡  rJ  r  r˜  )r{  r  rY  ÚlimitedrE  rF  r   r   r   r   [  s   zLimitsProcessor.modifylimitsc                 C   s$   |   ||¡}|jj dd¡|j_|S )z#Get the limit for a limits command.rP  r‰  )Ú	getscriptr  rK  r‰  )r{  r  rY  r‰  r   r   r   r¥  f  s   zLimitsProcessor.getlimitc                 C   s:   |   ||¡}|   ||¡}tƒ  ||gd¡}| ||¡ dS )z=Modify the super- and subscript to appear vertically aligned.zspan class="scripts"N)r§  rJ  r  r˜  )r{  r  rY  rE  rF  Úscriptsr   r   r   r¢  l  s   zLimitsProcessor.modifyscriptsc                 C   s   |   ||t¡S )z6Check if the current element is a sub- or superscript.)r£  rc   rl  r   r   r   r¡  t  rÍ  zLimitsProcessor.checkscriptc                 C   s   t |ƒ|krdS t|| |ƒS )z0Check for the given type as the current element.F)r  rŒ  )r{  r  rY  rö  r   r   r   r£  x  s   zLimitsProcessor.checkcommandc                 C   s"   || }|j  jd7  _||= |S )zGet the sub- or superscript.z class="script"r  )r{  r  rY  r@  r   r   r   r§  ~  s   zLimitsProcessor.getscriptN)r   r   r    r!   rý  rŸ  r¤  r   r¥  r¢  r¡  r£  r§  r   r   r   r   rž  ?  s    	rž  c                   @   ra  )ri   z"A command which defines a bracket.c                 C   s   t  | |¡ dS )zParse the bracket.N)rb   rQ  rÁ  r   r   r   rQ  Š  rÞ  zBracketCommand.parsebitc                 C   s    || _ d| | _t|ƒg| _| S )z+Create the bracket for the given character.r±   )ró  rm  rV   r  ©r{  r?  Ú	characterr   r   r   rñ  Ž  s   
zBracketCommand.createN)	r   r   r    r!   rÒ   r}  rM  rQ  rñ  r   r   r   r   ri   …  rb  ri   c                   @   rc  )ÚBracketProcessorz!A processor for bracket commands.c                 C   s&   t jrdS |  ||¡r|  ||¡S dS )z6Convert the bracket using Unicode pieces, if possible.N)r™  r´  Ú	checkleftÚprocessleftrl  r   r   r   rý  ˜  s
   ÿzBracketProcessor.processc                 C   sJ   |   ||d ¡}|sdS |  |||¡}|  || |¡ |  || |¡ dS )zProcess a left bracket.r•  N)Ú	findrightÚfindmaxÚresize)r{  r  rY  Ú
rightindexr*  r   r   r   r­  Ÿ  s   zBracketProcessor.processleftc                 C   ó   |   || d¡S )z0Check if the command at the given index is left.rï   ©Úcheckdirectionrl  r   r   r   r¬  ¨  rÞ  zBracketProcessor.checkleftc                 C   r²  )z1Check if the command at the given index is right.rð   r³  rl  r   r   r   Ú
checkright¬  rÞ  zBracketProcessor.checkrightc                 C   s   t |tƒsdS |j|kS )z6Check if the given bit is the desired bracket command.F)rŒ  ri   rm  )r{  r@  rm  r   r   r   r´  °  r  zBracketProcessor.checkdirectionc                 C   s\   d}|t |ƒk r,|  ||¡r|d7 }|  ||¡r|d8 }|dkr"|S |d7 }|t |ƒk sdS )z9Find the right bracket starting at the given index, or 0.r•  r   N)r  r¬  rµ  )r{  r  rY  Údepthr   r   r   r®  ¶  s   ùzBracketProcessor.findrightc                 C   s   |||… }t dd„ |D ƒƒS )z@Find the max size of the contents between the two given indices.c                 S   rB  r   rC  rD  r   r   r   rF  Æ  rG  z,BracketProcessor.findmax.<locals>.<listcomp>)r  )r{  r  Ú	leftindexr±  Úslicedr   r   r   r¯  Ã  s   zBracketProcessor.findmaxc                 C   s8   |  ¡ }|j dd¡}t|||ƒ}tƒ |_| ¡ |_dS )z+Resize a bracket command to the given size.r±   r+   N)r´   rm  r‰  rh  rG  r  rw  r  )r{  rm  r*  rª  ri  r6  r   r   r   r°  È  s
   zBracketProcessor.resizeN)r   r   r    r!   rý  r­  r¬  rµ  r´  r®  r¯  r°  r   r   r   r   r«  •  s    	r«  c                   @   s   e Zd ZdZdZdd„ ZdS )r`  zShows today's date.Nc                 C   s    t ƒ | _tj ¡  d¡g| _dS )r[  z	%b %d, %YN)rC  r  Údatetimer‘  ÚtodayÚstrftimerÏ   rÁ  r   r   r   rQ  Õ  r|  zTodayCommand.parsebit)r   r   r    r!   rM  rQ  r   r   r   r   r`  Ð  r~  r`  c                   @   sR   e Zd ZdZ	 	 	 	 ddgZdd„ Zdd„ Zdd	„ Zd
d„ Ze	j
dkr'eZdS dS )ÚParameterDefinitionz3The definition of a parameter in a hybrid function.)rè   ré   )rê   rë   c                 C   s"   d | _ d| _d| _d | _d | _d S )NF)ræ  ri  r¸  r…  Úliteralvaluer¾  r   r   r   r|  î  s
   
zParameterDefinition.__init__c                 C   s¨   t jD ]E\}}| |¡rH|dkrd| _| d¡s&t d| ¡  d ¡  dS | ¡ | _| d¡r3d| _	| |¡sDt d| ¡  ¡  dS |   S qt d	| ¡  ¡ dS )
z2Parse a parameter definition: [$0], {$x}, {$1!}...rè   Trô   z$Wrong parameter name, did you mean $ú?Nru  zWrong parameter closing z'Wrong character in parameter template: )
r¼  ÚparambracketsrÖ  r¸  r   r   r’  rŽ  ræ  ri  )r{  rÂ  ÚopeningÚclosingr   r   r   r#  õ  s"   




ôzParameterDefinition.parsec                 C   sf   | j r | jr| |¡| _n| |¡| _| jrt| jƒ| _dS dS | jr+| |¡| _dS | |¡| _dS )z/Read the parameter itself using the definition.N)	ri  r¸  rY  r½  rb  rV   r…  rX  r  )r{  rÂ  rk  r   r   r   Úread  s   ÿzParameterDefinition.readc                 C   s2   d| j  }| jr|dt| jƒ 7 }|S |d7 }|S )r  zparam r  z (empty))ræ  r…  rÑ  rÊ  r   r   r   rí    s   
ÿzParameterDefinition.__unicode__r   N)r   r   r    r!   r¿  r|  r#  rÂ  rí  r	   r   rï  r   r   r   r   r¼  å  s    
	ÿr¼  c                   @   s:   e Zd ZdZ	 dd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚParameterFunctionzFA function with a variable number of parameters defined in a template.c                 C   s8   t ƒ | _|  |¡D ]}| || ¡ || jd|j < q	dS )z*Read the params according to the template.rô   N)rá  ÚparamsÚ	paramdefsrÂ  ræ  ©r{  ÚreadtemplaterÂ  Úparamdefr   r   r   Ú
readparams'  s
   þzParameterFunction.readparamsc                 c   s8   � t |ƒ}| ¡ stƒ  |¡}|r|V  | ¡ r	dS dS )z*Read each param definition in the templateN)rØ  rz  r¼  r#  rÆ  r   r   r   rÅ  .  s   €ýzParameterFunction.paramdefsc                 C   r  )zGet a parameter as parsed.N)rÄ  rç  r   r   r   Úgetparam6  r  zParameterFunction.getparamc                 C   s   |   |¡jS )zGet the value of a parameter.)rÊ  r…  rç  r   r   r   rÆ  <  r¨  zParameterFunction.getvaluec                 C   s   |   |¡}|r
|jsdS |jS )z%Get the literal value of a parameter.N)rÊ  r½  )r{  ræ  r¹  r   r   r   Úgetliteralvalue@  s   

z!ParameterFunction.getliteralvalueN)	r   r   r    r!   rÉ  rÅ  rÊ  rÆ  rË  r   r   r   r   rÃ  #  s    rÃ  c                   @   óV   e Zd ZdZejZdd„ Zdd„ Zdd„ Z	dd	„ Z
d
d„ Zdd„ Zdd„ Zdd„ ZdS )Ú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 <span class="fbox">$1</span>.
  Literal parameters can be used in tags definitions:
    [f0{$1},span style="color: $p;"]
  yields <span style="color: $p;">$1</span>, 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 <hr/>.
  c                 C   s8   | j d }| j d }|  ||¡ |  |¡| _|  ¡  dS )z*Parse a function with [] and {} parametersr   r•  N)rU  rÉ  Úwriteparamsr  Úcomputehybridsize)r{  rÂ  rÇ  Úwritetemplater   r   r   rQ  [  s
   

zHybridFunction.parsebitc                 C   s   |   t|ƒ¡S )z*Write all params according to the template)ÚwriteposrØ  )r{  rÐ  r   r   r   rÎ  c  rÍ  zHybridFunction.writeparamsc                 C   s´   g }|  ¡ sX| d¡r|  |¡}|r| |¡ n<| d¡r-|  |¡}|r,d|_| |¡ n'| d¡r<| |  dd¡¡ n| d¡rK| |  dd¡¡ n	| t| ¡ ƒ¡ |  ¡ r|S )z/Write all params as read in the parse position.rô   ÚfNræ   Úleftrç   Úright)	rz  rÖ  Ú
writeparamr‘  Úwritefunctionrö  ÚwritebracketrV   rŽ  )r{  rÂ  rž  r¹  rk  r   r   r   rÑ  g  s(   


€


€

ñzHybridFunction.writeposc                 C   s^   d|  ¡  }|| jvrt d| ¡ dS | j| sdS | d¡r)| ¡ | j| j_| j| jS )z*Write a single param of the form $0, $x...rô   zUnknown parameter Nr8   )rŽ  rÄ  r   r   rÖ  r   r…  rö  )r{  rÂ  ræ  r   r   r   rÕ  |  s   


zHybridFunction.writeparamc                 C   sz   |   |¡}|s	dS | d¡rtƒ  |¡S | d¡s t d¡ dS | d¡ |  |¡}| ¡  t	|ƒdkr6dS tƒ  
||¡S )z"Write a single function f0,...,fn.NrÂ   rê   z Function should be defined in {}rë   r   )ÚreadtagrÖ  rJ  rM  r   r   r¹  rÑ  r¼  r  r  )r{  rÂ  rK  r  r   r   r   rÖ  ˆ  s   





zHybridFunction.writefunctionc                 C   sÖ   |  ¡  ¡ st d|  ¡  ¡ dS t| ¡ ƒ}d| t| jƒkr-t dt|ƒ d ¡ dS | jd|  }d|vr:|S | j	D ]+}||v rh| j	| }|j
sYt d| d | d	 ¡ q=|jr`|j}nd
}| ||¡}q=|S )zJGet the tag corresponding to the given index. Does parameter substitution.zFunction should be f0,...,f9: fNr‡  z
Function fz is not definedrô   zParameters in tag z should be literal: {z!}r+   )r’  r¢  r   r   rª  rŽ  r  rU  rÑ  rÄ  ri  r½  r‰  )r{  rÂ  rY  rK  Úvariabler¹  r…  r   r   r   rØ  š  s,   

€zHybridFunction.readtagc                 C   s   | j  t¡ ||¡S )z4Return a new bracket looking at the given direction.)r  rñ  ri   r©  r   r   r   r×  ³  r^  zHybridFunction.writebracketc                 C   s>   | j tjvr|  ¡  dS tƒ  | ¡| _| jD ]}| j|_qdS )z(Compute the size of the hybrid function.N)rm  Ú
HybridSizeÚconfigsizesrH  Úgetsizer*  r  r7  r   r   r   rÏ  ·  s   

ÿz HybridFunction.computehybridsizeN)r   r   r    r!   rÒ   rƒ  rM  rQ  rÎ  rÑ  rÕ  rÖ  rØ  r×  rÏ  r   r   r   r   rÍ  G  s    rÍ  c                   @   rZ  )rÚ  z+The size associated with a hybrid function.c                 C   sb   | j |j }|jD ]}||v r|j| j ¡ }| |t|ƒ¡}q	d|v r-t d| ¡ dS t	|ƒS )z*Read the size for a function and parse it.rô   z%Unconverted variable in hybrid size: r•  )
rÛ  rm  rÄ  r…  rH  r‰  rÑ  r   r   Úeval)r{  rk  Ú
sizestringræ  r*  r   r   r   rÜ  Æ  s   
€zHybridSize.getsizeN)r   r   r    r!   rÒ   r„  rÛ  rÜ  r   r   r   r   rÚ  Á  r]  rÚ  c                   @   r÷  )ÚHeaderParserzParses the LyX headerc                    s(   g ‰ ˆ  ˆ‡ ‡‡fdd„¡ ˆ ¡  ˆ S )z?Parse header parameters into a dictionary, return the preamble.c                      r.  rx  )Ú	parseliner   r/  r   r   rû  ã  rÿ  z$HeaderParser.parse.<locals>.<lambda>r3  r"  r   r/  r   r#  à  s   zHeaderParser.parsec                 C   sz   |  ¡ }| tjd ¡r|  |¡ dS | tjd ¡r#tƒ  |¡ dS | tjd ¡r6| | j 	|¡¡ dS |  
|¡ dS )z0Parse a single line as a parameter or as a startr—  Nrœ  r–  )r	  r€  r•  rÚ  ÚparsebranchÚ	LstParserÚparselstsetr‘  r  r  r  )r{  r  r  r  r   r   r   rà  è  s   
zHeaderParser.parselinec                 C   sh   |  ¡  ¡ d }| ¡  tƒ  tjd ¡}| |¡ t|ƒ}|jD ]}| 	||j| ¡ q!|t
j|< dS )zParse all branch definitions.r•  r™  N)r	  r—  r
  rß  r  r•  rÚ  r#  rä  ré  r™  râ  )r{  r  r—  Ú	subparserrz  r„  r   r   r   rá  ÷  s   

zHeaderParser.parsebranchc                 C   rO  )z*Complete the parser with the given ending.)r  )r{  r  r   r   r   r    rQ  zHeaderParser.completeN)r   r   r    r!   r#  rà  rá  r  r   r   r   r   rß  Ý  s    rß  c                   @   s$   e Zd ZdZg Zdd„ Zdd„ ZdS )ÚPreambleParserzA parser for the LyX preamble.c                    s&   t jd ˆ_ˆ ˆ ‡ ‡fdd„¡ g S )z,Parse the full preamble with all statements.rš  c                      s
   ˆ  ˆ ¡S rx  )Úparsepreambleliner   ©r  r{  r   r   rû    rú  z&PreambleParser.parse.<locals>.<lambda>)r•  rÚ  r  r  r"  r   rç  r   r#    s   zPreambleParser.parsec                 C   s   t j | ¡ ¡ | ¡  dS )zParse a single preamble line.N)rå  Úpreambler‘  r	  r
  r"  r   r   r   ræ    rÌ  z PreambleParser.parsepreamblelineN)r   r   r    r!   rè  r#  ræ  r   r   r   r   rå    r�  rå  c                   @   ó6   e Zd ZdZeƒ Zdd„ Zdd„ Zdd„ Zdd	„ Z	d
S )râ  z!Parse global and local lstparams.c                 C   sN   |   |¡}d|vrt d| ¡ dS | d¡d }|dd… }|  |¡t_dS )z+Parse a declaration of lstparams in lstset.rê   z#Missing opening bracket in lstset: Nr•  r   )Úextractlstsetr   r   r—  Úparselstparamsrâ  Úglobalparams)r{  r  r	  ÚlefttextÚcroppedtextr   r   r   rã    s   
zLstParser.parselstsetc                 C   sD   d}|  ¡ s|| ¡ 7 }| ¡  | d¡r|S |  ¡ rt d¡ dS )z%Extract the global lstset parameters.r+   rë   z0Could not find end of \lstset settings; abortingN)rz  r	  r
  r–  r   r   )r{  r  r	  r   r   r   rê  &  s   
üzLstParser.extractlstsetc                 C   s,   t j ¡ |_| d¡}|j |  |¡¡ dS )z-Parse some lstparams from elyxer.a container.Ú	lstparamsN)râ  rì  rŸ  rï  r
  Úupdaterë  )r{  r  Ú	paramlistr   r   r   r  0  s   
zLstParser.parsecontainerc                 C   sT   t ƒ }|D ]"}d|vrt| ¡ ƒdkrt d| ¡ q| dd¡\}}|||< q|S )z1Process a number of lstparams from elyxer.a list.re  r   zInvalid listing parameter r•  )rá  r  r  r   r   r—  )r{  rñ  Ú	paramdictr¹  r„  r…  r   r   r   rë  6  s   €
zLstParser.parselstparamsN)
r   r   r    r!   rá  rì  rã  rê  r  rë  r   r   r   r   râ    s    

râ  c                   @   ré  )r]  z0A function that defines a new command (a macro).c                 C   s`   t ƒ | _d| _g | _d| j_|  |¡ d| j_t d| j	 d t
| jƒ d ¡ | | j| j	< dS )z*Parse the function that defines the macro.r   TFzNew command rÈ  z parameters)N)rB  r  ÚparameternumberÚdefaultsr  r•  Úparseparametersr   r   Ú
newcommandrÑ  ÚmacrosrÁ  r   r   r   rQ  J  s   
ÿÿzMacroDefinition.parsebitc                 C   s^   	 |   |¡| _|  |¡}|rt|ƒ| _|  |¡}|r'| j |¡ |  |¡}|s|  |¡| _	dS )zDParse all optional parameters (number of parameters, default values)N)
Úparsenewcommandrö  rY  rª  ró  rX  rô  r‘  r  Ú
definition)r{  rÂ  ri  r6  r   r   r   rõ  V  s   



þzMacroDefinition.parseparametersc                 C   sZ   | j  |¡ | j  t|¡r|  |¡S | j  t|¡r"| j  t¡ |¡S t 	d| 
¡  ¡ dS )z"Parse the name of the new command.z,Unknown formula bit in defining function at r&  )r  r�  r�  r\   rb  rF  rñ  rI  r   r   rÏ  rÁ  r   r   r   rø  f  s   
zMacroDefinition.parsenewcommandc                 C   rã  )z Return an instance of the macro.)rù  rô  r¾  r   r   r   r4  p  r[  zMacroDefinition.instantiateN)
r   r   r    r!   rá  r÷  rQ  rõ  rø  r4  r   r   r   r   r]  E  s    
r]  c                   @   r4  )ÚMacroParameterz A parameter from elyxer.a macro.c                 C   s
   |  d¡S )zFind a macro parameter: #n.ró   )r”  rÁ  r   r   r   rP  w  r[  zMacroParameter.detectc                 C   sV   |  d¡st d¡ dS t| ¡ ƒ| _dt| jƒ | _tƒ  	dt| jƒ d¡g| _
dS )zParse the parameter: #n.ró   zMissing parameter start #.Nr”  )rÖ  r   r   rª  rŽ  r“  rÑ  ró  rJ  r  r  rÁ  r   r   r   rQ  {  s   

 zMacroParameter.parsebitNrR  r   r   r   r   rú  t  rA  rú  c                   @   rÌ  )ÚMacroFunctionz*A function that was defined using a macro.c                 C   s.   t ƒ | _g | _| j}|  ||¡ |  |¡ dS )z#Parse a number of input parameters.N)rY  r  ÚvaluesrU  rõ  Úcompletemacro©r{  rÂ  Úmacror   r   r   rQ  ‰  s
   zMacroFunction.parsebitc                 C   sT   |   |t|jƒ¡ |  ||jt|jƒ ¡ t| jƒ|jk r(t dt	| ƒ ¡ dS dS )z'Parse as many parameters as are needed.zMissing parameters in macro N)
Úparseoptionalr�  rô  Úparsemandatoryró  r  rü  r   r   rÑ  rþ  r   r   r   rõ  ‘  s
   ÿzMacroFunction.parseparametersc                 C   sŽ   g }| j  t|¡r!| |  |¡¡ t|ƒt|ƒkrn| j  t|¡s	|D ]}| ¡ }t|jƒdkr7| j |¡ q#| j |¡ q#|  j|7  _dS )zParse optional parameters.r   N)	r  r�  rj  r‘  rX  r  rº  r  rü  )r{  rÂ  rô  r¸  r…  r'   r   r   r   r   ˜  s   ýzMacroFunction.parseoptionalc                 C   s8   t |ƒD ]}|  ||| ¡}|s dS | j |¡ qdS )z'Parse a number of mandatory parameters.N)rp  Úparsemacroparameterrü  r‘  )r{  rÂ  r“  rY  rV  r   r   r   r  §  s   üzMacroFunction.parsemandatoryc                 C   s@   	 	 | j  |¡ | ¡ rdS | j  t|¡r|  ||¡S |  |¡S )z?Parse a macro parameter. Could be a bracket or a single letter.N)r  r�  rz  r�  r_   Úparsenumbersr  )r{  rÂ  Ú	remainingr   r   r   r  ¯  s   
z!MacroFunction.parsemacroparameterc                 C   s^   	 | j  t|¡}t|jƒ|ks|S |jD ]}| j  t¡}| t|ƒ¡ ||_| j	 
|¡ qdS )z3Parse the remaining parameters as a running number.N)r  r'  r_   r  ró  rñ  r¶  rV   rö  rü  r‘  )r{  rÂ  r  r“  Údigitr…  r   r   r   r  º  s   
zMacroFunction.parsenumbersc                 C   s¨   |  ¡ g| _dgt| jƒ }|  t¡D ]'}|jd }|t| jƒkr-t dt	|ƒ ¡  dS d||< | j|  
¡ g|_qtt| jƒƒD ]}|| sQ|  || j| ¡ qBdS )z,Complete the macro with the parameters read.Fr•  z%Macro parameter index out of bounds: NT)r4  r  r  rü  rý  rú  r“  r   r   rÑ  rô  rp  r]  )r{  rÿ  r:   rV  rY  r   r   r   rý  Ç  s   
€þzMacroFunction.completemacroc                 C   s6   dt |d ƒ }d | jd  ¡ ¡}| j ||¡ dS )z@Add a filter for the given parameter number and parameter value.ró   r•  r+   r   N)rÑ  Újoinrü  r=  r  r]  )r{  rY  r…  ró  r   r   r   r]  Ö  s   zMacroFunction.addfilterN)r   r   r    r!   r]  r÷  rM  rQ  rõ  r   r  r  r  rý  r]  r   r   r   r   rû  „  s    rû  c                   @   r  )r‹   z!A math macro defined in an inset.c                 C   r  rx  )r;  r�  rB  r  r¾  r   r   r   r|  ß  r  zFormulaMacro.__init__c                 C   r?  )r  z
Math macror   r¾  r   r   r   rí  ã  r$  zFormulaMacro.__unicode__r   Nr  r   r   r   r   r‹   Ü  rm  r‹   c                 C   s2   t ƒ }| | ¡}tƒ  |¡ | ¡  d | ¡ ¡S )zConvert some TeX math to HTML.r+   )r~  r-  rn  rý  r  r=  )r.  r  r  r   r   r   Ú	math2htmló  s
   
r  c                  C   sH   t j} tƒ  | ¡ t| ƒdkrt d¡ tƒ  t| d ƒ}t 	|¡ dS )z=Main function, called if invoked from elyxer.the command liner•  z"Usage: math2html.py escaped_stringr   N)
r	   Úargvr™  r†  r  r   r   r   r  r   )rƒ  rž  r   r   r   Úmainû  s   
r	  Ú__main__)©rh  r¹  r�  ÚioÚos.pathrº  r	   Úunicodedatar   Úurllib.parser   Úurllibr  rÑ  r�  ÚIOBaserg  Úobjectr   r#   r6   r;   r¹   rÒ   r�  r•  rÜ  rç  rê  rð  rý  r,  r/  rR  rw  r™  rä  rð  rø  r  r   r'  r-  r0  r1  r5  r9  r:  rB  rC  rG  rJ  rY  r`  rd  r~  rˆ  rŠ  rÀ  rÌ  rØ  râ  ré  rq   r©   rT   rU   rX   r  r$  r;  r<  rJ  rV   r]   rh   r_   rC  rY  r\   rj  rk  rn  r[   r‹  r~  r–  rÍ  r£  rÍ  rÏ  rí  rê  rë  rð  r“   rª   rE   rM   rS   rC   rO   r?   rR   rF   r=   rZ   r¨   rš   r–   r<   r¬   r­   r  rQ   r¯   r!  rz   r‡   r"  r(  r)  r}   r�   rF  rT  ra   r^  r`   rb   rc   rd   rc  re   r’  re  rh  ry  r  r�  r…  rŒ  r�  r’  r•  r—  rf   rg   rœ  r\  rž  ri   r«  r`  rr  r¼  rÃ  rÍ  rÚ  rß  rå  râ  r]  rú  rû  r‹   r  r	  r   r   r   r   r   Ú<module>   sv  

0D    V#,D ]-Q#	


BD(vC;#> 6!h0F8oI6]n 

</5@U;		


þB
+F;ÿÿ>$z
*./Xÿ

ÿ