Add support for bullet lists.
git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@465 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
85ca38e143
commit
eed493316e
1 changed files with 41 additions and 9 deletions
|
@ -134,6 +134,7 @@ sub parse_source($) {
|
||||||
my $argnames;
|
my $argnames;
|
||||||
my $man;
|
my $man;
|
||||||
my $inlist;
|
my $inlist;
|
||||||
|
my $intaglist;
|
||||||
my $inliteral;
|
my $inliteral;
|
||||||
my %xref;
|
my %xref;
|
||||||
my @errors;
|
my @errors;
|
||||||
|
@ -196,7 +197,7 @@ sub parse_source($) {
|
||||||
# and surround with ()
|
# and surround with ()
|
||||||
$argnames =~ s/^\"(.*)\"$/($1)/;
|
$argnames =~ s/^\"(.*)\"$/($1)/;
|
||||||
# $argnames is now a regexp that matches argument names
|
# $argnames is now a regexp that matches argument names
|
||||||
$inliteral = $inlist = 0;
|
$inliteral = $inlist = $intaglist = 0;
|
||||||
foreach (split("\n", $source)) {
|
foreach (split("\n", $source)) {
|
||||||
s/\s*$//;
|
s/\s*$//;
|
||||||
if (!defined($man)) {
|
if (!defined($man)) {
|
||||||
|
@ -209,12 +210,13 @@ sub parse_source($) {
|
||||||
s/^ \* ?//;
|
s/^ \* ?//;
|
||||||
s/\\(.)/$1/gs;
|
s/\\(.)/$1/gs;
|
||||||
if (m/^$/) {
|
if (m/^$/) {
|
||||||
|
# paragraph separator
|
||||||
if ($man ne "" && $man !~ m/\.Pp\n$/s) {
|
if ($man ne "" && $man !~ m/\.Pp\n$/s) {
|
||||||
if ($inliteral) {
|
if ($inliteral) {
|
||||||
$man .= "\0\n";
|
$man .= "\0\n";
|
||||||
} elsif ($inlist) {
|
} elsif ($inlist || $intaglist) {
|
||||||
$man .= ".El\n.Pp\n";
|
$man .= ".El\n.Pp\n";
|
||||||
$inlist = 0;
|
$inlist = $intaglist = 0;
|
||||||
} else {
|
} else {
|
||||||
$man .= ".Pp\n";
|
$man .= ".Pp\n";
|
||||||
}
|
}
|
||||||
|
@ -222,35 +224,63 @@ sub parse_source($) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if (m/^>(\w+)(\s+\d)?$/) {
|
if (m/^>(\w+)(\s+\d)?$/) {
|
||||||
|
# "see also" cross-reference
|
||||||
my ($page, $sect) = ($1, $2 ? int($2) : 3);
|
my ($page, $sect) = ($1, $2 ? int($2) : 3);
|
||||||
++$xref{$sect}->{$page};
|
++$xref{$sect}->{$page};
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
if (s/^\s+([=%]?\w+):\s*/.It $1/) {
|
if (s/^\s+-\s+//) {
|
||||||
|
# item in bullet list
|
||||||
if ($inliteral) {
|
if ($inliteral) {
|
||||||
$man .= ".Ed\n";
|
$man .= ".Ed\n";
|
||||||
$inliteral = 0;
|
$inliteral = 0;
|
||||||
}
|
}
|
||||||
|
if ($intaglist) {
|
||||||
|
$man .= ".El\n.Pp\n";
|
||||||
|
$intaglist = 0;
|
||||||
|
}
|
||||||
if (!$inlist) {
|
if (!$inlist) {
|
||||||
$man =~ s/\.Pp\n$//s;
|
$man =~ s/\.Pp\n$//s;
|
||||||
$man .= ".Bl -tag -width 18n\n";
|
$man .= ".Bl -bullet\n";
|
||||||
$inlist = 1;
|
$inlist = 1;
|
||||||
}
|
}
|
||||||
|
$man .= ".It\n";
|
||||||
|
# fall through
|
||||||
|
} elsif (s/^\s+(\S+):\s*/.It $1/) {
|
||||||
|
# item in tag list
|
||||||
|
if ($inliteral) {
|
||||||
|
$man .= ".Ed\n";
|
||||||
|
$inliteral = 0;
|
||||||
|
}
|
||||||
|
if ($inlist) {
|
||||||
|
$man .= ".El\n.Pp\n";
|
||||||
|
$inlist = 0;
|
||||||
|
}
|
||||||
|
if (!$intaglist) {
|
||||||
|
$man =~ s/\.Pp\n$//s;
|
||||||
|
$man .= ".Bl -tag -width 18n\n";
|
||||||
|
$intaglist = 1;
|
||||||
|
}
|
||||||
s/^\.It =([A-Z][A-Z_]+)$/.It Dv $1/gs;
|
s/^\.It =([A-Z][A-Z_]+)$/.It Dv $1/gs;
|
||||||
$man .= "$_\n";
|
$man .= "$_\n";
|
||||||
next;
|
next;
|
||||||
} elsif ($inlist && m/^\S/) {
|
} elsif (($inlist || $intaglist) && m/^\S/) {
|
||||||
|
# regular text after list
|
||||||
$man .= ".El\n.Pp\n";
|
$man .= ".El\n.Pp\n";
|
||||||
$inlist = 0;
|
$inlist = $intaglist = 0;
|
||||||
} elsif ($inliteral && m/^\S/) {
|
} elsif ($inliteral && m/^\S/) {
|
||||||
|
# regular text after literal section
|
||||||
$man .= ".Ed\n";
|
$man .= ".Ed\n";
|
||||||
$inliteral = 0;
|
$inliteral = 0;
|
||||||
} elsif ($inliteral) {
|
} elsif ($inliteral) {
|
||||||
|
# additional text within literal section
|
||||||
$man .= "$_\n";
|
$man .= "$_\n";
|
||||||
next;
|
next;
|
||||||
} elsif ($inlist) {
|
} elsif ($inlist || $intaglist) {
|
||||||
|
# additional text within list
|
||||||
s/^\s+//;
|
s/^\s+//;
|
||||||
} elsif (m/^\s+/) {
|
} elsif (m/^\s+/) {
|
||||||
|
# new literal section
|
||||||
$man .= ".Bd -literal\n";
|
$man .= ".Bd -literal\n";
|
||||||
$inliteral = 1;
|
$inliteral = 1;
|
||||||
$man .= "$_\n";
|
$man .= "$_\n";
|
||||||
|
@ -272,11 +302,13 @@ sub parse_source($) {
|
||||||
$man .= "$_\n";
|
$man .= "$_\n";
|
||||||
}
|
}
|
||||||
if (defined($man)) {
|
if (defined($man)) {
|
||||||
if ($inlist) {
|
if ($inlist || $intaglist) {
|
||||||
$man .= ".El\n";
|
$man .= ".El\n";
|
||||||
|
$inlist = $intaglist = 0;
|
||||||
}
|
}
|
||||||
if ($inliteral) {
|
if ($inliteral) {
|
||||||
$man .= ".Ed\n";
|
$man .= ".Ed\n";
|
||||||
|
$inliteral = 0;
|
||||||
}
|
}
|
||||||
$man =~ s/\%/\\&\%/gs;
|
$man =~ s/\%/\\&\%/gs;
|
||||||
$man =~ s/(\n\.[A-Z][a-z] [\w ]+)\n([\.,:;-]\S*)\s*/$1 $2\n/gs;
|
$man =~ s/(\n\.[A-Z][a-z] [\w ]+)\n([\.,:;-]\S*)\s*/$1 $2\n/gs;
|
||||||
|
|
Loading…
Reference in a new issue