Docutils | Overview | About | Users | Reference | Developers

Docutils Configuration

Author:

David Goodger

Contact:
docutils-develop@lists.sourceforge.net
Revision:
$Revision$
Date:
$Date$

Introduction

Configuration Files

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:

  1. /etc/docutils.conf: This is a system-wide configuration file, applicable to all Docutils processing on the system.

  2. ./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.

  3. ~/.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 File Syntax

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:

    on:

    "true", "yes", "on", "1"

    off:

    "false", "no", "off", "0", "" (no value)

Example

This is from the tools/docutils.conf configuration file supplied with Docutils:

# These entries affect all processing:
[general]
source-link: yes
datestamp: %Y-%m-%d %H:%M UTC
generator: on

# These entries affect HTML output:
[html writers]
embed-stylesheet: no

[html4css1 writer]
stylesheet-path: docutils/writers/html4css1/html4css1.css
field-name-limit: 20

[html5 writer]
stylesheet-dirs: docutils/writers/html5_polyglot/
stylesheet-path: minimal.css, responsive.css

Configuration File Sections & Entries

Below are the Docutils runtime settings, listed by config file section.

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:

  1. [general]

  2. [parsers], parser dependencies, and the section specific to the Parser used ("[... parser]").

  3. [readers], reader dependencies, and the section specific to the Reader used ("[... reader]"). For example, [pep reader] depends on [standalone reader].

  4. [writers], writer family ("[... writers]"; if applicable), writer dependencies, and the section specific to the writer used ("[... writer]"). For example, [pep_html writer] depends on [html writers] and [html4css1 writer].

  5. [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.

Individual configuration sections and settings are described in the following sections. Some knowledge of Python is assumed for some attributes.

[general]

Settings in the "[general]" section are always applied.

auto_id_prefix

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).

datestamp

Include a time/datestamp in the document footer. Contains a format string for Python's time.strftime().

Default: None.
Options: --date, -d, --time, -t, --no-datestamp.

Configuration file entry examples:

# 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:

debug

Report debug-level system messages.

Default: don't (None). Options: --debug, --no-debug.

dump_internals

At the end of processing, write all internal attributes of the document (document.__dict__) to stderr.

Default: don't (None). Option: --dump-internals (hidden, for development use only).

dump_pseudo_xml

At the end of processing, write the pseudo-XML representation of the document to stderr.

Default: don't (None). Option: --dump-pseudo-xml (hidden, for development use only).

dump_settings

At the end of processing, write all Docutils settings to stderr.

Default: don't (None). Option: --dump-settings (hidden, for development use only).

dump_transforms

At the end of processing, write a list of all transforms applied to the document to stderr.

Default: don't (None). Option: --dump-transforms (hidden, for development use only).

error_encoding

The text encoding for error output.

Default: The encoding reported by sys.stderr, locale encoding, or "ascii".
Options: --error-encoding, -e.

error_encoding_error_handler

The error handler for unencodable characters in error output. Acceptable values are the Error Handlers of Python's "codecs" module. See also output_encoding_error_handler.

Default: "backslashreplace"
Options: --error-encoding-error-handler, --error-encoding, -e.

exit_status_level

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.).

Default: disabled (5). Option: --exit-status.

expose_internals

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).

generator

Include a "Generated by Docutils" credit and link in the document footer.

Default: off (None). Options: --generator, -g, --no-generator.

halt_level

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.

See also report_level.

Default: severe (4). Options: --halt, --strict.

id_prefix

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.

Default: "" (empty). Option: --id-prefix (hidden, intended mainly for programmatic use).

input_encoding

The text encoding for input (use the empty string to restore the default).

Default: auto-detect (None). [1] Options: --input-encoding, -i. [2]

input_encoding_error_handler

The error handler for undecodable characters in the input. Acceptable values are the Error Handlers of Python's "codecs" module, including:

strict

Raise an exception in case of an encoding error.

replace

Replace malformed data with the official Unicode replacement character, U+FFFD.

ignore

Ignore malformed data and continue without further notice.

The error handler may also be appended to the input_encoding setting, delimited by a colon, e.g. --input-encoding=ascii:replace.

Default: "strict". Options: --input-encoding-error-handler.

language_code

Case-insensitive language tag as defined in BCP 47.

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.

