askrobots / dbbasic-manx
Public
manx.py: man pages in BBS style, with ANSI colours and syntax highlighting, using only the Python standard library.
- .gitignore 173 bytes
- README.md 2.1 KB
- demo.sh 1.1 KB
- manx.py 13.7 KB
- test_width.py 1.5 KB
README.md
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 -Rfor 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
lessfor pager support (optional, falls back to basic pager)
License
MIT License - Feel free to use and modify!