manx.py: man pages in BBS style, with ANSI colours and syntax highlighting, using only the Python standard library.

0 downloads

dbbasic-manx/README.md
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-manx.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-manx.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-manx.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Initial commit: BBS-style ANSI man page viewer 9414990 1 year, 1 month ago History
README.md · 2.1 KB · 86 lines

manx.py - BBS/ANSI Manual Viewer

A standalone Python script that provides BBS-style, ANSI-colored man pages with syntax highlighting and pager support.

Features

  • Zero dependencies - Uses only Python stdlib
  • ANSI colors - Beautiful 256-color terminal output with box-drawing characters
  • Syntax highlighting - Python, Shell, HTTP, TSV code blocks
  • Pager support - Works with less -R for keyboard navigation
  • Adaptive width - Automatically adjusts to terminal size (60-120 columns)
  • Respects NO_COLOR - Disable colors with NO_COLOR=1
  • Pipe-friendly - Detects when output is redirected and uses sensible defaults
  • Fully self-contained - Single file, easy to distribute

Usage

# View the menu
python manx.py

# View a specific page
python manx.py dbbasic-tsv

# Disable colors
NO_COLOR=1 python manx.py dbbasic-tsv

# Export to text file
python manx.py dbbasic-tsv > dbbasic-tsv.txt

Keyboard Navigation (in pager)

  • Arrow keys / PageUp / PageDown - Navigate
  • / - Search for text
  • n - Next search match
  • q - Quit pager

Adding New Pages

To add a new manual page, create a function that returns the formatted content:

def get_mynew_man():
    mycode = code_block("""print("Hello, World!")""", "python")

    return f"""{h1("MYNEW(1) — My New Tool")}

{BOLD}NAME{RESET}
  mynew — Description of your tool

{BOLD}SYNOPSIS{RESET}
  mynew [options] <args>

{BOLD}DESCRIPTION{RESET}
  Your tool description here.

{BOLD}EXAMPLES{RESET}
{mycode}
"""

# Register it
PAGES = {
    "dbbasic-tsv": get_dbbasic_tsv_man,
    "mynew": get_mynew_man,
}

Syntax Highlighting

Supports automatic syntax highlighting for:

  • Python - Keywords, strings, comments, numbers
  • Shell - Commands, flags, env vars, quoted args
  • HTTP - Methods, status codes, headers
  • TSV - Tab-separated values with header highlighting

Requirements

  • Python 3.6+
  • Terminal with ANSI color support
  • less for pager support (optional, falls back to basic pager)

License

MIT License - Feel free to use and modify!