Default: English ("en"). Options: --language, -l.

output

The path of the output destination. Use - for stdout.

Obsoletes the <destination> positional argument (cf. Future changes in the RELEASE-NOTES).

Default: None (stdout). Option: --output.

New in Docutils 0.20.

output_encoding

The text encoding for output.

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).

This setting is ignored by the ODF/ODT Writer which always usues UTF-8.

Default: "utf-8". Options: --output-encoding, -o. [2]

output_encoding_error_handler

The error handler for unencodable characters in the output. Acceptable values are the Error Handlers of Python's "codecs" module, including:

strict

Raise an exception in case of an encoding error.

replace

Replace malformed data with a suitable replacement marker, such as "?".

ignore

Ignore malformed data and continue without further notice.

xmlcharrefreplace

Replace with the appropriate XML character reference, such as "&#8224;".

backslashreplace

Replace with backslash escape sequences, such as "\u2020".

The error handler may also be appended to the output_encoding setting using a colon as delimiter, e.g. --output-encoding=ascii:xmlcharrefreplace.

Default: "strict". Options: --output-encoding-error-handler.

record_dependencies

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. [3] [8] The format is one path per line with forward slashes as separator, the encoding is UTF-8.

Set it to "-" in order to write dependencies to stdout.

This option is particularly useful in conjunction with programs like make using Makefile rules like:

ham.html: ham.txt $(shell cat hamdeps.txt)
  rst2html --record-dependencies=hamdeps.txt ham.txt ham.html

If the filesystem encoding differs from UTF-8, replace the cat command with a call to a converter, e.g.:

$(shell iconv -f utf-8 -t latin1 hamdeps.txt)

Default: None. Option: --record-dependencies.

report_level

Report system messages at or higher than <level>:

1 info 2 warning 3 error 4 severe 5 none

See also halt_level.

Default: warning (2).
Options: --report, -r, --verbose, -v, --quiet, -q.

root_prefix

Base directory, prepended to a filesystem path starting with "/" when including files with the "include", "raw", or "csv-table" directives.

Also applied when a writer converts an image URI to a local filesystem path in order to determine the image size or embed the image in the output.

Default: "/" (no change). Option: --root-prefix

New in Docutils 0.21.

sectnum_xform

Enable or disable automatic section numbering by Docutils (docutils.transforms.parts.SectNum) associated with the sectnum directive.

If disabled, section numbers might be added to the output by the renderer (e.g. by LaTeX or via a CSS style definition).

Default: enabled (True).
Options: --section-numbering, --no-section-numbering.

source_url

An explicit URL for a "View document source" link, used verbatim.

Default: compute if source_link (None).
Options: --source-url, --no-source-link.

strict_visitor

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).

strip_classes

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.

Default: disabled (None). Option: --strip-class.

strip_comments

Enable the removal of comment elements from the document tree.

Default: disabled (None). Options: --strip-comments, --leave-comments.

strip_elements_with_classes

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.

Default: disabled (None). Option: --strip-element-with-class.

title

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.

This setting overrides a displayed document title and is overridden by a "title" directive.

Default: none. Option: --title.

traceback

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.

warning_stream

Path to a file for the output of system messages (warnings). [8]

Default: stderr (None). Option: --warnings.

[parsers]

Generic parser options:

file_insertion_enabled

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.)

Default: enabled (True).
Options: --file-insertion-enabled, --no-file-insertion.

line_length_limit

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.

Default: 10 000. Option: --line-length-limit

New in Docutils 0.17.

raw_enabled

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.

Default: enabled (True). Options: --raw-enabled, --no-raw.

[restructuredtext parser]

character_level_inline_markup

Relax the inline markup recognition rules requiring whitespace or punctuation around inline markup.

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).

Default: disabled (False).
Options: --character-level-inline-markup, --word-level-inline-markup.

New in Docutils 0.13.

pep_references

Recognize and link to standalone PEP references (like "PEP 258").

Default: disabled (None); enabled (True) in PEP Reader.

Option: --pep-references.

pep_base_url

Base URL for PEP references.

Default: "https://peps.python.org/". Option: --pep-base-url.

pep_file_url_template

Template for PEP file part of URL, interpolated with the PEP number and appended to pep_base_url.

Default: "pep-%04d". Option: --pep-file-url.

