Markdown to Man Page Converter
Convert Markdown files to Unix man page (troff/roff) format instantly in your browser. Supports headers, lists, code blocks, and inline formatting.
About
Unix man pages use troff/nroff markup, a formatting system dating to 1970s Bell Labs. Writing raw roff by hand is error-prone. A misplaced .SH directive or unescaped backslash breaks rendering across man, groff, and mandoc implementations. This tool converts standard Markdown into valid roff output conforming to the man(7) macro package. It handles .TH title generation, section headers (.SH/.SS), font escapes (\fB, \fI), no-fill blocks (.nf/.fi), and bullet/numbered lists (.IP). The conversion runs entirely client-side with zero server dependency.
Limitations: nested blockquotes beyond two levels flatten. Table support is basic (pipe tables convert to tab-separated .TS/.TE blocks where possible, otherwise preformatted). Image references are stripped since roff has no native image support in terminal renderers. The tool assumes UTF-8 input. Pro tip: validate output with mandoc -Tlint before distribution. Remember that man page section numbers matter: section 1 is user commands, 3 is library functions, 5 is file formats.
Formulas
The converter applies a deterministic, line-by-line state machine. Each input line is classified into a block type, then inline markup is resolved via regex substitution.
BlockType(line) → HEADING | CODE_FENCE | BULLET | ORDERED | BLOCKQUOTE | BLANK | PARAGRAPH
InlineSub(text) applies in order:
1. ``code`` → \fBcode\fR
2. **bold** → \fBbold\fR
3. *italic* → \fIitalic\fR
4. [text](url) → text (url)
5. - (leading hyphens in flags) → \-
.TH generation: .TH "NAME" "section" "date" "source" "manual"
Where NAME = uppercased title from first # heading or user-provided name. section = integer 1 - 9 (default 1). date = current date in ISO format. source and manual are optional metadata strings.
Reference Data
| Section | Content Type | Example |
|---|---|---|
| 1 | User Commands | ls, grep, git |
| 2 | System Calls | open, read, fork |
| 3 | Library Functions | printf, malloc, pthread_create |
| 4 | Special Files / Devices | /dev/null, /dev/tty |
| 5 | File Formats & Conventions | passwd, fstab, crontab |
| 6 | Games | fortune, banner |
| 7 | Miscellaneous / Macro Packages | man, ascii, regex |
| 8 | System Administration | mount, iptables, systemctl |
| 9 | Kernel Routines (Linux) | printk, kmalloc |
| Roff Macro | Purpose | Markdown Equivalent |
|---|---|---|
| .TH | Title header (name, section, date) | First # heading or filename |
| .SH | Section heading | ## heading |
| .SS | Subsection heading | ### heading |
| .PP | New paragraph | Blank line between text |
| .IP | Indented paragraph (list item) | * or - list item |
| .nf / .fi | No-fill mode (preformatted) | Fenced code block (```) |
| .BR | Bold/Roman alternating | Cross-references |
| \fB / \fR | Bold font escape | **bold** |
| \fI / \fR | Italic font escape | *italic* |
| .TP | Tagged paragraph | Definition-style lists |
| .RS / .RE | Relative indent start/end | Nested content / blockquotes |
| .BI | Bold-Italic alternating | Function signatures |
| \(bu | Bullet character | * or - prefix |
| \- | Minus sign (vs hyphen) | CLI flags like --verbose |