ó ÿgdSc@s›dZddlZddlZddlZddlZddlZddlmZmZm Z ddl m Z m Z yddl mZWn!ek r«ddlmZnXddlmZddlmZdd lmZmZdd lmZmZdd lmZmZdd lmZ m!Z!d efd„ƒYZ"dZ#dZ$dZ%ej&edƒƒZ'd„Z(d„Z)d„Z*d„Z+d„Z,d„Z-dS(sÆ sphinx.ext.pngmath ~~~~~~~~~~~~~~~~~~ Render math in HTML via dvipng. :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. iÿÿÿÿN(tpathtgetcwdtchdir(tPopentPIPE(tsha1(tsha(tnodes(t SphinxError(tread_png_depthtwrite_png_depth(t ensuredirtENOENT(tbt sys_encoding(t setup_mathtwrap_displaymatht MathExtErrorcBseZdZddd„ZRS(sMath extension errorcCsZ|r#|d|jtdƒ7}n|rF|d|jtdƒ7}ntj||ƒdS(Ns [stderr] treplaces [stdout] (tdecodeRRt__init__(tselftmsgtstderrtstdout((s</usr/local/lib/python2.7/site-packages/sphinx/ext/pngmath.pyR#s N(t__name__t __module__tcategorytNoneR(((s</usr/local/lib/python2.7/site-packages/sphinx/ext/pngmath.pyR ss² \documentclass[12pt]{article} \usepackage[utf8x]{inputenc} \usepackage{amsmath} \usepackage{amsthm} \usepackage{amssymb} \usepackage{amsfonts} \usepackage{bm} \pagestyle{empty} s$ \begin{document} %s \end{document} s_ \usepackage[active]{preview} \begin{document} \begin{preview} %s \end{preview} \end{document} s\[\d+ depth=(-?\d+)\]cCsé|jjj}t|jjj}||r1tp4t|7}dt|jdƒƒj ƒ}t j |jj d|ƒ}t j |jjdd|ƒ}t j|ƒr¹t|ƒ}||fSt|jdƒsÝt|jdƒrádSt|jdƒs tjƒ}|j_n |jj}tjt j |dƒd dƒ} | j|ƒ| jƒ|jjjd g} | j|jjjƒ| jdƒtƒ} t|ƒzuyt | d t!d t!ƒ} WnRt"k r} | j#t$krá‚n|jj%d |jjjƒt&|j_'dSXWdt| ƒX| j(ƒ\}}| j)dkrTt*d||ƒ‚nt+t j,|ƒƒ|jjj-g}|d|dddg7}|j|jjj.ƒ|r¾|jdƒn|jt j |dƒƒyt |d t!d t!ƒ} WnRt"k rG} | j#t$kr‚n|jj%d|jjj-ƒt&|j_/dSX| j(ƒ\}}| j)dkr~t*d||ƒ‚nd}|rßxR|j0ƒD]A}t1j2|ƒ}|r—t3|j4dƒƒ}t5||ƒPq—q—Wn||fS(srRender the LaTeX math expression *math* using latex and dvipng. Return the filename relative to the built document and the "depth", that is, the distance of image bottom and baseline in pixels, if the option to use preview_latex is switched on. Error handling may seem strange, but follows a pattern: if LaTeX or dvipng aren't available, only a warning is generated (since that enables people on machines without these programs to at least build the rest of the docs successfully). If the programs are there, however, they may not fail since that indicates a problem in the math source. s%s.pngsutf-8tmatht_imagest_mathpng_warned_latext_mathpng_warned_dvipngt_mathpng_tempdirsmath.textws--interaction=nonstopmodeRRsYLaTeX command %r cannot be run (needed for math display), check the pngmath_latex settingNislatex exited with errors-os-Tttights-z9s--depthsmath.dvis[dvipng command %r cannot be run (needed for math display), check the pngmath_dvipng settingsdvipng exited with errori(NN(NN(NN(6tbuildertconfigtpngmath_use_previewtDOC_HEADtpngmath_latex_preambletDOC_BODY_PREVIEWtDOC_BODYRtencodet hexdigestt posixpathtjointimgpathRtoutdirtisfileR thasattrRttempfiletmkdtempR!tcodecstopentwritetcloset pngmath_latextextendtpngmath_latex_argstappendRRRRtOSErrorterrnoR twarntTrueRt communicatet returncodeRR tdirnametpngmath_dvipngtpngmath_dvipng_argsR t splitlinestdepth_retmatchtinttgroupR (RRt use_previewtlatextshasumtrelfntoutfntdepthttempdirttftltx_argstcurdirtpterrRRt dvipng_argstlinetm((s</usr/local/lib/python2.7/site-packages/sphinx/ext/pngmath.pyt render_mathGs‚    !             cCsO|r dSt|jdƒs dSytj|jjƒWntk rJnXdS(NR!(R2R$tshutiltrmtreeR!t Exception(tapptexc((s</usr/local/lib/python2.7/site-packages/sphinx/ext/pngmath.pytcleanup_tempdir¯s cCs.|jjjr*d|j|dƒjƒSdS(Ns alt="%s"RLt(R$R%tpngmath_add_tooltipsR+tstrip(Rtnode((s</usr/local/lib/python2.7/site-packages/sphinx/ext/pngmath.pyt get_tooltip¹sc Cs0y%t|d|ddƒ\}}Wn|tk r£}t|ƒ}tj|dddddgd|dƒ}|j|ƒ|jjd |d|ƒtj‚nX|dkrÚ|j j d |j |dƒj ƒƒnId |t||ƒ}|dk r|d | 7}n|j j |d ƒtj‚dS(Nt$RLttypetWARNINGtlevelitbackrefstsourcesdisplay latex %r: s%ss(RZRtunicodeRtsystem_messaget walkaboutR$R?tSkipNodeRtbodyR<R+RcRe(RRdtfnameRPR_Rtsmtc((s</usr/local/lib/python2.7/site-packages/sphinx/ext/pngmath.pythtml_visit_math¾s"%      c Cs|dr|d}nt|ddƒ}yt||ƒ\}}Wn|tk rÁ}tjt|ƒdddddgd|dƒ}|j|ƒ|jj d |dt|ƒƒtj ‚nX|j j |j |d d d ƒƒ|j j d ƒ|dr|j j d|dƒn|dkrO|j j d|j|dƒjƒƒn%|j j d|t||ƒdƒtj ‚dS(NtnowrapRLRgRhRiiRjRksinline latex %r: tdivtCLASSRs