rfc_references

Recognize and link to standalone RFC references (like "RFC 822").

Default: disabled (None); enabled (True) in PEP Reader.

Option: --rfc-references.

rfc_base_url

Base URL for RFC references.

Default: "http://www.faqs.org/rfcs/". Option: --rfc-base-url.

smart_quotes

Activate the SmartQuotes transform to change straight quotation marks to typographic form. Quote characters are selected according to the language of the current block element (see language_code, smartquotes_locales, and the pre-defined quote sets).

Also changes consecutive runs of hyphen-minus and full stops (---, --, ...) to em-dash, en-dash, and ellipsis Unicode characters respectively.

Supported values:

booleans (yes/no)

Use smart quotes?

alt (or "alternative")

Use alternative quote set (if defined for the language).

Default: "no". Option: --smart-quotes.

New in Docutils 0.10.

smartquotes_locales

Typographical quotes used by the SmartQuotes transform.

A comma-separated list with language tag and a string of four quotes (primary open/close, secondary open/close). [4]

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:

smartquote-locales: nl: „”’’,
                    fr: « : »:‹ : ›

Default: None. Option: --smartquotes-locales.

New in Docutils 0.14.

syntax_highlight

Token type names used by Pygments when parsing contents of the code directive and role.

Supported values:

long

Use hierarchy of long token type names.

short

Use short token type names. (For use with Pygments-generated stylesheets.)

none

No code parsing. Use this to avoid the "Pygments not found" warning when Pygments is not installed.

Default: "long". Option: --syntax-highlight.

New in Docutils 0.9.

tab_width

Number of spaces for hard tab expansion.

Default: 8. Option: --tab-width.

trim_footnote_reference_space

Remove spaces before footnote references?

Default: None [5]
Options: --trim-footnote-reference-space, --leave-footnote-reference-space.

[myst parser]

Provided by the 3rd party package myst-docutils. See MyST with Docutils and its Sphinx configuration options (some settings are not available with Docutils).

[pycmark parser]

Provided by the 3rd party package pycmark. Currently no configuration settings.

[recommonmark parser]

Provisional, depends on (deprecated) 3rd-party package recommonmark. Currently no configuration settings.

[readers]

[standalone reader]

docinfo_xform

Enable or disable the bibliographic field list transform (docutils.transforms.frontmatter.DocInfo).

Default: enabled (True). Options: --no-doc-info.

doctitle_xform

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).

Default: enabled (True). Options: --no-doc-title.

sectsubtitle_xform

Enable or disable the promotion of the title of a lone subsection to a subtitle (docutils.transforms.frontmatter.SectSubTitle).

Default: disabled (False).
Options: --section-subtitles, --no-section-subtitles.

[pep reader]

The pep_references and rfc_references settings ([restructuredtext parser]) are set on by default.

[writers]

[docutils_xml writer]

doctype_declaration

Generate XML with a DOCTYPE declaration.

Default: do (True). Options: --no-doctype.

indents

Generate XML with indents and newlines.

Default: don't (None). Options: --indents.

newlines

Generate XML with newlines before and after block-level tags.

Default: don't (None). Options: --newlines.

xml_declaration

Generate XML with an XML declaration. See also xml_declaration [html writers].

Default: do (True). Option: --no-xml-declaration.

[html writers]

attribution

Format for block quote attributions: one of "dash" (em-dash prefix), "parentheses"/"parens", or "none". See also attribution [latex writers].

Default: "dash". Option: --attribution.

cloak_email_addresses

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:

<a class="reference" href="mailto:abc&#37;&#52;&#48;example&#46;org">
abc<span>&#64;</span>example<span>&#46;</span>org</a>

Default: don't cloak (None). Option: --cloak-email-addresses.

compact_lists

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.

Default: enabled (True).
Options: --compact-lists, --no-compact-lists.

compact_field_lists

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.

Default: enabled (True).
Options: --compact-field-lists, --no-compact-field-lists.

embed_stylesheet

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].

Default: enabled. Options: --embed-stylesheet, --link-stylesheet.

footnote_references

Format for footnote references, one of "superscript" or "brackets". See also footnote_references [latex writers].

Overrides [9] trim_footnote_reference_space, if the parser supports this option.

Default: "brackets". Option: --footnote-references.

