This script converts reStructuredText (RST) files to HTML, handling custom RST directives and applying optional text replacements. It supports inclusion of a CSS stylesheet in the output HTML files, making it suitable for generating styled documentation or other HTML from RST sources.
Because the Bitcoin Developer RPC Reference is bullshit.
- Custom Directive Handling: Ignores or processes custom directives such as
highlight
andtoctree
. - Text Replacements: Applies user-specified text replacements throughout the documents.
- CSS Styling: Allows linking a CSS stylesheet to the output HTML documents.
- Flexible Output: Outputs HTML files either in the same directory as the source or in a user-specified directory.
- Python 3
- Docutils library
To install dependenies, run:
pip install -r requirements.txt
./rts-to-html <source_folder> [options]
Arg | Description | Usage |
---|---|---|
--output_folder | Specifies the directory where the converted HTML files will be placed. If not specified, files are generated in the same directory as the source files. | --output_folder |
--replace | Specifies a pair of strings to find and replace in the documents. This option can be repeated to specify multiple replacements. | --replace "OLD" "NEW" |
--css | Specifies the path to the CSS stylesheet that should be linked in the HTML documents. Defaults to 'style.css'. | --css |
./rts-to-html path_to_rst_files
./rst-to-html path_to_rst_files --output_folder path_to_output_folder
./rst-to-html path_to_rst_files --replace "Lorem ipsum" "Example text"
./rst-to-html path_to_rst_files --css path_to_custom_style.css
./rst-to-html path_to_rst_files --js path_to_custom_javascript.js
The script processes each .rst file in the specified directory, applying any specified text replacements. It handles custom directives like toctree by converting them into navigable lists of links, and ignores others like highlight. Finally, it wraps the HTML output with basic HTML tags, including a head tag linking to the specified CSS file, and writes the results to the output directory.
Contributions to this script are welcome. Please ensure to test your changes thoroughly before making a pull request.