Skip to main content

A tool to convert reStructuredText to GitHub Flavored Markdown

Project description

rst2gfm - reStructuredText to GitHub Flavored Markdown Converter

A Python tool that converts reStructuredText (RST) documents to GitHub Flavored Markdown (GFM).

Features

  • Converts RST documents to GitHub Flavored Markdown
  • Preserves document structure including headings, paragraphs, and formatting
  • Supports common RST elements:
    • Headers/sections
    • Text formatting (bold, italic)
    • Code blocks with language highlighting
    • Lists (bullet and enumerated)
    • Tables
    • Links
    • Images
    • Block quotes
    • Definition lists

Installation

pip install rst2gfm

Or install from source:

git clone https://github.com/pdh/rst2gfm.git
cd rst2gfm
pip install -e .

Usage

Command Line

Convert an RST file to Markdown:

rst2gfm input.rst -o output.md

Use stdin/stdout:

cat input.rst | rst2gfm > output.md

Python API

from rst2gfm import convert_rst_to_md

# Convert RST string to Markdown
rst_content = "**Bold text** in reStructuredText"
md_content = convert_rst_to_md(rst_content)
print(md_content)

# Convert RST file to Markdown file
with open('input.rst', 'r') as f:
    rst_content = f.read()

md_content = convert_rst_to_md(rst_content)

with open('output.md', 'w') as f:
    f.write(md_content)

Limitations

This converter handles most common RST elements, but some advanced features may not be fully supported:

  • Complex nested structures
  • Custom RST directives
  • Some Sphinx-specific extensions

Development

Running Tests

pip install pytest
pytest

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

rst2gfm-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

rst2gfm-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file rst2gfm-0.1.0.tar.gz.

File metadata

  • Download URL: rst2gfm-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for rst2gfm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b869fda8980103dcab9f02856bb4864cfd3aeb1e9910fbb45b7645990053b15d
MD5 9e62b4600ae268f6e04e528f8a33e3da
BLAKE2b-256 090e99e53e218d838ae25d1d263c53d5b4c9779b77d2a8e2bb4c3816e623e34b

See more details on using hashes here.

File details

Details for the file rst2gfm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: rst2gfm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for rst2gfm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6eb6dd0377948c162b6793a111f81a0f333119c9d20ea3451ea9fbc4773609c8
MD5 7bf34858c8ecc92752a3c0d5bb0072a0
BLAKE2b-256 71999d6a9a9de3a5321f5d44fd8af8dfbf9d533547fb74f01f0af74c2f7f47d9

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