initial_header_level

The initial level for section header elements. This does not affect the document title & subtitle; see doctitle_xform.

Default: writer dependent (see [html4css1 writer], [html5 writer], [pep_html writer]).
Option: --initial-header-level.

math_output

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).

MathML:

Embed math content as presentational MathML.

Self-contained documents (no JavaScript, no external downloads). MathML is part of the HTML5 standard [6] and supported by all major browsers (since January 2023 also by Chrome).

Docutil's latex2mathml converter supports a considerable subset of LaTeX math syntax.

An external converter can be appended after whitespace, e.g., --math-output="MathML blahtexml":

blahtexml:

Fast conversion, support for many symbols and environments, but no "align" (or other equation-aligning) environment. (C++)

LaTeXML:

Comprehensive macro support but very slow. (Perl)

TtM:

No "matrix", "align" and "cases" environments. Support may be removed.

Pandoc:

Comprehensive macro support, fast, but a large install size. (Haskell)

MathJax:

Format math for display with MathJax, a JavaScript-based math rendering engine.

Pro:

Works across multiple browsers and platforms. Large set of supported LaTeX math commands and constructs

Con:

Rendering requires JavaScript and an Internet connection or local MathJax installation.

A URL pointing to a MathJax library should be appended after whitespace. A warning is given if this is missing.

  • It is recommended to install the MathJax library on the same server as the rest of the deployed site files.

    Example: Install the library at the top level of the web server’s hierarchy in the directory MathJax and set:

    math-output: mathjax /MathJax/MathJax.js
  • The easiest way to use MathJax is to link directly to a public installation. In that case, there is no need to install MathJax locally.

    Downside: Downloads JavaScript code from a third-party site --- opens the door to cross-site scripting attacks!

    Example: MathJax getting started documentation uses:

    math-output: mathjax
       https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

    See https://www.jsdelivr.com/ for details and terms of use.

  • Use a local MathJax installation on the client machine, e.g.:

    math-output: MathJax file:/usr/share/javascript/mathjax/MathJax.js

    This is the fallback if no URL is specified.

LaTeX:

Include literal LaTeX code.

The failsafe fallback.

Default: HTML math.css. Option: --math-output.

New in Docutils 0.8. The default for the HTML5 writer will change to "MathML" in Docutils 0.22.

stylesheet

A comma-separated list of CSS stylesheet URLs, used verbatim. See also stylesheet [latex writers].

Overrides also stylesheet_path. [9]

Default: None. Option: --stylesheet.

stylesheet_dirs

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.

stylesheet_path

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 (if output or <destination> are specified) or the current work directory. See also stylesheet_path [latex writers].

Also overrides "stylesheet". [9] Pass an empty string (to either "stylesheet" or "stylesheet_path") to deactivate stylesheet inclusion.

Default: writer dependent (see [html4css1 writer], [html5 writer], [pep_html writer]).
Option: --stylesheet-path.

table_style

Class value(s) added to all tables. See also table_style [latex writers].

The default CSS sylesheets define:

borderless

No borders around table cells.

align-left, align-center, align-right

Align table as indicated.

The HTML5 stylesheets also define:

booktabs

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: "". Option: --table-style.

template

Path to template file, which must be encoded in UTF-8. [8] See also template [latex writers].

Default: "template.txt" in the writer's directory (installed automatically; for the exact machine-specific path, use the --help option).
Option: --template.

xml_declaration

Prepend an XML declaration. See also xml_declaration [docutils_xml writer].

Default: writer dependent.
Options: --xml-declaration, --no-xml-declaration.

[html4css1 writer]

The HTML4/CSS1 Writer generates output that conforms to the XHTML 1 Transitional specification. It shares all settings defined in the [html writers] configuration section.

Writer Specific Defaults
initial_header_level

1 (for "<h1>")

stylesheet_path:

"html4css1.css"

xml_declaration

enabled (True)

field_name_limit

