Skip to main content

A textual markdown viewer CLI

Project description

A modern, feature-rich terminal-based Markdown viewer with pipeline support, built with Textual.

PyPI version Python versions License

Table of Contents

Features

  • ๐Ÿ“ Render Markdown files directly in your terminal
  • ๐Ÿ”„ Pipeline support - pipe markdown content directly to txmd
  • ๐Ÿ—‚๏ธ Dynamic Table of Contents - Navigate long documents with hierarchical TOC
  • ๐ŸŽจ Syntax highlighting for code blocks
  • ๐Ÿ“Š Table support
  • ๐Ÿ–ผ๏ธ Beautiful TUI interface powered by Textual
  • โŒจ๏ธ Vim-style navigation (j/k for scrolling)
  • ๐Ÿš€ Fast and lightweight

Installation

You can install txmd using pip:

pip install txmd

Or using Poetry:

poetry add txmd

Usage

Basic Usage

View a Markdown file:

txmd README.md

Pipeline Usage

Pipe content to txmd:

echo "# Hello World" | txmd
cat document.md | txmd
curl https://raw.githubusercontent.com/user/repo/main/README.md | txmd

Table of Contents

For documents with headers, txmd provides a dynamic Table of Contents sidebar:

Toggle TOC:

  • t - Show/hide the Table of Contents panel

