man2html - AutoOpts Simple Client


XML Defs


Man example
local use
using getopt






Project GNU
Home Page


xdr project


Man2html is an AutoOpts "Hello, world!" example that does something. It is yet another program to convert man page display text into html code. See the usage text or its own man page for more details. It is being released in conjunction with AutoGen for several reasons:

An AutoOpts example
This is a very simple example showing how to use AutoOpts for local-only builds.

The Perl man2html is broken
Unfortunately, it seems to have bugs and drops sections of output.

Output form
Most man2html programs presume they are producing the entire page. This one does not, so the output can be formatted to fit within a frame or HTML table entry (as in this page).

The "local only build" usage is actually very simple. Here is the full Makefile for this project:

  CVSSRC  = Makefile man2html.c opts.def README
  SRC     = opts.c man2html.c
  OBJ     = $(SRC:.c=.o)
  DOCS    = man2html.1 man2html.html
  CFLAGS  = -g `autoopts-config cflags`
  LDFLAGS = `autoopts-config libs`
  default : man2html
  all     : man2html $(DOCS)
  opts.h : opts.c
  opts.c : opts.def
      autogen opts.def
  $(OBJ) : opts.h
  man2html : man2html.o opts.o
      $(CC) -o $@ man2html.o opts.o $(LDFLAGS)
  clobber :
      rm -rf $(OBJ) opts.? man2html *~ $(DOCS) man2html-*
  man2html.1 : opts.def
      autogen -T agman-cmd.tpl -b man2html opts.def
  man2html.html : man2html.1 man2html
      nroff -man man2html.1 | ./man2html -u > $@
  dist :
      ver=`sed -n 's/^version *=//p' opts.def` ; \
      ver=`eval echo $$ver` ; \
      rm -rf man2html-$$ver ; mkdir man2html-$$ver ; \
      cp $(CVSSRC) man2html-$$ver/. ; \
      tar cvf - man2html-$$ver | gzip --best > man2html-$$ver.tar.gz ; \
      rm -rf man2html-$$ver

man2html Man Page Converter

Here is the AutoGen-erated usage text:

man2html - convert nroff output to html - Ver. 2.0
USAGE:  man2html [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ <input-file> ]
  Flg Arg Option-Name    Description
   -u no  blank-lines    Remove multiple blank lines
   -f KWd form           HTML form type (default:  html PAGE)
      no  bs-warning     Warn on unprocessed backspaces
   -p no  pea            omit attribution
   -h Str header         regex for identifying page headers
				- disabled as '--no-header'
				- enabled by default
      Str section-flag   section option flag for 'man(1)'
   -v opt version        Output version information and exit
   -? no  help           Display usage information and exit
   -! no  more-help      Extended usage information passed thru pager

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.

The input may come from standard input, or be specified on the command
line.  If it is specified on the command line but cannot be found
directly, then the ``man(1)'' command will be invoked using this name.

The valid "form" option keywords are:
  page xhtml body pre
  or an integer from 0 through 3

Makes the following conversions:
 * backspace/overstrikes to bold.
 * backspace/underbar (either order) to italic.
 * bar/backspace/dash to `+' (also handle bold rendering)
 * bar/backspace/equals to `*' (also handle bold rendering)
 * plus/backspace/o to `o'
 * maps HTML special characters: '<', '>' and '&' to
   '&lt;', '&gt;' and '&amp;', respectively.

If a man page name is specified and the name contains a suffix,
the suffix will be stripped from the name and passed to ``man(1)''
as a separate argument.  An attempt is made when ``man2html'' is
built to determine if this argument should be introduced with a ``-s''
or ``-S'' option marker, or by itself as the initial argument.

All text preceeding the ``NAME'' section marker is stripped.

Please send bug reports to:  <>

Man Page for man2html

Here is its own generated man page:


This man page was converted to HTML by man2html

top  Viewable With Any Browser  Valid XHTML 1.0!

AutoGen, AutoOpts, columns, getdefs, AutoFSM, AutoXDR and these web pages copyright (c) 1999-2012 Bruce Korb, all rights reserved.

Return to GNU's home page.

Please send FSF & GNU inquiries & questions to There are also other ways to contact the FSF.

Please send comments on these web pages to, send other questions to

This article, Copyright © 2000-2002 by Bruce Korb

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. Last modified: Sun Sep 8 12:45:50 PDT 2013