The maximum length (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.

Default: 14 (i.e. 14 characters). Option: --field-name-limit.

option_limit

The maximum length (in characters) for one-column 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.

Default: 14 (i.e. 14 characters). Option: --option-limit.

[html5 writer]

The HTML5 Writer generates valid XML that is compatible with HTML5. It shares all settings defined in the [html writers] configuration section.

New in Docutils 0.13.

Writer Specific Defaults
initial_header_level

2 (for "<h2>", cf. "Headings and outlines" in the HTML Standard)

stylesheet_path:

"minimal.css, plain.css"

embed_images

Deprecated. Obsoleted by image_loading.

image_loading

Indicate at which point images should be loaded. Overridden by the "image" directive's :loading: option.

Supported values:
embed:

Embed still images into the HTML document (ignored for videos).

link:

Refer to images in the HTML document (default).

lazy:

Refer to images. Additionally specify the lazy loading attribute to defer fetching the image.

Default: "link". Option: --image-loading.

New in Docutils 0.18.

[pep_html writer]

The PEP/HTML Writer derives from the HTML4/CSS1 Writer, and shares all settings defined in the [html writers] and [html4css1 writer] configuration sections.

Writer Specific Defaults
initial_header_level

1 (for "<h1>")

stylesheet_path:

"pep.css"

template:

docutils/writers/pep_html/template.txt in the installation directory. For the exact machine-specific path, use the --help option.

no_random

Do not use a random banner image. Mainly used to get predictable results when testing.

Default: random enabled (None). Options: --no-random (hidden).

pep_home

Home URL prefix for PEPs.

Default: current directory ("."). Option: --pep-home.

python_home

Python's home URL.

Default: https://www.python.org. Option: --python-home.

[s5_html writer]

The S5/HTML Writer derives from the HTML4/CSS1 Writer, and shares all settings defined in the [html writers] and [html4css1 writer] configuration sections.

Writer Specific Defaults
compact_lists:

disable compact lists.

template:

docutils/writers/s5_html/template.txt in the installation directory. For the exact machine-specific path, use the --help option.

hidden_controls

Auto-hide the presentation controls in slideshow mode, or or keep them visible at all times.

Default: auto-hide (True).
Options: --hidden-controls, --visible-controls.
current_slide

Enable or disable the current slide indicator ("1/15").

Default: disabled (None).
Options: --current-slide, --no-current-slide.
overwrite_theme_files

Allow or prevent the overwriting of existing theme files in the ui/<theme> directory. This has no effect if "theme_url" is used.

Default: keep existing theme files (None).
Options: --keep-theme-files, --overwrite-theme-files.
theme

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. [9]

Default: "default". Option: --theme.

theme_url

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. [9]

Default: None. Option: --theme-url.

view_mode

The initial view mode, either "slideshow" or "outline".

Default: "slidewhow". Option: --view-mode.

[latex writers]

Common settings for the LaTeX writers [latex2e writer] and [xetex writer].

attribution

See attribution [html writers].

compound_enumerators

Enable or disable compound enumerators for nested enumerated lists (e.g. "1.2.a.ii").

Default: disabled (None).
Options: --compound-enumerators, --no-compound-enumerators.

documentclass

Specify LaTeX documentclass.

Default: "article". Option: --documentclass.

documentoptions

Specify document options. Multiple options can be given, separated by commas.

Default: "a4paper". Option: --documentoptions.

docutils_footnotes

Use the Docutils-specific macros \DUfootnote and \DUfootnotetext for footnotes.

TODO: The alternative, "use_latex_footnotes" is not implemented yet.

Default: on. Option: --docutils-footnotes.

embed_stylesheet

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].

Default: off. Options: --embed-stylesheet, --link-stylesheet.

footnote_references

Format for footnote references: one of "superscript" or "brackets". See also footnote_references [html writers].

Overrides [9] trim_footnote_reference_space, if the parser supports this option.

Default: "superscript". Option: --footnote-references.

graphicx_option

LaTeX graphicx package option.

Possible values are "dvips", "pdftex", "dvipdfmx".

Default: "". Option: --graphicx-option.

hyperref_options

Options for the hyperref TeX package. If hyperlink_color is not "false", the expansion of

'colorlinks=true,linkcolor=%s,urlcolor=%s' % (
    hyperlink_color, hyperlink_color)

is prepended.

Default: "". Option: --hyperref-options.

latex_preamble

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).

Default: writer dependent (see [latex2e writer], [xetex writer]). Option: --latex-preamble.

legacy_class_functions

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.

Default: False (since Docutils 0.18).
Options: --legacy-class-functions, --new-class-functions.

New in Docutils 0.17.