Using the TOC:

  • The TOC automatically parses all headers (# through ######) in your document
  • Headers are displayed in a hierarchical tree structure
  • Navigate with arrow keys (โ†‘/โ†“) when TOC is focused
  • Press Enter to expand/collapse sections with subsections
  • Press Space to jump to the selected section (positions it at top of screen)
  • Click a header to jump directly to that section
  • Leaf sections (no subsections) have no expand icon for cleaner display
  • Hidden by default to maximize reading space

The TOC is especially useful for:

  • Long documentation files with many sections
  • README files with multiple chapters
  • Technical documentation with nested topics
  • Any structured markdown content

Navigation

Inside the viewer, you can navigate using vim-style keys or traditional navigation keys:

Basic Scrolling:

  • j or โ†“ - Scroll down one line
  • k or โ†‘ - Scroll up one line

Page Scrolling:

  • Space or Page Down - Scroll down one page
  • b or Page Up - Scroll up one page

Jump to Position:

  • Home - Jump to the top of the document
  • End - Jump to the bottom of the document

Exit:

  • q or Ctrl+C - Quit the viewer

Keybindings Reference

Complete list of all keybindings:

Key(s) Action Description
j, โ†“ Scroll Down Move down one line
k, โ†‘ Scroll Up Move up one line
Space, Page Down Page Down Scroll down by viewport height
b, Page Up Page Up Scroll up by viewport height
Home Jump to Top Scroll to the beginning of the document
End Jump to Bottom Scroll to the end of the document
t Toggle TOC Show/hide Table of Contents sidebar
q, Ctrl+C Quit Exit the application

Note: All scrolling operations happen instantly without animation for a responsive feel.

Examples

txmd includes a collection of example markdown files demonstrating various features:

# View basic markdown features
txmd examples/basic.md

# See syntax highlighting for various languages
txmd examples/code-blocks.md

# Explore table formatting
txmd examples/tables.md

# Check out advanced features
txmd examples/advanced.md

See the examples directory for more information and sample files.

Supported Markdown Features

txmd supports all standard Markdown elements through Textual's Markdown widget:

Feature Support Notes
Headers โœ… Full All levels (H1-H6)
Text Formatting โœ… Full Bold, italic, strikethrough
Lists โœ… Full Ordered, unordered, nested
Code Blocks โœ… Full Syntax highlighting for 100+ languages
Inline Code โœ… Full Monospace formatting
Tables โœ… Full With column alignment
Blockquotes โœ… Full Including nested quotes
Horizontal Rules โœ… Full Visual separators
Links โœ… Full Displayed with formatting
Images โš ๏ธ Partial Text representation in terminal

Code Syntax Highlighting

Syntax highlighting is supported for many languages including:

  • Python, JavaScript, TypeScript, Rust, Go
  • Java, C, C++, C#, Ruby, PHP
  • Bash, Shell, PowerShell
  • HTML, CSS, SCSS, JSON, YAML, TOML, XML
  • SQL, Markdown, and many more

Pipeline Integration

txmd is designed to work seamlessly in Unix pipelines. This means you can:

# Preview markdown before committing
git show HEAD:README.md | txmd

# View remote markdown files
curl -s https://raw.githubusercontent.com/user/repo/main/README.md | txmd

# View markdown from any command output
echo "# Dynamic Content\n\nGenerated at $(date)" | txmd

# Process and view markdown
grep -A 10 "## Section" document.md | txmd

How it works: txmd detects piped input, reads the content, and then restores terminal control by reopening /dev/tty. This allows the TUI to function normally even when receiving piped input.

Platform Note: Full pipeline support works on Linux and macOS. On Windows, use WSL or Windows Terminal for best results.

Documentation

Comprehensive documentation is available:

  • CONTRIBUTING.md - Detailed contribution guidelines, development setup, coding standards, and PR process
  • ARCHITECTURE.md - Technical architecture, design decisions, and component details
  • TROUBLESHOOTING.md - Solutions for common issues and debugging help
  • CLAUDE.md - AI assistant context and project overview
  • examples/ - Sample markdown files demonstrating features

Development

Quick Start

  1. Clone the repository:

    git clone https://github.com/guglielmo/txmd
    cd txmd
    
  2. Install Poetry (if not already installed):

    curl -sSL https://install.python-poetry.org | python3 -
    
  3. Install dependencies:

    poetry install
    
  4. Run from source:

    poetry run txmd README.md
    
  5. Run tests:

    poetry run pytest
    

Code Quality

# Format code
poetry run black txmd/

# Sort imports
poetry run isort txmd/

# Lint code
poetry run flake8 txmd/

# Run all checks
poetry run black txmd/ && poetry run isort txmd/ && poetry run flake8 txmd/ && poetry run pytest

Project Structure

txmd/
โ”œโ”€โ”€ txmd/
โ”‚   โ”œโ”€โ”€ __init__.py      # Package initialization
โ”‚   โ”œโ”€โ”€ cli.py           # Main application (CLI + TUI)
โ”‚   โ””โ”€โ”€ toc.py           # Table of Contents module
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ test_cli.py      # CLI test suite
โ”‚   โ””โ”€โ”€ test_toc.py      # TOC test suite
โ”œโ”€โ”€ examples/            # Example markdown files
โ”‚   โ”œโ”€โ”€ basic.md
โ”‚   โ”œโ”€โ”€ code-blocks.md
โ”‚   โ”œโ”€โ”€ tables.md
โ”‚   โ”œโ”€โ”€ advanced.md
โ”‚   โ””โ”€โ”€ README.md
โ”œโ”€โ”€ CONTRIBUTING.md      # Contribution guidelines
โ”œโ”€โ”€ ARCHITECTURE.md      # Technical documentation
โ”œโ”€โ”€ TROUBLESHOOTING.md   # Common issues and solutions
โ”œโ”€โ”€ CLAUDE.md            # AI assistant context
โ”œโ”€โ”€ pyproject.toml       # Poetry configuration
โ””โ”€โ”€ README.md            # This file

For detailed development information, see CONTRIBUTING.md and ARCHITECTURE.md.

Contributing

Contributions are welcome and appreciated! We'd love your help making txmd better.

Quick Contribution Guide

  1. Fork and clone the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Run quality checks:
    poetry run black txmd/
    poetry run isort txmd/
    poetry run flake8 txmd/
    poetry run pytest
    
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to your fork: git push origin feature/amazing-feature
  7. Open a Pull Request

What to Contribute

  • ๐Ÿ› Bug fixes - Help us squash bugs
  • โœจ New features - Add capabilities from the roadmap
  • ๐Ÿ“ Documentation - Improve or add documentation
  • โœ… Tests - Increase test coverage
  • ๐ŸŽจ Examples - Create new example markdown files

Before Contributing

Please read our comprehensive CONTRIBUTING.md guide which covers:

  • Development setup and workflow
  • Coding standards and style guide
  • Testing guidelines
  • PR process and review guidelines
  • Project architecture and structure

Getting Help

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Troubleshooting

Having issues? Check our TROUBLESHOOTING.md guide for solutions to common problems:

  • Installation issues
  • Pipeline/stdin problems
  • Display and rendering issues
  • Platform-specific issues (Windows, macOS, Linux)
  • Performance problems

Quick Fixes

Command not found after install:

# Try running with python -m
python -m txmd README.md

# Or ensure ~/.local/bin is in PATH
export PATH="$HOME/.local/bin:$PATH"

No colors/syntax highlighting:

# Check terminal type
echo $TERM  # Should be something like xterm-256color

# Set if needed
export TERM=xterm-256color

Pipeline not working on Windows:

# Use WSL for full pipeline support
wsl -e txmd README.md

For more help, see the full troubleshooting guide.

FAQ

Q: Why use txmd instead of other markdown viewers? A: txmd is designed to be lightweight, fast, and integrate seamlessly with Unix pipelines while providing a beautiful TUI interface. It's perfect for developers who live in the terminal.

Q: Does txmd support custom themes? A: Not yet, but it's on our roadmap! Custom theme support is planned for v0.2.0 or later.

Q: Can I use txmd to preview markdown before committing to git? A: Absolutely! git show HEAD:README.md | txmd or git diff main...HEAD | txmd

Q: Does txmd work on Windows? A: Yes, but for best results use Windows Terminal or WSL. Pipeline support works best on Linux/macOS or WSL.

Q: Can I view multiple files at once? A: Not yet, but multi-file support with tabs is on the roadmap!

Q: How do I report a bug or request a feature? A: Open an issue on GitHub with details about the bug or feature request.

Roadmap

v0.4.0 - Table of Contents (Released)

Completed:

  • Table of Contents - Dynamic TOC with hierarchical navigation
    • Hierarchical tree view of document headers
    • Toggle with 't' key
    • Navigate with arrow keys, expand/collapse with Enter, jump with Space
    • Filters headers in code blocks
  • Comprehensive Testing - 84% test coverage with UI interaction tests

v0.5.0 - Enhanced Features (Planned)

In Development:

  • Multi-file support - View multiple markdown files with tab navigation
  • Search functionality - Find text within documents with incremental search
  • Bookmark support - Mark and jump to important sections
  • Custom themes - Support for custom color schemes and styling

Future Versions

Additional features planned for future releases:

  • Configuration file - User preferences and custom keybindings
  • GitHub Flavored Markdown - Extended markdown syntax support
  • Image preview - Terminal graphics protocol support (Kitty, iTerm2)
  • Export functionality - Convert to HTML, PDF
  • Watch mode - Auto-reload on file changes
  • Split view - View two documents side by side

See the GitHub issues and project milestones for more details.

Support

Getting Help

Project Links

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

txmd-0.4.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

txmd-0.4.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file txmd-0.4.0.tar.gz.

File metadata

  • Download URL: txmd-0.4.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for txmd-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ccbb661ed99eae40d7851862a11067483a248a7efa583b3d33693276305e41c0
MD5 0c89bc36212e622625f1d50a6ff5a264
BLAKE2b-256 c5e5b36ef015f9801aa5c40c23edbe60fa4007cd69c55715178dd1cbd55467c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for txmd-0.4.0.tar.gz:

Publisher: publish.yml on guglielmo/txmd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file txmd-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: txmd-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for txmd-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e71ae0b5d22217c90ecfa9cbb43a9e1bb9d61066deeeffb4315b438807e1447a
MD5 9509ad94ff9503149c43e3e92c83f047
BLAKE2b-256 9410bc2b2a5c561011ce170068a201ba34a1a040e8feca031c6e816e1ce9eeb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for txmd-0.4.0-py3-none-any.whl:

Publisher: publish.yml on guglielmo/txmd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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