Debian Codegraph @

doc/docs/formatters.rst

raw
1 .. -*- mode: rst -*-
2
3 ====================
4 Available formatters
5 ====================
6
7 This page lists all builtin formatters.
8
9 Common options
10 ==============
11
12 All formatters support these options:
13
14 `encoding`
15 If given, must be an encoding name (such as ``"utf-8"``). This will
16 be used to convert the token strings (which are Unicode strings)
17 to byte strings in the output (default: ``None``).
18 It will also be written in an encoding declaration suitable for the
19 document format if the `full` option is given (e.g. a ``meta
20 content-type`` directive in HTML or an invocation of the `inputenc`
21 package in LaTeX).
22
23 If this is ``""`` or ``None``, Unicode strings will be written
24 to the output file, which most file-like objects do not support.
25 For example, `pygments.highlight()` will return a Unicode string if
26 called with no `outfile` argument and a formatter that has `encoding`
27 set to ``None`` because it uses a `StringIO.StringIO` object that
28 supports Unicode arguments to `write()`. Using a regular file object
29 wouldn't work.
30
31 .. versionadded:: 0.6
32
33 `outencoding`
34 When using Pygments from the command line, any `encoding` option given is
35 passed to the lexer and the formatter. This is sometimes not desirable,
36 for example if you want to set the input encoding to ``"guess"``.
37 Therefore, `outencoding` has been introduced which overrides `encoding`
38 for the formatter if given.
39
40 .. versionadded:: 0.7
41
42
43 Formatter classes
44 =================
45
46 All these classes are importable from :mod:`pygments.formatters`.
47
48 .. pygmentsdoc:: formatters