legacy_column_widths

Use "legacy algorithm" or new algorithm to determine table column widths.

The new algorithm limits the table width to the text width or specified table width and keeps the ratio of specified column widths.

Custom table and/or column widths can be set with the respective options of the table directive. See also Generating LaTeX with Docutils.

Default: True (will change to False in Docutils 1.0).
Options: --legacy-column-widths, --new-column-widths.

New in Docutils 0.18.

literal_block_env

When possible[7], use the specified environment for literal blocks.

Default: "" (quoting of whitespace and special chars).
Option: --literal-block-env.

reference_label

Per default the LaTeX writer uses \hyperref for hyperlink references to internal or implicit targets. Specify an alternative reference command, e.g., "ref" or "pageref" to get the section number or the page number as reference text.

Default: "" (use "hyperref"). Option: --reference-label.

section_enumerator_separator

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".

Default: "-". Option: --section-enumerator-separator.

section_prefix_for_enumerators

Enable or disable section ("." subsection ...) prefixes for compound enumerators. This has no effect unless compound_enumerators are enabled.

Default: disabled (None).
Options: --section-prefix-for-enumerators, --no-section-prefix-for-enumerators.

stylesheet

A comma-separated list of style files. Used without path adaption (cf. stylesheet_path [latex writers]). Under Windows, path separators are normalized to forward slashes (/). See also stylesheet [html writers].

Overrides also stylesheet_path. [9]

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.

stylesheet_dirs

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.

stylesheet_path

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 (if output or <destination> are specified) or the current work directory. See also stylesheet_path [html writers].

For files in the TeX input path, the stylesheet option is recommended.

Also overrides stylesheet. [9]

Default: no stylesheet (""). Option: --stylesheet-path.

table_style

Specify the default style for tables. See also table_style [html writers].

Supported values: "booktabs", "borderless", "colwidths-auto", and "standard". See Generating LaTeX with Docutils for details.

Default: "standard". Option: --table-style.

template

Path [8] to template file, which must be encoded in UTF-8. See also template [html writers].

Default: writer dependent (see [latex2e writer], [xetex writer]).
Option: --template.

use_bibtex

Provisional, name, values, and behaviour may change in future versions or the option may be removed.

A comma-separated list of style and database(s) for the experimental BibTeX support, for example:

--use-bibtex=unsrt,mydb1,mydb2

