summaryrefslogtreecommitdiff
path: root/doc/docs/formatters.rst
diff options
context:
space:
mode:
authorTim Hatch <tim@timhatch.com>2014-04-23 16:48:10 -0400
committerTim Hatch <tim@timhatch.com>2014-04-23 16:48:10 -0400
commit690a2bdfa924f76fd374e25bd9772c2090cf6414 (patch)
tree576991298817f1055da24857df6982dc2bd37d5a /doc/docs/formatters.rst
parent1d9f7f4f19c49a22ecd119f58580f9bc5ccd5080 (diff)
parentb69477dc22e228cde4c1d39bf11b292b88d95fe1 (diff)
downloadpygments-690a2bdfa924f76fd374e25bd9772c2090cf6414.tar.gz
Merged in lefticus/pygments-main (pull request #24)
Conflicts: pygments/lexers/_mapping.py pygments/lexers/agile.py
Diffstat (limited to 'doc/docs/formatters.rst')
-rw-r--r--doc/docs/formatters.rst48
1 files changed, 48 insertions, 0 deletions
diff --git a/doc/docs/formatters.rst b/doc/docs/formatters.rst
new file mode 100644
index 00000000..9e7074e8
--- /dev/null
+++ b/doc/docs/formatters.rst
@@ -0,0 +1,48 @@
+.. -*- mode: rst -*-
+
+====================
+Available formatters
+====================
+
+This page lists all builtin formatters.
+
+Common options
+==============
+
+All formatters support these options:
+
+`encoding`
+ If given, must be an encoding name (such as ``"utf-8"``). This will
+ be used to convert the token strings (which are Unicode strings)
+ to byte strings in the output (default: ``None``).
+ It will also be written in an encoding declaration suitable for the
+ document format if the `full` option is given (e.g. a ``meta
+ content-type`` directive in HTML or an invocation of the `inputenc`
+ package in LaTeX).
+
+ If this is ``""`` or ``None``, Unicode strings will be written
+ to the output file, which most file-like objects do not support.
+ For example, `pygments.highlight()` will return a Unicode string if
+ called with no `outfile` argument and a formatter that has `encoding`
+ set to ``None`` because it uses a `StringIO.StringIO` object that
+ supports Unicode arguments to `write()`. Using a regular file object
+ wouldn't work.
+
+ .. versionadded:: 0.6
+
+`outencoding`
+ When using Pygments from the command line, any `encoding` option given is
+ passed to the lexer and the formatter. This is sometimes not desirable,
+ for example if you want to set the input encoding to ``"guess"``.
+ Therefore, `outencoding` has been introduced which overrides `encoding`
+ for the formatter if given.
+
+ .. versionadded:: 0.7
+
+
+Formatter classes
+=================
+
+All these classes are importable from :mod:`pygments.formatters`.
+
+.. pygmentsdoc:: formatters