3 pygments.formatters.svg |
3 pygments.formatters.svg |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Formatter for SVG output. |
6 Formatter for SVG output. |
7 |
7 |
8 :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
|
12 from __future__ import unicode_literals |
|
13 |
11 |
14 from pygments.formatter import Formatter |
12 from pygments.formatter import Formatter |
15 from pygments.util import get_bool_opt, get_int_opt |
13 from pygments.util import get_bool_opt, get_int_opt |
16 |
14 |
17 __all__ = ['SvgFormatter'] |
15 __all__ = ['SvgFormatter'] |
35 coordinates containing ``<tspan>`` elements with the individual token styles. |
33 coordinates containing ``<tspan>`` elements with the individual token styles. |
36 |
34 |
37 By default, this formatter outputs a full SVG document including doctype |
35 By default, this formatter outputs a full SVG document including doctype |
38 declaration and the ``<svg>`` root element. |
36 declaration and the ``<svg>`` root element. |
39 |
37 |
40 *New in Pygments 0.9.* |
38 .. versionadded:: 0.9 |
41 |
39 |
42 Additional options accepted: |
40 Additional options accepted: |
43 |
41 |
44 `nowrap` |
42 `nowrap` |
45 Don't wrap the SVG ``<text>`` elements in ``<svg><g>`` elements and |
43 Don't wrap the SVG ``<text>`` elements in ``<svg><g>`` elements and |
78 name = 'SVG' |
76 name = 'SVG' |
79 aliases = ['svg'] |
77 aliases = ['svg'] |
80 filenames = ['*.svg'] |
78 filenames = ['*.svg'] |
81 |
79 |
82 def __init__(self, **options): |
80 def __init__(self, **options): |
83 # XXX outencoding |
|
84 Formatter.__init__(self, **options) |
81 Formatter.__init__(self, **options) |
85 self.nowrap = get_bool_opt(options, 'nowrap', False) |
82 self.nowrap = get_bool_opt(options, 'nowrap', False) |
86 self.fontfamily = options.get('fontfamily', 'monospace') |
83 self.fontfamily = options.get('fontfamily', 'monospace') |
87 self.fontsize = options.get('fontsize', '14px') |
84 self.fontsize = options.get('fontsize', '14px') |
88 self.xoffset = get_int_opt(options, 'xoffset', 0) |
85 self.xoffset = get_int_opt(options, 'xoffset', 0) |