16 February 2022

05 February 2022

How to convert a .rst file into a .html file?

If docutils is not installed, install it with the following command -

#python -m pip install docutils

===================================================

Method 1 (better than Method 2)

https://docutils.sourceforge.io/docs/user/tools.html#rst2html5-py

# rst2html5.py --help

# rst2html5.py <source_rst_file_name.rst> <output.html>



===================================================

Method 2

https://www.geeksforgeeks.org/restructuredtext-rst-file-to-html-file-using-python-for-documentations/

The following python script will convert 'restructured.rst' into 'output.html'


import docutils.core

docutils.core.publish_file(
    source_path ="restructured.rst",
    destination_path ="Output.html",
    writer_name ="html")