Skip to main content

An OpenDocument to Sphinx converter.

Project description

What is it ?

Odt2sphinx converts OpenDocument Text file(s) to one or several .rst files.

This is a fork of Christophe de Vienne odt2sphinx.

Install

pip install metapensiero.odt2sphinx

Usage

usage: odt2sphinx [-h] [--debug] [--download-source-link]
                  [--encoding ENCODING]
                  source [target]

ODT to RST

positional arguments:
  source                Source ODT file to be converted
  target                Either destination directory or single .rst target
                        filename

optional arguments:
  -h, --help            show this help message and exit
  --debug               Emit debug noise
  --download-source-link
                        Add a link to the ODT source file
  --encoding ENCODING   Output encoding, by default UTF-8

Output files

There are two modes of operation:

  1. Sphinx, splitting the source in multiple files, one per chapter

  2. Monolithic single plain reST output

The first mode is selected by omitting the second positional argument, or giving it the name of a directory. The latter is selected by specifing a file name with a .rst extension as the second positional argument.

Multiple files mode

The files are generated in the target dir, which by default has the same name as the .odt file minus the extension.

At least one file, “index.rst”, will be written. Depending on the document content, additional rst files may be generated.

Images are extracted and put together in an “images” directory inside the targetdir.

Monolithic output mode

All the output goes into the single rst file specified as the second positional argument.

Images are extracted and put together in an “images” directory inside the directory containing the output file.

Styles mapping

The following rules will be applied to particulary styles when converting an .odt file. The style names are case-insensitive.

“Title” (in any language)

Becomes the main document title (underlined with ‘=’)

“Title 1”

Creates a new page named after the title, and becomes this page main title (underlined with ‘=’); a reference to this file is inserted in a .. toctree directive of the index.rst file

“Title 2” to “Title 6”

Becomes sub-chapter titles, underlined respectively ‘-’, ‘~’, ‘^’, ‘”’, “’”

“Warning” (or “Avertissement”)

The chapter becomes the content of a .. warning directive

“Tip” (or “Trucs & Astuces”)

The chapter becomes the content of a .. tip directive

“Note” or “Information”

The chapter becomes the content of a .. note directive

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page