https://github.com/stephenfin/rst2txt
Convert reStructuredText to plain text
https://github.com/stephenfin/rst2txt
docutils restructuredtext sphinx
Last synced: about 1 year ago
JSON representation
Convert reStructuredText to plain text
- Host: GitHub
- URL: https://github.com/stephenfin/rst2txt
- Owner: stephenfin
- License: bsd-2-clause
- Created: 2018-11-12T13:26:14.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-04-01T07:35:40.000Z (about 5 years ago)
- Last Synced: 2024-10-06T02:21:23.418Z (over 1 year ago)
- Topics: docutils, restructuredtext, sphinx
- Language: Python
- Size: 72.3 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
=======
rst2txt
=======
.. image:: https://badge.fury.io/py/rst2txt.svg
:target: https://badge.fury.io/py/rst2txt
:alt: PyPi Status
.. image:: https://travis-ci.org/stephenfin/rst2txt.svg?branch=master
:target: https://travis-ci.org/stephenfin/rst2txt
:alt: Build Status
reStructuredText is pretty-damn consumable in its raw form, but extensive use
of directives and roles can hamper things or leave the document incomplete in
its raw form (cough, ``.. include``, cough).
*rst2txt* allows you to work around this by evaluating the reStructuredText
source and stripping it of most of its formatting. The end result is a document
that's more readable and has elements that don't make sense in a plain text
document, such as images, stripped.
*rst2txt* is based on the ``sphinx.writer.text.TextWriter`` writer used by
Sphinx's `TextBuilder
`__
but with the Sphinx-specific features stripped out.
Installation
------------
*rst2txt* is available on PyPI. To install, run:
.. code-block:: shell
$ pip install --user rst2txt
Usage
-----
Most users will want just the ``rst2txt`` application:
.. code-block:: shell
$ rst2txt README.rst
It is also possible to call this programmatically though. This can be useful
for things like consuming README files:
.. code-block:: python
from docutils.core import publish_file
import rst2txt
with open('README.rst', 'r') as source:
publish_file(source=source, destination_path='README.txt',
writer=rst2txt.Writer())