Skip to main content

Generates (X)HTML5 documents from standalone reStructuredText sources

Project description

rst2html5 generates (X)HTML5 documents from standalone reStructuredText sources. It is a complete rewrite of the docutils’ rst2html and uses new HTML5 constructs such as <section> and <aside>.

Usage

$ rst2html5 [options] SOURCE

Options:

--no-indent

Don’t indent output

--stylesheet=<URL or path>

Specify a stylesheet URL to be included. (This option can be used multiple times)

--script=<URL or path>

Specify a script URL to be included. (This option can be used multiple times)

--script-defer=<URL or path>

Specify a script URL with a defer attribute to be included in the output HTML file. (This option can be used multiple times)

--script-async=<URL or path>

Specify a script URL with a async attribute to be included in the output HTML file. (This option can be used multiple times)

--html-tag-attr=<attribute>

Specify a html tag attribute. (This option can be used multiple times)

Examples

Consider the following rst snippet:

Title
=====

Some text and a target to `Title 2`_. **strong emphasis**:

* item 1
* item 2

Title 2
=======

.. parsed-literal::

    Inline markup is supported, e.g. *emphasis*, **strong**, ``literal
    text``,
    _`hyperlink targets`, and `references <http://www.python.org/>`_

The html5 produced is clean and tidy:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
</head>
<body>
    <section id="title">
        <h1>Title</h1>
        <p>Some text and a target to <a href="#title-2">Title 2</a>. <strong>strong emphasis</strong>:</p>
        <ul>
            <li>item 1</li>
            <li>item 2</li>
        </ul>
    </section>
    <section id="title-2">
        <h1>Title 2</h1>
        <pre>Inline markup is supported, e.g. <em>emphasis</em>, <strong>strong</strong>, <code>literal
text</code>,
<a id="hyperlink-targets">hyperlink targets</a>, and <a href="http://www.python.org/">references</a></pre>
    </section>
</body>
</html>

No stylesheets or classes are spread over the html5 by default. However:

  1. Stylesheets and javascripts URLs or paths can be included through stylesheet and script options.

    $ rst2html5 example.rst \
    --stylesheet css/default.css \
    --stylesheet css/special.css \
    --script https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <link href="css/default.css" rel="stylesheet" />
        <link href="css/special.css" rel="stylesheet" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    ...
  2. Script attributes defer and async:

    $ rst2html5 example.rst \
    --script js/test1.js \
    --script-defer js/test2.js \
    --script-async js/test3.js
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <script src="js/test1.js"></script>
        <script src="js/test2.js" defer="defer"></script>
        <script src="js/test3.js" async="async"></script>
    ...
  3. Html tag attributes can be included through html-tag-attr option:

    $ rst2html5 --html-tag-attr 'lang="pt-BR"' example.rst
    <!DOCTYPE html>
    <html lang="pt-BR">
    ...
  4. Classes can be explicitly associated to rst elements (see ref):

    .. class:: special
    
    This is a "special" paragraph.
    
    .. class:: exceptional remarkable
    
    An Exceptional Section
    ======================
    
    This is an ordinary paragraph.

    which results in:

    <p class="special">This is a "special" paragraph.</p>
    <section class="exceptional remarkable" id="an-exceptional-section">
        <h1>An Exceptional Section</h1>
        <p>This is an ordinary paragraph.</p>
    </section>

Installation

$ pip install rst2html5

Project details


Download files

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

Source Distributions

rst2html5-1.1.zip (60.6 kB view details)

Uploaded Source

rst2html5-1.1.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rst2html5-1.1.linux-x86_64.tar.gz (23.0 kB view details)

Uploaded Source

File details

Details for the file rst2html5-1.1.zip.

File metadata

  • Download URL: rst2html5-1.1.zip
  • Upload date:
  • Size: 60.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rst2html5-1.1.zip
Algorithm Hash digest
SHA256 90a2ba49b0831ffbc1a9f27ed59f72f91d74b7f9e8d9e10359d9f7bfae78b57f
MD5 d2be5f63c7d0ea75dc1d55c30ef14d05
BLAKE2b-256 d2376125ffb49e702961ceaeaf70746f366a66e020cbd18056a0e305fde9a4f4

See more details on using hashes here.

File details

Details for the file rst2html5-1.1.tar.gz.

File metadata

  • Download URL: rst2html5-1.1.tar.gz
  • Upload date:
  • Size: 50.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for rst2html5-1.1.tar.gz
Algorithm Hash digest
SHA256 665cc6e3a920e4ab69539a8d566b18ba071ee38981e2177f1596ad887b3e6c83
MD5 f0543e10bb88dd82e45af0039cf4914b
BLAKE2b-256 a18f80df79716d7695c7c91f7960f7c33cc260952a487e9617cff0219e58fc58

See more details on using hashes here.

File details

Details for the file rst2html5-1.1.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for rst2html5-1.1.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 2b46a9677a040a76490fb1ff561e7681f611cf8bd8b8d30b8f1e2f9e12f01f95
MD5 8d97a011fcdb7677a976e702b197ea8c
BLAKE2b-256 be52615d7f52b1167b62da0de3c4b45a905e22d59396af6223342a5aa331fdf5

See more details on using hashes here.

Supported by

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