perl
view release on metacpan or search on metacpan
cpan/podlators/lib/Pod/Man.pm view on Meta::CPAN
my $font_end = qr{ (?: \\f[PR] | \Q$self->{FONTS}{100}\E ) }xms;
$nroff =~ s{\Q$self->{FONTS}{100}\E(.*?)\\f([PR])}{$1}xmsg;
$nroff =~ s{\Q$self->{FONTS}{101}\E}{\\fI}xmsg;
$nroff =~ s{\Q$self->{FONTS}{110}\E}{\\fB}xmsg;
$nroff =~ s{\Q$self->{FONTS}{111}\E}{\\f\(BI}xmsg;
# We have to deal with \*C` and \*C', which are used to add the quotes
# around C<> text, since they may expand to " and if they do this
# confuses the .SH macros and the like no end. Expand them ourselves.
my $c_is_quote = index("$self->{LQUOTE}$self->{RQUOTE}", qq(\")) != -1;
if ($c_is_quote && $text =~ m{ \\[*]\(C[\'\`] }xms) {
$nroff =~ s{ \\[*]\(C\` }{$self->{LQUOTE}}xmsg;
$nroff =~ s{ \\[*]\(C\' }{$self->{RQUOTE}}xmsg;
$troff =~ s{ \\[*]\(C[\'\`] }{}xmsg;
}
# Now finally output the command. Bother with .ie only if the nroff
# and troff output aren't the same.
$nroff = _quote_macro_argument($nroff) . ($extra ? " $extra" : '');
$troff = _quote_macro_argument($troff) . ($extra ? " $extra" : '');
if ($nroff ne $troff) {
return ".ie n $command $nroff\n.el $command $troff\n";
} else {
return "$command $nroff\n";
}
} else {
$text = _quote_macro_argument($text) . ($extra ? " $extra" : '');
return "$command $text\n";
}
}
# Protect leading quotes and periods against interpretation as commands. Also
# protect anything starting with a backslash, since it could expand or hide
# something that *roff would interpret as a command. This is overkill, but
# it's much simpler than trying to parse *roff here.
sub protect {
my ($self, $text) = @_;
$text =~ s/^([.\'\\])/\\&$1/mg;
return $text;
}
# Make vertical whitespace if NEEDSPACE is set, appropriate to the indentation
# level the situation. This function is needed since in *roff one has to
# create vertical whitespace after paragraphs and between some things, but
# other macros create their own whitespace. Also close out a sequence of
# repeated =items, since calling makespace means we're about to begin the item
# body.
sub makespace {
my ($self) = @_;
$self->output (".PD\n") if $$self{ITEMS} > 1;
$$self{ITEMS} = 0;
$self->output ($$self{INDENT} > 0 ? ".Sp\n" : ".PP\n")
if $$self{NEEDSPACE};
}
# Output any pending index entries, and optionally an index entry given as an
# argument. Support multiple index entries in X<> separated by slashes, and
# strip special escapes from index entries.
sub outindex {
my ($self, $section, $index) = @_;
my @entries = map { split m%\s*/\s*% } @{ $$self{INDEX} };
return unless ($section || @entries);
# We're about to output all pending entries, so clear our pending queue.
$$self{INDEX} = [];
# Build the output. Regular index entries are marked Xref, and headings
# pass in their own section. Undo some *roff formatting on headings.
my @output;
if (@entries) {
push @output, [ 'Xref', join (' ', @entries) ];
}
if ($section) {
$index =~ s/\\-/-/g;
$index =~ s/\\\`/\`/g;
$index =~ s/\\[*]\(Aq/\'/g;
$index =~ s/\\(?:.\(..|.)//g;
push @output, [ $section, $index ];
}
# Print out the .IX commands.
for (@output) {
my ($type, $entry) = @$_;
$entry =~ s/\s+/ /g;
$entry =~ s/\"/\"\"/g;
$entry =~ s/\\/\\\\/g;
$self->output (".IX $type " . '"' . $entry . '"' . "\n");
}
}
# Output some text, without any additional changes.
sub output {
my ($self, @text) = @_;
my $text = join('', @text);
$text =~ s{$NBSP}{\\ }xmsg;
$text =~ s{$SHY}{\\%}xmsg;
if ($$self{ENCODE} && _needs_encode($$self{ENCODING})) {
my $check = sub {
my ($char) = @_;
my $display = '"\x{' . hex($char) . '}"';
my $error = "$display does not map to $$self{ENCODING}";
$self->whine ($self->line_count(), $error);
return Encode::encode ($$self{ENCODING}, chr($char));
};
my $output = Encode::encode ($$self{ENCODING}, $text, $check);
print { $$self{output_fh} } $output;
} else {
print { $$self{output_fh} } $text;
}
}
##############################################################################
# Document initialization
##############################################################################
# Handle the start of the document. Here we handle empty documents, as well
# as setting up our basic macros in a preamble and building the page title.
sub start_document {
my ($self, $attrs) = @_;
if ($$attrs{contentless} && !$$self{ALWAYS_EMIT_SOMETHING}) {
( run in 1.965 second using v1.01-cache-2.11-cpan-71847e10f99 )