Skip to main content

MarkRender

Professional Terminal Markdown Renderer for Streaming LLM Responses

MarkRender renders markdown in the terminal. It is built for streaming output, so you can hand it a complete string or feed it chunks from an LLM as they arrive. Syntax highlighting, themes, tables, and the rest work the same either way, without reprinting content that is already on screen.

Features

  • Streaming Support - Designed for chunk-by-chunk LLM response rendering
  • 7 Themes - github-dark, monokai, dracula, nord, one-dark, solarized-dark, solarized-light
  • Syntax Highlighting - Powered by Pygments with 500+ languages
  • Dim Mode - Render "thinking" content in a single muted gray
  • Theme Preview - Preview all themes with sample content via CLI
  • Line Numbers - Optional line numbers in code blocks
  • Tables - Table rendering with borders and overflow truncation
  • Checkboxes - Task list support
  • Emoji Support - Converts :emoji_name: to actual emojis
  • Links - Styled hyperlinks with URLs
  • Full Markdown - Headings, lists, blockquotes, horizontal rules, alerts, and more
  • Force Color - Force color output even in non-tty terminals
  • Customizable - Custom colors, backgrounds, and formatting options
  • Python 3.7+ - Compatible with Python 3.7 and above

Installation

MarkRender is on PyPI:

pip install markrender

That installs the library and the markrender command. Check that it worked:

markrender --version

Upgrade an existing install with:

pip install --upgrade markrender

If you want to work on MarkRender itself, clone the repo and install it in editable mode instead:

git clone https://github.com/Praneeth-Gandodi/markrender.git
cd markrender
pip install -e ".[dev]"

Command Line

Render a file:

markrender README.md

Read markdown from stdin:

cat notes.md | markrender

On PowerShell:

Get-Content notes.md -Raw | markrender

Pick a theme:

markrender --theme dracula notes.md

Adjust code blocks:

markrender --no-line-numbers notes.md
markrender --code-background notes.md
markrender --no-stream-code notes.md

Set a fixed width when the terminal reports the wrong size, or when the output goes somewhere else:

markrender --width 80 notes.md

Force color when piping into another program, a log file, or CI:

markrender --force-color notes.md | less -R

List the theme names:

markrender --list-themes

Preview every theme with sample content:

markrender --preview-themes

Running markrender with no file and nothing piped in prints an error and exits.

Options

Option Description
--theme NAME Color theme (default: github-dark)
--no-line-numbers Hide line numbers in code blocks
--code-background Show a background behind code blocks
--width N Wrap at a fixed width instead of the terminal width
--no-stream-code Render code blocks in one pass instead of line by line
--force-color Emit colors even when the output is not a terminal
--list-themes Print available themes and exit
--preview-themes Render sample markdown in every theme and exit
-v, --version Print the version and exit

CLI flags override values from a config file. See Configuration.

Python API

Render a string

from markrender import MarkdownRenderer

renderer = MarkdownRenderer()

markdown = """
# Hello

Some **bold** text, some *italic* text, and `inline code`.

```python
def hello():
    print("Hello from MarkRender!")
```

- A list item
- [x] A finished task
- [ ] A pending task
"""

renderer.render(markdown)
renderer.finalize()

render() writes output as it parses, and finalize() flushes whatever is still buffered. For a string you already have, call them one after the other.

Streaming LLM responses

from markrender import MarkdownRenderer
from openai import OpenAI

client = OpenAI()
renderer = MarkdownRenderer(theme="github-dark")

stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Explain quantum computing"}],
    stream=True,
)

for chunk in stream:
    text = chunk.choices[0].delta.content
    if text:
        renderer.render(text)

renderer.finalize()

The renderer keeps partial lines and open blocks in an internal buffer, so chunks can split anywhere: mid-word, mid-table, or in the middle of a code fence. Feed every chunk and call finalize() once when the stream ends.

Dim mode

render() takes a dim_mode argument, which draws that chunk as plain muted gray. Formatting colors, bold, and syntax highlighting are dropped so the whole block reads like thinking text instead of competing with the answer:

renderer.render("Let me think about this...", dim_mode=True)
renderer.render("Here is the answer.", dim_mode=False)

Dim mode applies per call, so you can turn it on and off while streaming.

Custom output

By default output goes to stdout. Pass any text stream with output:

from markrender import MarkdownRenderer

with open("rendered.txt", "w", encoding="utf-8") as log:
    renderer = MarkdownRenderer(output=log, force_color=True)
    renderer.render("# Saved to a file\n")
    renderer.finalize()

Color detection still looks at stdout, so set force_color=True if you want ANSI colors in the file.

Constructor options

Parameter Default Description
theme "github-dark" Theme name
code_background False Draw a background behind code blocks
line_numbers True Show line numbers in code blocks
inline_code_color theme default ANSI color code for inline code
width auto-detect Wrap width in characters
force_color False Emit color even when the output is not a TTY
stream_code True Render code lines as they arrive
output sys.stdout Stream to write to
use_config True Load a config file if one is found
config None Pass a RendererConfig directly

Custom inline code color uses the rgb helper:

from markrender import MarkdownRenderer
from markrender.colors import rgb

renderer = MarkdownRenderer(
    theme="monokai",
    inline_code_color=rgb(255, 100, 200),
    width=100,
)

Configuration

MarkRender reads a TOML config file if one exists. It checks these locations in order and uses the first match:

  1. .markrender.toml in the current directory
  2. ~/.markrender/config.toml
  3. ~/.config/markrender/config.toml

Example .markrender.toml:

[theme]
name = "dracula"

[rendering]
code_background = true
line_numbers = false

[output]
width = 100
force_color = false

[features]
stream_code = false

Values are applied in this order, from highest to lowest priority:

  1. Arguments passed to MarkdownRenderer(...)
  2. The config file
  3. Built-in defaults

Only non-None arguments override the config, so MarkdownRenderer() picks up your file settings. Pass use_config=False to ignore config files entirely.

Themes

Theme Notes
github-dark GitHub's dark theme (default)
monokai Classic Monokai palette
dracula Dracula palette
nord Nord palette
one-dark Atom One Dark
solarized-dark Solarized Dark
solarized-light Solarized Light
renderer = MarkdownRenderer(theme="dracula")

See the names from the CLI with markrender --list-themes, or render a sample in each theme with markrender --preview-themes.

Supported Markdown Features

Headings

# H1 Heading
## H2 Heading
### H3 Heading
#### H4 Heading
##### H5 Heading
###### H6 Heading

Code Blocks

```python
def example():
    return "Syntax highlighted!"
```

Inline Code

Use `inline code` for short snippets.

Tables

| Feature | Supported |
|---------|-----------|
| Tables  | Yes       |
| Borders | Yes       |

Lists

- Unordered item 1
- Unordered item 2
  - Nested item

1. Ordered item 1
2. Ordered item 2

Checkboxes

- [x] Completed task
- [ ] Pending task

Blockquotes

> This is a blockquote
> It can span multiple lines

Alerts (GitHub-flavored)

> [!NOTE]
> Useful information users should know

> [!TIP]
> Helpful advice

> [!IMPORTANT]
> Key information

> [!WARNING]
> Urgent information

> [!CAUTION]
> Potential negative consequences
[Link text](https://example.com)

Text Formatting

**Bold text**
*Italic text*
***Bold and italic***
~~Strikethrough~~

Emojis

Hello :wave: Let's :rocket: go!

Horizontal Rules

---

Use Cases

  • AI Chat Applications - Render LLM responses in CLI tools
  • Documentation Viewers - Display markdown documentation in terminal
  • Code Review Tools - Show code diffs and comments
  • Note-Taking Apps - Terminal-based markdown note viewers
  • Log Viewers - Render structured logs with markdown

Development

Setup Development Environment

git clone https://github.com/Praneeth-Gandodi/markrender.git
cd markrender
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -e ".[dev]"

Run Tests

pytest tests/ -v
pytest tests/ --cov=markrender --cov-report=html --cov-report=term

Run Examples

python examples/basic_usage.py
python examples/streaming_demo.py
python examples/theme_showcase.py

Releasing

The package version is derived from git tags by setuptools_scm, so there is no version number to edit by hand.

  1. Open Actions → Publish → Run workflow.
  2. Choose auto (recommended) or an explicit patch, minor, or major bump.
  3. The workflow runs the tests, creates the next vX.Y.Z tag, builds the sdist and wheel, publishes to PyPI, and creates a GitHub release.

With auto, commit messages since the last tag decide the bump:

  • feat!: or a BREAKING CHANGE: footer → major
  • feat: → minor
  • everything else → patch

Publishing uses PyPI Trusted Publishing (OIDC), so no API token is stored in the repository. Configure it once:

  • PyPI: project markrender → Publishing → add a trusted publisher with owner Praneeth-Gandodi, repository markrender, workflow publish.yml, environment pypi.
  • GitHub: Settings → Environments → create an environment named pypi.

The repository default workflow permission can stay read-only; the workflow requests contents: write only for the jobs that create the tag and release.

You can also publish an existing tag directly:

git tag v1.1.0
git push origin v1.1.0

To publish automatically after every merge to main, uncomment the branches: [main] trigger in .github/workflows/publish.yml.

License

MIT License - see LICENSE file for details.

Metadata

Release files for markrender 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markrender 1.1.1
File Size Uploaded Provenance Actions
markrender-1.1.1.tar.gz 51.9 kB With provenance Details for markrender-1.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for markrender 1.1.1
File Interpreter ABI Platform Actions
markrender-1.1.1-py3-none-any.whl Python 3 none any Details for markrender-1.1.1-py3-none-any.whl

Total release size: 76.3 kB

Release files / markrender-1.1.1.tar.gz

Download URL markrender-1.1.1.tar.gz
Size 51.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2c30d95a69035480f34da2fd5a2bc058255ba7b7b8e080814fbcfec8499c4076
BLAKE2b-256 checksum
How to use checksums
c2759ad6d836f880203dc36277b432cddaf088e8921a8e43a4959e3957801b3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / markrender-1.1.1-py3-none-any.whl

Download URL markrender-1.1.1-py3-none-any.whl
Size 24.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ff69fddec92882e15384fb7279849ac1da73355bfc5c6527878ef97041a529c
BLAKE2b-256 checksum
How to use checksums
ae54f4d0ee982784d42e34de934c3b3ffbe2ad971a241ae319893f927168c6b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for markrender 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for markrender-1.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page