tnumbers(%s)s'%s

s

(RRRZRRRmtstrRnR$R?RoRpR<tstarttagR+RcRe(RRdRLRqRPR_Rr((s</usr/local/lib/python2.7/site-packages/sphinx/ext/pngmath.pythtml_visit_displaymathÓs*   " "    cCsÇt|tdftdfƒ|jdddƒ|jdddƒ|jdtdƒ|jddd d d d d gdƒ|jdgdƒ|jdddƒ|jdtdƒ|jdtƒdS(NRDtdvipngthtmlR9RLR&REs-gammas1.5s-Dt110s-bgt TransparentR;R(RaRbsbuild-finished( tmathbase_setupRtRR{tadd_config_valuetFalseR@tconnectR`(R^((s</usr/local/lib/python2.7/site-packages/sphinx/ext/pngmath.pytsetupîs (.t__doc__treR5R[R3R-tosRRRt subprocessRRthashlibRRt ImportErrortdocutilsRt sphinx.errorsRtsphinx.util.pngR R tsphinx.util.osutilR R tsphinx.util.pycompatR Rtsphinx.ext.mathbaseRR€RRR'R*R)tcompileRGRZR`ReRtR{R„(((s</usr/local/lib/python2.7/site-packages/sphinx/ext/pngmath.pyt s8        h