A Python-based Markdown to ANSI terminal formatter that renders markdown files with color and style directly in your terminal.
- Headers (H1-H6) with distinct colors
- Lists (unordered)
- Code Blocks (fenced with ``` or ~~~)
- Tables (pipe-delimited with alignment support)
- Blockquotes
- Horizontal Rules
- Inline Formatting:
- Bold (text)
- Italic (text)
- Strikethrough (
text) - Inline code (
code
)
Clone the repository and make the script executable:
git clone https://github.com/Open-Technology-Foundation/md2ansi
cd md2ansi
chmod +x md2ansi.py
Create a symbolic link (optional):
ln -s md2ansi.py md2ansi
# Process a single markdown file
./md2ansi README.md
# Process multiple files
./md2ansi file1.md file2.md
# Process markdown from stdin
cat README.md | ./md2ansi
# Force specific terminal width
./md2ansi --width 100 README.md
# H1 Header
## H2 Header
### H3 Header
* Item 1
* Item 2
* Subitem 2.1
| Align Left | Center | Align Right |
|:-----------|:------:|------------:|
| Left | Center | Right |
```python
def hello():
print("Hello, World!")
```
- Python 3.6+
- Linux/Unix terminal with ANSI color support
The script uses ANSI escape sequences to provide colored output:
- Headers use distinct colors (yellow to purple gradient)
- Code blocks and tables use gray
- Lists and horizontal rules use cyan
- Blockquotes use a dark background
- Regular text uses light gray
Terminal width is auto-detected with graceful fallbacks to ensure proper text wrapping.
Contributions are welcome! Please feel free to submit a Pull Request.
Copyright © 2022-2025 Indonesian Open Technology Foundation Licensed under GPL-3.0. See LICENSE file for details.
Please report any issues on the GitHub repository.