docutils.writers.xetex package

XeLaTeX document tree Writer.

A variant of Docutils’ standard ‘latex2e’ writer producing LaTeX output suited for processing with the Unicode-aware TeX engines LuaTeX and XeTeX.

class Writer[source]

Bases: Writer

A writer for Unicode-aware LaTeX variants (XeTeX, LuaTeX)

supported = ('latex', 'tex', 'xetex', 'xelatex', 'luatex', 'lualatex')

Formats this writer supports.

default_template = 'xelatex.tex'
default_preamble = '% Linux Libertine (free, wide coverage, not only for Linux)\n\\setmainfont{Linux Libertine O}\n\\setsansfont{Linux Biolinum O}\n\\setmonofont[HyphenChar=None,Scale=MatchLowercase]{DejaVu Sans Mono}'
config_section = 'xetex writer'

The name of the config file section specific to this component (lowercase, no brackets). Override in subclasses.

config_section_dependencies = ('writers', 'latex writers')

A list of names of config file sections that are to be applied before config_section, in order (from general to specific). In other words, the settings in config_section are to be overlaid on top of the settings from these sections. The “general” section is assumed implicitly. Override in subclasses.

settings_spec = ('LaTeX-Specific Options', None, (('Specify LaTeX documentclass.  Default: "article".', ['--documentclass'], {'default': 'article'}), ('Specify document options.  Multiple options can be given, separated by commas.  Default: "a4paper".', ['--documentoptions'], {'default': 'a4paper'}), ('Format for footnote references: one of "superscript" or "brackets".  Default: "superscript".', ['--footnote-references'], {'choices': ['superscript', 'brackets'], 'default': 'superscript', 'metavar': '<format>', 'overrides': 'trim_footnote_reference_space'}), ('Use \\cite command for citations. (future default)', ['--use-latex-citations'], {'action': 'store_true', 'default': None, 'validator': <function validate_boolean>}), ('Use figure floats for citations (might get mixed with real figures). (provisional default)', ['--figure-citations'], {'action': 'store_false', 'dest': 'use_latex_citations', 'validator': <function validate_boolean>}), ('Format for block quote attributions: one of "dash" (em-dash prefix), "parentheses"/"parens", or "none".  Default: "dash".', ['--attribution'], {'choices': ['dash', 'parentheses', 'parens', 'none'], 'default': 'dash', 'metavar': '<format>'}), ('Specify LaTeX packages/stylesheets. A style is referenced with "\\usepackage" if extension is ".sty" or omitted and with "\\input" else.  Overrides previous --stylesheet and --stylesheet-path settings.', ['--stylesheet'], {'default': '', 'metavar': '<file[,file,...]>', 'overrides': 'stylesheet_path', 'validator': <function validate_comma_separated_list>}), ('Comma separated list of LaTeX packages/stylesheets. Relative paths are expanded if a matching file is found in the --stylesheet-dirs. With --link-stylesheet, the path is rewritten relative to the output *.tex file. ', ['--stylesheet-path'], {'metavar': '<file[,file,...]>', 'overrides': 'stylesheet', 'validator': <function validate_comma_separated_list>}), ('Link to the stylesheet(s) in the output file. (default)', ['--link-stylesheet'], {'action': 'store_false', 'dest': 'embed_stylesheet'}), ('Embed the stylesheet(s) in the output file. Stylesheets must be accessible during processing. ', ['--embed-stylesheet'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Comma-separated list of directories where stylesheets are found. Used by --stylesheet-path when expanding relative path arguments. Default: ".".', ['--stylesheet-dirs'], {'default': ['.'], 'metavar': '<dir[,dir,...]>', 'validator': <function validate_comma_separated_list>}), ('Customization by LaTeX code in the preamble. Default: select "Linux Libertine" fonts.', ['--latex-preamble'], {'default': '% Linux Libertine (free, wide coverage, not only for Linux)\n\\setmainfont{Linux Libertine O}\n\\setsansfont{Linux Biolinum O}\n\\setmonofont[HyphenChar=None,Scale=MatchLowercase]{DejaVu Sans Mono}'}), ('Template file. Default: "xelatex.tex".', ['--template'], {'default': 'xelatex.tex', 'metavar': '<file>'}), ('Table of contents by LaTeX. (default)', ['--use-latex-toc'], {'action': 'store_true', 'default': True, 'validator': <function validate_boolean>}), ('Table of contents by Docutils (without page numbers).', ['--use-docutils-toc'], {'action': 'store_false', 'dest': 'use_latex_toc', 'validator': <function validate_boolean>}), ('Add parts on top of the section hierarchy.', ['--use-part-section'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Attach author and date to the document info table. (default)', ['--use-docutils-docinfo'], {'action': 'store_false', 'dest': 'use_latex_docinfo', 'validator': <function validate_boolean>}), ('Attach author and date to the document title.', ['--use-latex-docinfo'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Typeset abstract as topic. (default)', ['--topic-abstract'], {'action': 'store_false', 'dest': 'use_latex_abstract', 'validator': <function validate_boolean>}), ("Use LaTeX abstract environment for the document's abstract.", ['--use-latex-abstract'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Color of any hyperlinks embedded in text. Default: "blue" (use "false" to disable).', ['--hyperlink-color'], {'default': 'blue'}), ('Additional options to the "hyperref" package.', ['--hyperref-options'], {'default': ''}), ('Enable compound enumerators for nested enumerated lists (e.g. "1.2.a.ii").', ['--compound-enumerators'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Disable compound enumerators for nested enumerated lists. (default)', ['--no-compound-enumerators'], {'action': 'store_false', 'dest': 'compound_enumerators'}), ('Enable section ("." subsection ...) prefixes for compound enumerators.  This has no effect without --compound-enumerators.', ['--section-prefix-for-enumerators'], {'action': 'store_true', 'default': None, 'validator': <function validate_boolean>}), ('Disable section prefixes for compound enumerators. (default)', ['--no-section-prefix-for-enumerators'], {'action': 'store_false', 'dest': 'section_prefix_for_enumerators'}), ('Set the separator between section number and enumerator for compound enumerated lists.  Default: "-".', ['--section-enumerator-separator'], {'default': '-', 'metavar': '<char>'}), ('When possible, use the specified environment for literal-blocks. Default: "" (fall back to "alltt").', ['--literal-block-env'], {'default': ''}), ('Deprecated alias for "--literal-block-env=verbatim".', ['--use-verbatim-when-possible'], {'action': 'store_true', 'validator': <function validate_boolean>}), ('Table style. "standard" with horizontal and vertical lines, "booktabs" (LaTeX booktabs style) only horizontal lines above and below the table and below the header, or "borderless". Default: "standard"', ['--table-style'], {'action': 'append', 'choices': ['booktabs', 'borderless', 'colwidths-auto', 'nolines', 'standard'], 'default': ['standard'], 'metavar': '<format>', 'validator': <function validate_comma_separated_list>}), ('LaTeX graphicx package option. Possible values are "dvipdfmx", "dvips", "dvisvgm", "luatex", "pdftex", and "xetex".Default: "".', ['--graphicx-option'], {'default': ''}), ('Per default the latex-writer puts the reference title into hyperreferences. Specify "ref*" or "pageref*" to get the section number or the page number.', ['--reference-label'], {'default': ''}), ('Specify style and database(s) for bibtex, for example "--use-bibtex=unsrt,mydb1,mydb2". Provisional!', ['--use-bibtex'], {'default': '', 'metavar': '<style,bibfile[,bibfile,...]>', 'validator': <function validate_comma_separated_list>}), ('Use legacy functions with class value list for \\DUtitle and \\DUadmonition.', ['--legacy-class-functions'], {'action': 'store_true', 'default': False, 'validator': <function validate_boolean>}), ('Use \\DUrole and "DUclass" wrappers for class values. Place admonition content in an environment. (default)', ['--new-class-functions'], {'action': 'store_false', 'dest': 'legacy_class_functions', 'validator': <function validate_boolean>}), ('Use legacy algorithm to determine table column widths. (provisional default)', ['--legacy-column-widths'], {'action': 'store_true', 'default': None, 'validator': <function validate_boolean>}), ('Use new algorithm to determine table column widths. (future default)', ['--new-column-widths'], {'action': 'store_false', 'dest': 'legacy_column_widths', 'validator': <function validate_boolean>}), ('Footnotes with numbers/symbols by Docutils. (default) (The alternative, --latex-footnotes, is not implemented yet.)', ['--docutils-footnotes'], {'action': 'store_true', 'default': True, 'validator': <function validate_boolean>})))

Runtime settings specification. Override in subclasses.

Defines runtime settings and associated command-line options, as used by docutils.frontend.OptionParser. This is a tuple of:

  • Option group title (string or None which implies no group, just a list of single options).

  • Description (string or None).

  • A sequence of option tuples. Each consists of:

    • Help text (string)

    • List of option strings (e.g. ['-Q', '--quux']).

    • Dictionary of keyword arguments sent to the OptionParser/OptionGroup add_option method.

      Runtime setting names are derived implicitly from long option names (’–a-setting’ becomes settings.a_setting) or explicitly from the ‘dest’ keyword argument.

      Most settings will also have a ‘validator’ keyword & function. The validator function validates setting values (from configuration files and command-line option arguments) and converts them to appropriate types. For example, the docutils.frontend.validate_boolean function, required by all boolean settings, converts true values (‘1’, ‘on’, ‘yes’, and ‘true’) to 1 and false values (‘0’, ‘off’, ‘no’, ‘false’, and ‘’) to 0. Validators need only be set once per setting. See the docutils.frontend.validate_* functions.

      See the optparse docs for more details.

  • More triples of group title, description, options, as many times as needed. Thus, settings_spec tuples can be simply concatenated.

class Babel(language_code, reporter)[source]

Bases: Babel

Language specifics for XeTeX.

Use polyglossia instead of babel and adapt settings.

language_codes = {'ar': 'arabic', 'bg': 'bulgarian', 'br': 'breton', 'ca': 'catalan', 'cop': 'coptic', 'cs': 'czech', 'cy': 'welsh', 'da': 'danish', 'de': 'german', 'de-1901': 'ogerman', 'dsb': 'lsorbian', 'dv': 'divehi', 'el': 'greek', 'el-polyton': 'polygreek', 'en': 'english', 'en-au': 'australian', 'eo': 'esperanto', 'es': 'spanish', 'et': 'estonian', 'eu': 'basque', 'fa': 'farsi', 'fi': 'finnish', 'fr': 'french', 'ga': 'irish', 'gl': 'galician', 'grc': 'ancientgreek', 'he': 'hebrew', 'hr': 'croatian', 'hsb': 'usorbian', 'hu': 'magyar', 'ia': 'interlingua', 'id': 'bahasai', 'is': 'icelandic', 'it': 'italian', 'ja': 'japanese', 'kk': 'kazakh', 'ko': 'korean', 'la': 'latin', 'lt': 'lithuanian', 'lv': 'latvian', 'mn': 'mongolian', 'ms': 'bahasam', 'nb': 'norsk', 'nl': 'dutch', 'nn': 'nynorsk', 'no': 'norsk', 'pl': 'polish', 'pt': 'portuges', 'pt-br': 'brazil', 'ro': 'romanian', 'ru': 'russian', 'se': 'samin', 'sh-cyrl': 'serbian', 'sh-latn': 'croatian', 'sk': 'slovak', 'sl': 'slovene', 'sq': 'albanian', 'sr': 'serbian', 'sv': 'swedish', 'th': 'thai', 'tr': 'turkish', 'uk': 'ukrainian', 'vi': 'vietnamese'}
key = 'sr-Latn'
class XeLaTeXTranslator(document)[source]

Bases: LaTeXTranslator

Generate code for LaTeX using Unicode fonts (XeLaTex or LuaLaTeX).

See the docstring of docutils.writers._html_base.HTMLTranslator for notes on and examples of safe subclassing.