ó Y-Qc@s^dZddlmZddlmZmZdgZd„ZiZdefd„ƒYZ dS(sÌ pygments.formatters.svg ~~~~~~~~~~~~~~~~~~~~~~~ Formatter for SVG output. :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. iÿÿÿÿ(t Formatter(t get_bool_optt get_int_optt SvgFormattercCs@|jddƒjddƒjddƒjddƒjd d ƒS( s<Escape &, <, > as well as single and double quotes for HTML.t&s&ts>t"s"t's'(treplace(ttext((sA/usr/local/lib/python2.7/site-packages/pygments/formatters/svg.pyt escape_htmls    cBsAeZdZdZdgZdgZd„Zd„Zd„ZRS(sl Format tokens as an SVG graphics file. This formatter is still experimental. Each line of code is a ```` element with explicit ``x`` and ``y`` coordinates containing ```` elements with the individual token styles. By default, this formatter outputs a full SVG document including doctype declaration and the ```` root element. *New in Pygments 0.9.* Additional options accepted: `nowrap` Don't wrap the SVG ```` elements in ```` elements and don't add a XML declaration and a doctype. If true, the `fontfamily` and `fontsize` options are ignored. Defaults to ``False``. `fontfamily` The value to give the wrapping ```` element's ``font-family`` attribute, defaults to ``"monospace"``. `fontsize` The value to give the wrapping ```` element's ``font-size`` attribute, defaults to ``"14px"``. `xoffset` Starting offset in X direction, defaults to ``0``. `yoffset` Starting offset in Y direction, defaults to the font size if it is given in pixels, or ``20`` else. (This is necessary since text coordinates refer to the text baseline, not the top edge.) `ystep` Offset to add to the Y coordinate for each subsequent line. This should roughly be the text size plus 5. It defaults to that value if the text size is given in pixels, or ``25`` else. `spacehack` Convert spaces in the source to `` ``, which are non-breaking spaces. SVG provides the ``xml:space`` attribute to control how whitespace inside tags is handled, in theory, the ``preserve`` value could be used to keep all whitespace as-is. However, many current SVG viewers don't obey that rule, so this option is provided as a workaround and defaults to ``True``. t���SVGt���svgs���*.svgc���������K���s��t��j�|��|��t�|�d�t�ƒ�|��_�|�j�d�d�ƒ�|��_�|�j�d�d�ƒ�|��_�t�|�d�d�ƒ�|��_ �|��j�j �ƒ��}�|�j �d�ƒ�r•�|�d � j �ƒ��}�n��y�t �|�ƒ�}�Wn �d �}�n�Xt�|�d �|�ƒ�|��_ �t�|�d �|�d �ƒ�|��_�t�|�d�t�ƒ�|��_�i��|��_�d��S(���Nt���nowrapt ���fontfamilyt ���monospacet���fontsizet���14pxt���xoffseti����t���pxiþÿÿÿi���t���yoffsett���ystepi���t ���spacehack(���R����t���__init__R���t���FalseR���t���getR���R���R���R���t���stript���endswitht���intR���R���t���TrueR���t ���_stylecache(���t���selft���optionst���fst���int_fs(����(����sA���/usr/local/lib/python2.7/site-packages/pygments/formatters/svg.pyR���P���s ����� c��� ������C���s»��|��j��}�|��j�}�|��j�s‚�|��j�r;�|�j�d�|��j�ƒ�n �|�j�d�ƒ�|�j�d�ƒ�|�j�d�ƒ�|�j�d�|��j�|��j�f�ƒ�n��|�j�d�|�|�f�ƒ�xõ�|�D]í�\�}�}�|��j�|�ƒ�}�|�rÏ�d�|�d�pÒ�d �}�|�rá�d �pä�d �} �t�|�ƒ�}�|��j �r|�j �ƒ��j �d �d �ƒ�}�n��|�j �d �ƒ�} �xK�| �d� D]?�} �|�j�|�| �| �ƒ�|�|��j �7}�|�j�d�|�|�f�ƒ�q1W|�j�|�| �d�| �ƒ�q �W|�j�d�ƒ�|��j�s·|�j�d�ƒ�n��d�S(���sÏ��� Format ``tokensource``, an iterable of ``(tokentype, tokenstring)`` tuples and write it into ``outfile``. For our implementation we put all lines in their own 'line group'. s$��� s��� sk��� s)��� s$��� s)���s���t��� s��� s��� iÿÿÿÿs1��� s���s ��� N(���R���R���R���t���encodingt���writeR���R���t ���_get_styleR ���R���t ���expandtabsR ���t���splitR���( ���R ���t ���tokensourcet���outfilet���xt���yt���ttypet���valuet���stylet���tspant���tspanendt���partst���part(����(����sA���/usr/local/lib/python2.7/site-packages/pygments/formatters/svg.pyt���format_unencodedb���s:����               c���������C���s¸���|�|��j��k�r�|��j��|�S|�}�x�|��j�j�|�ƒ�sA�|�j�}�q#�W|��j�j�|�ƒ�}�d�}�|�d�ry�d�|�d�d�}�n��|�d�r�|�d�7}�n��|�d�r§�|�d�7}�n��|�|��j��|�<|�S( ���NR$���t���colors��� fill="#R���t���bolds��� font-weight="bold"t���italics��� font-style="italic"(���R���R1���t ���styles_tokent���parentt���style_for_token(���R ���t ���tokentypet ���otokentypeR0���t���result(����(����sA���/usr/local/lib/python2.7/site-packages/pygments/formatters/svg.pyR(���‹���s����        ( ���t���__name__t ���__module__t���__doc__t���namet���aliasest ���filenamesR���R6���R(���(����(����(����sA���/usr/local/lib/python2.7/site-packages/pygments/formatters/svg.pyR������s���.    )N( ���RB���t���pygments.formatterR����t ���pygments.utilR���R���t���__all__R ���t ���class2styleR���(����(����(����sA���/usr/local/lib/python2.7/site-packages/pygments/formatters/svg.pyt��� ���s ���