Default: "" (don't use BibTeX). Option --use-bibtex.

use_latex_abstract

Use LaTeX abstract environment for the document's abstract.

Default: off. Options: --use-latex-abstract, --topic-abstract.

use_latex_citations

Use cite for citations instead of a simulation with figure-floats.

Default: off. Options: --use-latex-citations, --figure-citations.

use_latex_docinfo

Attach author and date to the document title instead of the bibliographic fields.

Default: off.
Options: --use-latex-docinfo, --use-docutils-docinfo.

use_latex_toc

To get page numbers in the table of contents, it must be generated by LaTeX. Usually latex must be run twice to get numbers correct.

Default: on. Options: --use-latex-toc, --use-docutils-toc.

use_part_section

Add parts on top of the section hierarchy.

Default: don't (None). Option: --use-part-section.

[latex2e writer]

The LaTeX2e writer generates a LaTeX source for compilation with 8-bit LaTeX (pdfTeX). It shares all settings defined in the [latex writers] configuration section.

Writer Specific Defaults
latex_preamble

Load the "PDF standard fonts" (Times, Helvetica, Courier):

\usepackage{mathptmx} % Times
\usepackage[scaled=.90]{helvet}
\usepackage{courier}
template

"default.tex" in the docutils/writers/latex2e/ directory (installed automatically).

font_encoding

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.

Default: "T1". Option: --font-encoding.

[xetex writer]

The XeTeX writer generates a LaTeX source for compilation with XeTeX or LuaTeX. It derives from the latex2e writer, and shares all settings defined in the [latex writers] configuration section.

Writer Specific Defaults
latex_preamble:

Font setup for Linux Libertine,:

% 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.

template:

"xelatex.tex" in the docutils/writers/latex2e/ directory (installed automatically).

[odf_odt writer]

The ODF/ODT Writer generates documents in the OpenDocument Text format (.odt).

The output_encoding setting is ignored, the output encoding is always "UTF-8".

add-syntax_highlighting

Add syntax highlighting in literal code blocks. See section "Syntax highlighting" in the ODT Writer documentation for details.

Default: disabled (False).
Options: --add-syntax-highlighting, --no-syntax-highlighting.

create_sections

Create sections for headers.

Default: enabled (True).
Options: --create-sections, --no-sections.

cloak_email_addresses

Obfuscate email addresses to confuse harvesters while still keeping email links usable with standards-compliant browsers.

Default: disabled (False).
Options: --cloak-email-addresses, --no-cloak-email-addresses.

custom_header

Specify the contents of a custom header line. See section "Custom header/footers" in the ODT Writer documentation for details.

Default: none (''). Option: --custom-odt-header.

endnotes_end_doc

Generate endnotes at end of document, not footnotes at bottom of page.

Default: disabled (False).
Options: --endnotes-end-doc, --no-endnotes-end-doc.

generate_oowriter_toc

Generate a native ODF table of contents, not a bullet list. See section "Table of contents" in the ODT Writer documentation for details.

Default: enabled (True).
Options: --generate-oowriter-toc, --generate-list-toc.

odf_config_file

Specify a configuration/mapping file relative to the current working directory for additional ODF options. In particular, this file may contain a mapping of default style names to names used in the resulting output file. See section How to use custom style names in the ODT Writer documentation for details.

Default: None. Option: --odf-config-file.

stylesheet

Specify a stylesheet URL, used verbatim. See section Styles and Classes in the ODT Writer documentation for details.

Default: writers/odf_odt/styles.odt in the installation directory.
Option: --stylesheet.

table_border_thickness

Specify the thickness of table borders in thousands of a centimetre. The Table styles section in the ODT Writer documentation describes alternatives for additional customisation of the table style.

Default: 35 (0.35 mm). Option: --table-border-thickness.

[pseudoxml writer]

detailed

Pretty-print <#text> nodes.

Default: False. Option: --detailed.

[applications]

[buildhtml application]

dry_run

Do not process files, show files that would be processed.

Default: False. Option: --dry-run.

ignore

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.

Default: None. Option: --ignore.

prune

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.

Default: ['.hg', '.bzr', '.git', '.svn', 'CVS']. Option: --prune.

recurse

Recursively scan subdirectories, or ignore subdirectories.

Default: recurse (True). Options: --recurse, --local.

silent

Work silently (no progress messages). Independent of report_level.

Default: show progress (None). Option: --silent.

writer

HTML writer version. One of "html", "html4", "html5".

Default: "html" (use Docutils' default HTML writer).
Option: --writer

New in 0.17. Obsoletes the html_writer option.

[docutils application]

New in 0.17. Config file support added in 0.18.
Renamed in 0.19 (the old name "docutils-cli application" is kept as alias).
Support for reader/parser import names added in 0.19.

reader

Reader component name. One of "standalone", "pep", or the import name of a drop-in reader module.

Default: "standalone". Option: --reader

parser

Parser component name. Either "rst" (default) or the import name of a drop-in parser module.

Parsers for CommonMark known to work with Docutils include "pycmark", "myst", and "recommonmark".

Default: "rst". Option: --parser

writer

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.

Default: "html5". Option: --writer

Other Settings

Command-Line Only

These settings are only effective as command-line options; setting them in configuration files has no effect.

config

Path to a configuration file to read (if it exists). [8] 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).

Default: None. Option: --config.

Internal Settings

These settings are for internal use only; setting them in configuration files has no effect, and there are no corresponding command-line options.

_config_files

List of paths of applied configuration files.

Default: None. No command-line options.

_directories

(buildhtml.py front end.) List of paths to source directories, set from positional arguments.

Default: current working directory (None).
No command-line options.

_disable_config

Prevent standard configuration files from being read. For programmatic use only.

Default: config files enabled (None).
No command-line options.

_destination

Path to output destination, set from positional arguments.

Default: stdout (None). No command-line options.

_source

Path to input source, set from positional arguments.

Default: stdin (None). No command-line options.


Old-Format Configuration Files

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:

Old-Format Setting

New Section & Setting

pep_stylesheet

[pep_html writer] stylesheet

pep_stylesheet_path

[pep_html writer] stylesheet_path

pep_template

[pep_html writer] template