Configuration files are used for persistent customization;
they can be set once and take effect every time you use a component,
e.g., via a front-end tool.
Configuration file settings override the built-in defaults, and
command-line options override all.
For the technicalities, see Docutils Runtime Settings.
By default, Docutils checks the following places for configuration
files, in the following order:
/etc/docutils.conf: This is a system-wide configuration file,
applicable to all Docutils processing on the system.
./docutils.conf: This is a project-specific configuration file,
located in the current directory. The Docutils front end has to be
executed from the directory containing this configuration file for
it to take effect (note that this may have nothing to do with the
location of the source files). Settings in the project-specific
configuration file will override corresponding settings in the
system-wide file.
~/.docutils: This is a user-specific configuration file,
located in the user's home directory. Settings in this file will
override corresponding settings in both the system-wide and
project-specific configuration files.
If more than one configuration file is found, all will be read but
later entries will override earlier ones. For example, a "stylesheet"
entry in a user-specific configuration file will override a
"stylesheet" entry in the system-wide file.
The default implicit config file paths can be overridden by the
DOCUTILSCONFIG environment variable. DOCUTILSCONFIG should
contain a colon-separated (semicolon-separated on Windows) sequence of
config file paths to search for; leave it empty to disable implicit
config files altogether. Tilde-expansion is performed on paths.
Paths are interpreted relative to the current working directory.
Empty path items are ignored.
In addition, a configuration file may be explicitly specified with the
--config command-line option. This configuration file is read after
the three implicit ones listed above (or the ones defined by the
DOCUTILSCONFIG environment variable), and its entries will have
priority.
Configuration files are UTF-8-encoded text files. The
ConfigParser.py module from Python's standard library is used to
read them. From its documentation:
The configuration file consists of sections, lead by a "[section]"
header and followed by "name: value" entries, with continuations
in the style of RFC 822; "name=value" is also accepted. Note
that leading whitespace is removed from values. ... Lines
beginning with "#" or ";" are ignored and may be used to provide
comments.
Configuration file entry names correspond to internal runtime
settings. Underscores ("_") and hyphens ("-") can be used
interchangeably in entry names; hyphens are automatically converted to
underscores.
For on/off switch settings (booleans), the following values are
recognized:
Below are the Docutils runtime settings, listed by config file
section. Any setting may be specified in any section, but only
settings from active sections will be used. Sections correspond to
Docutils components (module name or alias; section names are always in
lowercase letters). Each Docutils application uses a specific set
of components; corresponding configuration file sections are applied
when the application is used. Configuration sections are applied in
general-to-specific order, as follows:
[applications], application dependencies, and the section
specific to the Application (front-end tool) in use
("[... application]").
Since any setting may be specified in any section, this ordering
allows component- or application-specific overrides of earlier
settings. For example, there may be Reader-specific overrides of
general settings; Writer-specific overrides of Parser settings;
Application-specific overrides of Writer settings; and so on.
If multiple configuration files are applicable, the process is
completed (all sections are applied in the order given) for each one
before going on to the next. For example, a "[pep_html writer]
stylesheet" setting in an earlier configuration file would be
overridden by an "[html4css1 writer] stylesheet" setting in a later
file.
Some knowledge of Python is assumed for some attributes.
Prefix prepended to all auto-generated identifier keys generated within
the document, after id_prefix. Ensure the value conforms to the
restrictions on identifiers in the output format, as it is not subjected to
the identifier normalization.
A trailing "%" is replaced with the tag name (new in Docutils 0.16).
Default: "%" (changed in 0.18 from "id").
Option: --auto-id-prefix (hidden, intended mainly for programmatic use).
# Equivalent to --date command-line option, results in
# ISO 8601 extended format datestamp, e.g. "2001-12-21":
datestamp: %Y-%m-%d
# Equivalent to --time command-line option, results in
# date/timestamp like "2001-12-21 18:43 UTC":
datestamp: %Y-%m-%d %H:%M UTC
# Disables datestamp; equivalent to --no-datestamp:
datestamp:
A system message level threshold; non-halting system messages at
or above this level will produce a non-zero exit status at normal
exit. Exit status is the maximum system message level plus 10 (11
for INFO, etc.).
List of internal attributes to expose as external attributes (with
"internal:" namespace prefix). To specify multiple attributes in
configuration files, use colons to separate names; on the command
line, the option may be used more than once.
Default: don't (None).
Option: --expose-internal-attribute (hidden, for development use only).
The threshold at or above which system messages are converted to
exceptions, halting execution immediately. If traceback is set, the
exception will propagate; otherwise, Docutils will exit.
Prefix prepended to all identifier keys generated within the document.
Ensure the value conforms to the restrictions on identifiers in the output
format, as it is not subjected to the identifier normalization.
See also auto_id_prefix.
Sets the document language, also used for localized directive and
role names as well as Docutils-generated text.
A typical language identifier consists of a 2-letter language code
from ISO 639 (3-letter codes can be used if no 2-letter code
exists). The language identifier can have an optional subtag,
typically for variations based on country (from ISO 3166
2-letter country codes). Avoid subtags except where they add
useful distinguishing information. Examples of language tags
include "fr", "en-GB", "pt-br" (the same as "pt-BR"), and
"de-1901" (German with pre-1996 spelling).
The language of document parts can be specified with a
"language-<language tag>" class attribute, e.g.
.. class:: language-el-polyton for a quote in polytonic Greek.
The "output_encoding" setting may also affect the content of the output
(e.g. an encoding declaration in HTML or XML or the representation of
characters as LaTeX macro vs. literal character).
Path to a file where Docutils will write a list of files that were
required to generate the output, e.g. included files or embedded
stylesheets. [2][6] The format is one path per
line with forward slashes as separator, the encoding is UTF-8.
Set to - in order to write dependencies to stdout.
This option is particularly useful in conjunction with programs like
make using Makefile rules like:
When processing a document tree with the Visitor pattern, raise an
error if a writer does not support a node type listed as optional. For
transitional development use.
Default: disabled (None).
Option: --strict-visitor (hidden, for development use only).
Comma-separated list of "classes" attribute values to remove from all
elements in the document tree. The command line option may be used more
than once.
Comma-separated list of "classes" attribute values;
matching elements are removed from the document tree.
The command line option may be used more than once.
The document title as metadata which does not become part of the
document body. Stored as the document's title attribute.
For example, in HTML output the metadata document title
appears in the title bar of the browser window.
Enable Python tracebacks when halt-level system messages and other
exceptions occur. Useful for debugging, and essential for issue
reports. Exceptions are allowed to propagate, instead of being
caught and reported (in a user-friendly way) by Docutils.
Default: disabled (None) unless Docutils is run programmatically
using the Publisher Interface.
Options: --traceback,--no-traceback.
Enable or disable directives inserting the contents of
external files, such as "include" directive
or the "raw" and "csv-table" directives with option "url" or "file".
A "warning" system message (including the directive text) is inserted
instead. (See also raw_enabled for another security-relevant setting.)
Maximal number of characters in an input line or substitution
definition. To prevent extraordinary high processing times or memory
usage for certain input constructs, a "warning" system message is
inserted instead.
Enable or disable the "raw" directive. A "warning" system message
(including the directive text) is inserted instead. See also
file_insertion_enabled for another security-relevant setting.
Allows character level inline markup without escaped whithespace and is
especially suited for languages that do not use whitespace to separate words
(e.g. Japanese, Chinese).
Typographical quotes used by the SmartQuotes transform.
A comma-separated list with language tag and a set of four quotes (primary
open/close, secondary open/close)smartquotes_locales. (If more than one
character shall be used for a quote (e.g. padding in French quotes), a
colon-separated list may be used.)
Example:
Ensure a correct leading apostrophe in 's Gravenhage in Dutch (at the
cost of incorrect opening single quotes) and set French quotes to double
and single guillemets with inner padding:
Enable or disable the promotion of a lone top-level section title
to document title (and subsequent section title to document
subtitle promotion; docutils.transforms.frontmatter.DocTitle).
Scramble email addresses to confuse harvesters. In the reference
URI, the "@" will be replaced by %-escapes (as of RFC 1738). In
the visible text (link text) of an email reference, the "@" and
all periods (".") will be surrounded by <span> tags.
Furthermore, HTML entities are used to encode these characters in
order to further complicate decoding the email address. For
example, "abc@example.org" will be output as:
Remove extra vertical whitespace between items of bullet lists and
enumerated lists, when list items are all "simple" (i.e., items
each contain one paragraph and/or one "simple" sub-list only). The
behaviour can be specified directly via "class" attributes (values
"compact" and "open") in the document.
Remove extra vertical whitespace between items of field lists that
are "simple" (i.e., all field bodies each contain at most one
paragraph). The behaviour can be specified directly via "class"
attributes (values "compact" and "open") in the document.
Embed the stylesheet in the output HTML file. The stylesheet file
must specified by the stylesheet_path setting and must be
accessible during processing.
See also embed_stylesheet [latex writers].
The format of mathematical content (math directive and role) in
the output document. Supported values are (case insensitive):
HTML:
Format math in standard HTML enhanced by CSS rules.
Requires the math.css stylesheet (in the system
stylesheet directory)
A stylesheet_path
can be appended after whitespace. The specified
stylesheet(s) will only be referenced or embedded if required
(i.e. if there is mathematical content in the document).
Self-contained documents (no JavaScript, no external downloads).
MathML is part of the HTML5 standard [4] and
supported by all major browsers (since January 2023 also by Chrome).
A comma-separated list of directories where stylesheets can be found.
Used by the stylesheet_path setting when expanding relative path arguments.
Note: This setting defines a "search path" (similar to the PATH variable for
executables). However, the term "path" is already used in the
stylesheet_path setting with the meaning of a file location.
Default: the working directory of the process at launch and the directory
with default stylesheet files (writer and installation specific).
Use the --help option to get the exact value.
Option: --stylesheet-dirs.
A comma-separated list of paths to CSS stylesheets. Relative paths are
expanded if a matching file is found in the stylesheet_dirs.
If embed_stylesheet is False, paths are rewritten relative to the
output HTML file.
See also stylesheet_path [latex writers].
Also overrides "stylesheet". [7]
Pass an empty string (to either "stylesheet" or "stylesheet_path") to
deactivate stylesheet inclusion.
Only lines above and below the table and a thin line after the head.
captionbelow
Place the table caption below the table
(New in Docutils 0.17).
In addition, the HTML writers support:
colwidths-auto
Delegate the determination of table column widths to the back-end
(leave out the <colgroup> column specification).
Overridden by the "widths" option of the table directive.
colwidths-grid
Write column widths determined from the source to the HTML file.
Overridden by the "widths" option of the table directive.
Default: "template.txt" in the writer's directory (installed automatically;
for the exact machine-specific path, use the --help option).
Option: --template.
The maximum width (in characters) for one-column field names. Longer
field names will span an entire row of the table used to render the field
list. 0 indicates "no limit". See also option_limit.
The maximum width (in characters) for options in option lists.
Longer options will span an entire row of the table used to render
the option list. 0 indicates "no limit".
See also field_name_limit.
Append an empty anchor element with a href to the section to
section headings. See responsive.css for an example how this can be
styled to show a symbol allowing users to copy the section's URL.
Name of an installed S5 theme, to be copied into a ui/<theme>
subdirectory, beside the destination file (output HTML). Note
that existing theme files will not be overwritten; the existing
theme directory must be deleted manually.
Also overrides the "theme_url" setting. [7]
The URL of an S5 theme directory. The destination file (output
HTML) will link to this theme; nothing will be copied. Also overrides
the "theme" setting. [7]
Embed the stylesheet(s) in the header of the output file. The
stylesheets must be accessible during processing. Currently, this
fails if the file is not available via the given path (i.e. the
file is not searched in the TeX input path).
See also embed_stylesheet [html writers].
LaTeX code that will be inserted in the document preamble.
Can be used to load packages with options or (re-) define LaTeX
macros without writing a custom style file (new in Docutils 0.7).
Use legacy functions \DUtitle and \DUadmonition with a
comma-separated list of class values as optional argument. If False, class
values are handled with wrappers and admonitions use the DUadmonition
environment. See Generating LaTeX with Docutils for details.
Per default the latex-writer puts the reference title into
hyper references. Specify "ref*" or "pageref*" to get the section
number or the page number.
The separator between section number prefix and enumerator for
compound enumerated lists (see compound_enumerators).
Generally it isn't recommended to use both sub-sections and nested
enumerated lists with compound enumerators. This setting avoids
ambiguity in the situation where a section "1" has a list item
enumerated "1.1", and subsection "1.1" has list item "1". With a
separator of ".", these both would translate into a final compound
enumerator of "1.1.1". With a separator of "-", we get the
unambiguous "1-1.1" and "1.1-1".
If embed_stylesheet is False (default), the stylesheet files are
referenced with \usepackage (extension .sty or no extension) or
\input (any other extension).
LaTeX will search the specified files in the TeX input path.
Default: no stylesheet (""). Option: --stylesheet.
A comma-separated list of directories where stylesheets can be found.
Used by the stylesheet_path setting.
Note: This setting defines a "search path" (similar to the PATH variable for
executables). However, the term "path" is already used in the
stylesheet_path setting with the meaning of a file location.
Default: the working directory of the process at launch and the directory
with default stylesheet files (writer and installation specific).
Use the --help option to get the exact value.
Option: --stylesheet-dirs.
A comma-separated list of style files. Relative paths are expanded if a
matching file is found in the stylesheet_dirs.
If embed_stylesheet is False, paths are rewritten relative to the
output file path. Run latex from the directory containing
the output file.
See also stylesheet_path [html writers].
Specify LaTeX font encoding. Multiple options can be given, separated by
commas. The last value becomes the document default.
Possible values are "", "T1", "OT1", "LGR,T1" or any other combination of
LaTeX font encodings.
% Linux Libertine (free, wide coverage, not only for Linux)
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
\setmonofont[HyphenChar=None]{DejaVu Sans Mono}
The optional argument HyphenChar=None to the monospace font
prevents word hyphenation in literal text.
Specify a configuration/mapping file relative to the current working
directory for additional ODF options. In particular, this file may
contain a section named "Formats" that maps default style names to names
to be used in the resulting output file allowing for adhering to external
standards. For more info and the format of the configuration/mapping
file, see the Odt Writer for Docutils document.
Generate an ODF/oowriter table of contents, not a bullet
list. (default) Note:odtwriter is not able to
determine page numbers, so you will need to open the generated
document in oowriter, then right-click on the table of
contents and select "Update" to insert page numbers.
Specify the contents of a custom header line. For details about
custom headers and about special field character sequences, see
section "Custom header/footers: inserting page numbers, date,
time, etc" in the Odt Writer for Docutils document for
details.
Specify the contents of a custom footer line. For details about
custom footers and about special field character sequences, see
section "Custom header/footers: inserting page numbers, date,
time, etc" in the Odt Writer for Docutils document for
details.
List of wildcard (shell globing) patterns, specifying files to silently
ignore. To specify multiple patterns, use colon-separated patterns (in
configuration files or on the command line); on the command line, the
option may also be used more than once.
List of directories not to process. To specify multiple
directories, use colon-separated paths (in configuration files or
on the command line); on the command line, the option may also be
used more than once.
Writer component name.
One of "html", "html4", "html5", "latex", "xelatex", "odt", "xml",
"pseudoxml", "manpage", "pep_html", "s5", an alias,
or the import name of a drop-in writer module.
Path to a configuration file to read (if it exists). [6]
Settings may override defaults and earlier settings. The config
file is processed immediately. Multiple --config options may
be specified; each will be processed in turn.
Filesystem path settings contained within the config file will be
interpreted relative to the config file's location (not relative
to the current working directory).
Formerly, Docutils configuration files contained a single "[options]"
section only. This was found to be inflexible, and in August 2003
Docutils adopted the current component-based configuration file
sections as described above.
Up to version 2.0, Docutils will still recognize the old "[options]"
section, but complain with a deprecation warning.
To convert existing config files, the easiest way is to change the
section title: change "[options]" to "[general]". Most settings
haven't changed. The only ones to watch out for are these: