3 pygments.formatter |
3 pygments.formatter |
4 ~~~~~~~~~~~~~~~~~~ |
4 ~~~~~~~~~~~~~~~~~~ |
5 |
5 |
6 Base formatter class. |
6 Base formatter class. |
7 |
7 |
8 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS. |
8 :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS. |
9 :license: BSD, see LICENSE for details. |
9 :license: BSD, see LICENSE for details. |
10 """ |
10 """ |
11 |
11 |
12 import codecs |
12 import codecs |
13 |
13 |
14 from pygments.util import get_bool_opt, string_types |
14 from pygments.util import get_bool_opt |
15 from pygments.styles import get_style_by_name |
15 from pygments.styles import get_style_by_name |
16 |
16 |
17 __all__ = ['Formatter'] |
17 __all__ = ['Formatter'] |
18 |
18 |
19 |
19 |
20 def _lookup_style(style): |
20 def _lookup_style(style): |
21 if isinstance(style, string_types): |
21 if isinstance(style, str): |
22 return get_style_by_name(style) |
22 return get_style_by_name(style) |
23 return style |
23 return style |
24 |
24 |
25 |
25 |
26 class Formatter(object): |
26 class Formatter: |
27 """ |
27 """ |
28 Converts a token stream to text. |
28 Converts a token stream to text. |
29 |
29 |
30 Options accepted: |
30 Options accepted: |
31 |
31 |