#!/usr/bin/perl
#
# See COPYRIGHT
#
# Script to generate a pod file from an html source (the same one as for text files too)
# and later this pod file it passed through pod2man
#
# Use:
#  html2man [ <man-dir> [<version-dir>] ] <file.html
#
# <Man-dir> is the directory where the man pages will be created
# (current directory by default). If a file name is given instead of
# directory then the directory of that file is used.
# <Version-dir> is the directory containing the ttf2pt1 files version.h
# and CHANGES.html which are used to generate the release name and date
# for the man page (by default looks in current directory and then in up to
# 5 ancestor directories).
# If the version files can not be found then the release defaults to
# "current" and the date defaults to today.
#
# Special formatting in the html file is:
# All controls are hidden within HTML comments that must occupy a whole separate line
# Such a line looks like:
# <!-- =<html2man_directive> <arguments> -->
# <!-- ==<pod_directive> <arguments> -->
# Any sort of directive must be followed by a space. The pod directives are
# automatically surrounded by empty lines in the output file.
# The html2man directives are:
#
# <!-- =defdoc <docid> <file> <section> -->
# Define a man page. Multiple man pages can be defined in the same HTML
# file. <Docid> is a short name by which this man page will be referred in the
# other directives. <File> is the name of the man page, and <section> is the
# section of the manual (do not confuse with sections within a man page).
#
# <!-- =section <docid> <page_section_name> -->
# All the text following this directive is copied (with translation)
# into the specified section of the specified man page. The sections
# may appear in arbitrary order, they will be rearranged to the standard
# order before output. Only standard section names are permitted (see @stdsect
# below). The pod directives which occur outside of man sections are ignored,
# just like the common text. The translation of HTML tags is:
#
# <br> - to paragraph break
# <b> - to B<>
# <i> - to I<>
# <tt> - to C<>
# <a href> - to F<>
# <ul>, <li>, </ul> - to =over 2, =item *, =back
# &nbsp;, &amp;, &lt;, &gt - to their symbols, appropriately encoded
#
# The rest of HTML tags is removed
#
# If the same section is started more than once, the text from the
# second appearance will be added to the first, etc.
#
# <!-- =stop -->
# Stop copying text to the man page.
#
# <!-- =cont -->
# Continue copying text to the man page, same section as before.
#
# <!-- =text <text> -->
# Insert this <text> into the man page (works only when copying is enabled).
# Characters &lt;, &gt;, &amp; are converted as usual.

@mons = qw(January February March April May June July August September October November December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} elsif( ! -d $dir ) {
	if( ! ($dir =~ s|\/Tber December);

$dir = $ARGV[0];
$maindir = $ARGV[1];

if($dir eq "") {
	$dir = ".";
} 