1.6 KiB
1.6 KiB
print_md
A lightweight and simple CLI and library for colorful Markdown in the terminal
print_md is a tiny tool that takes regular Markdown and renders it to the
terminal using ANSI escape codes. The output is styled with colours and
typographic attributes (bold, underline, etc.) so that a Markdown file looks
more pleasant when viewed directly from the console.
The project ships two entry points:
- Command‑line – a small script that reads files passed on the command line and prints them to stdout.
- Python API – the
render()function can be imported from theprint_mdpackage and used in any Python program.
Both approaches use the same rendering logic and share the same colour configuration, so the output is identical no matter how you invoke it.
Installation
pip install . # Installs the package and the console script
Usage
As a command‑line tool
print_md intro.md how-to.md README.md
If you pass multiple files, each will be rendered sequentially:
The script accepts a single positional argument – the path to a Markdown file or a glob pattern. No additional flags are required.
Using the Python API
from print_md import render
sample = """
# Title
Hello, **world**! This is a _test_.
> A quote
```python
print('Hello')
"""
print(render(sample))
The `render` function returns a string that contains the ANSI‑styled
representation of the Markdown content. You can pipe that string to any
function that expects terminal output, such as `print()` or `sys.stdout.write`.