Ńň ŽfŻJc@s‰dZddklZddklZlZddklZlZl Z dgZ d„Z dZ dZ d „Zdefd „ƒYZd S( sŰ pygments.formatters.latex ~~~~~~~~~~~~~~~~~~~~~~~~~ Formatter for LaTeX fancyvrb output. :copyright: Copyright 2006-2009 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. i˙˙˙˙(t Formatter(tTokentSTANDARD_TYPES(t get_bool_optt get_int_opttStringIOtLatexFormattercCsX|iddƒiddƒiddƒidd|ƒidd|ƒidd |ƒS( Nt@tt[st]ss@%sZat[]s@%sZlb[]s@%sZrb[](treplace(ttextt commandprefix((s=/usr/lib/python2.6/site-packages/pygments/formatters/latex.pyt escape_texs   sČ \documentclass{%(docclass)s} \usepackage{fancyvrb} \usepackage{color} \usepackage[%(encoding)s]{inputenc} %(preamble)s %(styledefs)s \begin{document} \section*{%(title)s} %(code)s \end{document} s: \makeatletter \def\%(cp)s@reset{\let\%(cp)s@it=\relax \let\%(cp)s@bf=\relax%% \let\%(cp)s@ul=\relax \let\%(cp)s@tc=\relax%% \let\%(cp)s@bc=\relax \let\%(cp)s@ff=\relax} \def\%(cp)s@tok#1{\csname %(cp)s@tok@#1\endcsname} \def\%(cp)s@toks#1+{\ifx\relax#1\empty\else%% \%(cp)s@tok{#1}\expandafter\%(cp)s@toks\fi} \def\%(cp)s@do#1{\%(cp)s@bc{\%(cp)s@tc{\%(cp)s@ul{%% \%(cp)s@it{\%(cp)s@bf{\%(cp)s@ff{#1}}}}}}} \def\%(cp)s#1#2{\%(cp)s@reset\%(cp)s@toks#1+\relax+\%(cp)s@do{#2}} %(styles)s \def\%(cp)sZat{@} \def\%(cp)sZlb{[} \def\%(cp)sZrb{]} \makeatother cCsdti|ƒ}|o|Sd}x8|djo*|d|}|i}ti|ƒ}q$W||S(Nti˙˙˙˙(RtgettNonetparent(tttypetfnametaname((s=/usr/lib/python2.6/site-packages/pygments/formatters/latex.pyt_get_ttype_namefs  cBsPeZdZdZddgZdgZd„Zd„Zdd„Zd „Z RS( s^ Format tokens as LaTeX code. This needs the `fancyvrb` and `color` standard packages. Without the `full` option, code is formatted as one ``Verbatim`` environment, like this: .. sourcecode:: latex \begin{Verbatim}[commandchars=@\[\]] @PY[k][def ]@PY[n+nf][foo](@PY[n][bar]): @PY[k][pass] \end{Verbatim} The special command used here (``@PY``) and all the other macros it needs are output by the `get_style_defs` method. With the `full` option, a complete LaTeX document is output, including the command definitions in the preamble. The `get_style_defs()` method of a `LatexFormatter` returns a string containing ``\def`` commands defining the macros needed inside the ``Verbatim`` environments. Additional options accepted: `style` The style to use, can be a string or a Style subclass (default: ``'default'``). `full` Tells the formatter to output a "full" document, i.e. a complete self-contained document (default: ``False``). `title` If `full` is true, the title that should be used to caption the document (default: ``''``). `docclass` If the `full` option is enabled, this is the document class to use (default: ``'article'``). `preamble` If the `full` option is enabled, this can be further preamble commands, e.g. ``\usepackage`` (default: ``''``). `linenos` If set to ``True``, output line numbers (default: ``False``). `linenostart` The line number for the first line (default: ``1``). `linenostep` If set to a number n > 1, only every nth line number is printed. `verboptions` Additional options given to the Verbatim environment (see the *fancyvrb* docs for possible values) (default: ``''``). `commandprefix` The LaTeX commands used to produce colored output are constructed using this prefix and some letters (default: ``'PY'``). *New in Pygments 0.7.* *New in Pygments 0.10:* the default is now ``'PY'`` instead of ``'C'``. tLaTeXtlatexttexs*.texcKsŇti|||iddƒ|_|iddƒ|_t|dtƒ|_tt |ddƒƒ|_ tt |ddƒƒ|_ |id dƒ|_ t|d tƒ|_ |id d ƒ|_|iƒdS( NtdocclasstarticletpreambleRtlinenost linenostartit linenostept verboptionst nobackgroundR tPY(Rt__init__RRRRtFalseRtabsRRRR R!R t_create_stylesheet(tselftoptions((s=/usr/lib/python2.6/site-packages/pygments/formatters/latex.pyR#šsc Cs¸hdt6}|_h}|_|i}d„}x~|iD]s\}}t|ƒ}d}|do|d7}n|do|d7}n|do|d7}n|d o|d 7}n|d o|d 7}n|d o|d 7}n|do|d||dƒ7}n|do,|d||dƒ||dƒf7}n(|do|d||dƒ7}n|djoq=n|id|ƒ}|||<|||s tstyles(R R:t iteritemstappendtSTYLE_TEMPLATER*(R'targR>RBR@t definition((s=/usr/lib/python2.6/site-packages/pygments/formatters/latex.pytget_style_defsňs  cCsv|i}|i}|io|}tƒ}n|idƒ|ioP|i|i}}|id|o d|pd|o d|pdƒn|io|id|iƒn|idƒx8|D]0\}} t | |iƒ} g} xY|t j oKy| i ||ƒWn&t j o| i t |ƒƒnX|i}qóWdit| ƒƒ} | o‡| id ƒ} xD| d D]8} | o|id || | fƒn|id ƒq‚W| d o"|id || | d fƒqüqĚ|i| ƒqĚW|id ƒ|io[|ittd |id|id|id|ipdd|iƒd|iƒƒƒndS(Ns#\begin{Verbatim}[commandchars=@\[\]s ,numbers=lefts,firstnumber=%dRs,stepnumber=%dR)s] t+s i˙˙˙˙s @%s[%s][%s]s\end{Verbatim} RRttitletencodingtlatin1t styledefstcode(R9R tfullRtwriteRRRR RRRDtKeyErrorRRR*treversedtsplitt DOC_TEMPLATEtdictRRRJRKRHtgetvalue(R't tokensourcetoutfileR<R>t realoutfiletstarttstepRtvalueRBtstylevaltspltline((s=/usr/lib/python2.6/site-packages/pygments/formatters/latex.pytformat_unencodedţsZ            &      ( t__name__t __module__t__doc__R@taliasest filenamesR#R&RHR`(((s=/usr/lib/python2.6/site-packages/pygments/formatters/latex.pyRrsB    + N(Rctpygments.formatterRtpygments.tokenRRt pygments.utilRRRt__all__RRTRERR(((s=/usr/lib/python2.6/site-packages/pygments/formatters/latex.pyt s  7