A tool to convert Unix manual pages (troff format) to HTML. Originally developed by Sun Microsystems for the Tcl/Tk documentation.
This tool consists of two main components:
- man2tcl - A C program that parses troff-formatted man pages and converts them to Tcl scripts
- man2html.tcl - A Tcl script that processes the output from man2tcl and generates HTML files
- GCC compiler
- Make
- Tcl/Tclsh (for running the conversion scripts)
To build the man2tcl executable:
makeThis will compile man2tcl.c and create the man2tcl (or man2tcl.exe on Windows) executable.
To remove build artifacts:
make cleanTo see available make targets:
make helpThe main script man2html.tcl accepts an input directory containing man pages and an output directory for HTML files:
./man2html.tcl <input_dir> <output_dir>Or with tclsh:
tclsh man2html.tcl <input_dir> <output_dir>Convert man pages from /usr/share/man/man1 to ./html:
./man2html.tcl /usr/share/man/man1 ./html-help- Display usage information-clean <output_dir>- Remove the specified output directory (with confirmation)
The converter looks for man pages with the following extensions:
.1- User commands.3- Library functions.n- Tcl/Tk commands (new commands)
The conversion process works in two passes:
- Scans all man pages in the input directory
- Builds a database of command names and keywords
- Creates cross-reference information for generating hyperlinks
- Processes each man page again
- Generates individual HTML files
- Creates hyperlinks between related pages
- Generates a
contents.htmlindex file
man2tcl.c- C source for the man page parserman2html.tcl- Main conversion scriptman2html1.tcl- Pass 1 procedures (hyperlink database)man2html2.tcl- Pass 2 procedures (HTML generation)Makefile- Cross-platform build system
The tool generates:
- Individual HTML files for each man page (e.g.,
command.1.html) - A
contents.htmlfile with an index of all converted pages - Organized sections for:
- User Commands (*.1)
- Tcl/Tk Commands (*.n)
- Library Functions (*.3)
The build system supports:
- Linux/Unix - Native build with GCC
- Windows (MSYS/MinGW) - Unix-like environment on Windows
- Windows (Native) - Native Windows build with appropriate compiler
The Makefile automatically detects the platform and adjusts accordingly.
- The tool expects man pages in standard troff format
- HTML output uses basic HTML tags (HTML 4.01 style)
- Cross-references are automatically detected and converted to hyperlinks
- The converter handles common troff macros (.SH, .TH, .TP, .IP, etc.)
Make sure you've built the man2tcl executable:
makeAnd that it's in your PATH or in the same directory as man2html.tcl.
The input directory must contain files with extensions .1, .3, or .n. Check that your man pages have the correct extension.
The scripts use UTF-8 encoding. If you encounter encoding issues, make sure your man pages are in UTF-8 format, or modify the -encoding parameter in the source scripts.