1# Pod::Man -- Convert POD data to formatted *roff input. 2# 3# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 4# Russ Allbery <rra@stanford.edu> 5# Substantial contributions by Sean Burke <sburke@cpan.org> 6# 7# This program is free software; you may redistribute it and/or modify it 8# under the same terms as Perl itself. 9# 10# This module translates POD documentation into *roff markup using the man 11# macro set, and is intended for converting POD documents written as Unix 12# manual pages to manual pages that can be read by the man(1) command. It is 13# a replacement for the pod2man command distributed with versions of Perl 14# prior to 5.6. 15# 16# Perl core hackers, please note that this module is also separately 17# maintained outside of the Perl core as part of the podlators. Please send 18# me any patches at the address above in addition to sending them to the 19# standard Perl mailing lists. 20 21############################################################################## 22# Modules and declarations 23############################################################################## 24 25package Pod::Man; 26 27require 5.005; 28 29use strict; 30use subs qw(makespace); 31use vars qw(@ISA %ESCAPES $PREAMBLE $VERSION); 32 33use Carp qw(croak); 34use Pod::Simple (); 35 36@ISA = qw(Pod::Simple); 37 38$VERSION = '2.23'; 39 40# Set the debugging level. If someone has inserted a debug function into this 41# class already, use that. Otherwise, use any Pod::Simple debug function 42# that's defined, and failing that, define a debug level of 10. 43BEGIN { 44 my $parent = defined (&Pod::Simple::DEBUG) ? \&Pod::Simple::DEBUG : undef; 45 unless (defined &DEBUG) { 46 *DEBUG = $parent || sub () { 10 }; 47 } 48} 49 50# Import the ASCII constant from Pod::Simple. This is true iff we're in an 51# ASCII-based universe (including such things as ISO 8859-1 and UTF-8), and is 52# generally only false for EBCDIC. 53BEGIN { *ASCII = \&Pod::Simple::ASCII } 54 55# Pretty-print a data structure. Only used for debugging. 56BEGIN { *pretty = \&Pod::Simple::pretty } 57 58############################################################################## 59# Object initialization 60############################################################################## 61 62# Initialize the object and set various Pod::Simple options that we need. 63# Here, we also process any additional options passed to the constructor or 64# set up defaults if none were given. Note that all internal object keys are 65# in all-caps, reserving all lower-case object keys for Pod::Simple and user 66# arguments. 67sub new { 68 my $class = shift; 69 my $self = $class->SUPER::new; 70 71 # Tell Pod::Simple not to handle S<> by automatically inserting . 72 $self->nbsp_for_S (1); 73 74 # Tell Pod::Simple to keep whitespace whenever possible. 75 if ($self->can ('preserve_whitespace')) { 76 $self->preserve_whitespace (1); 77 } else { 78 $self->fullstop_space_harden (1); 79 } 80 81 # The =for and =begin targets that we accept. 82 $self->accept_targets (qw/man MAN roff ROFF/); 83 84 # Ensure that contiguous blocks of code are merged together. Otherwise, 85 # some of the guesswork heuristics don't work right. 86 $self->merge_text (1); 87 88 # Pod::Simple doesn't do anything useful with our arguments, but we want 89 # to put them in our object as hash keys and values. This could cause 90 # problems if we ever clash with Pod::Simple's own internal class 91 # variables. 92 %$self = (%$self, @_); 93 94 # Send errors to stderr if requested. 95 if ($$self{stderr}) { 96 $self->no_errata_section (1); 97 $self->complain_stderr (1); 98 delete $$self{stderr}; 99 } 100 101 # Initialize various other internal constants based on our arguments. 102 $self->init_fonts; 103 $self->init_quotes; 104 $self->init_page; 105 106 # For right now, default to turning on all of the magic. 107 $$self{MAGIC_CPP} = 1; 108 $$self{MAGIC_EMDASH} = 1; 109 $$self{MAGIC_FUNC} = 1; 110 $$self{MAGIC_MANREF} = 1; 111 $$self{MAGIC_SMALLCAPS} = 1; 112 $$self{MAGIC_VARS} = 1; 113 114 return $self; 115} 116 117# Translate a font string into an escape. 118sub toescape { (length ($_[0]) > 1 ? '\f(' : '\f') . $_[0] } 119 120# Determine which fonts the user wishes to use and store them in the object. 121# Regular, italic, bold, and bold-italic are constants, but the fixed width 122# fonts may be set by the user. Sets the internal hash key FONTS which is 123# used to map our internal font escapes to actual *roff sequences later. 124sub init_fonts { 125 my ($self) = @_; 126 127 # Figure out the fixed-width font. If user-supplied, make sure that they 128 # are the right length. 129 for (qw/fixed fixedbold fixeditalic fixedbolditalic/) { 130 my $font = $$self{$_}; 131 if (defined ($font) && (length ($font) < 1 || length ($font) > 2)) { 132 croak qq(roff font should be 1 or 2 chars, not "$font"); 133 } 134 } 135 136 # Set the default fonts. We can't be sure portably across different 137 # implementations what fixed bold-italic may be called (if it's even 138 # available), so default to just bold. 139 $$self{fixed} ||= 'CW'; 140 $$self{fixedbold} ||= 'CB'; 141 $$self{fixeditalic} ||= 'CI'; 142 $$self{fixedbolditalic} ||= 'CB'; 143 144 # Set up a table of font escapes. First number is fixed-width, second is 145 # bold, third is italic. 146 $$self{FONTS} = { '000' => '\fR', '001' => '\fI', 147 '010' => '\fB', '011' => '\f(BI', 148 '100' => toescape ($$self{fixed}), 149 '101' => toescape ($$self{fixeditalic}), 150 '110' => toescape ($$self{fixedbold}), 151 '111' => toescape ($$self{fixedbolditalic}) }; 152} 153 154# Initialize the quotes that we'll be using for C<> text. This requires some 155# special handling, both to parse the user parameter if given and to make sure 156# that the quotes will be safe against *roff. Sets the internal hash keys 157# LQUOTE and RQUOTE. 158sub init_quotes { 159 my ($self) = (@_); 160 161 $$self{quotes} ||= '"'; 162 if ($$self{quotes} eq 'none') { 163 $$self{LQUOTE} = $$self{RQUOTE} = ''; 164 } elsif (length ($$self{quotes}) == 1) { 165 $$self{LQUOTE} = $$self{RQUOTE} = $$self{quotes}; 166 } elsif ($$self{quotes} =~ /^(.)(.)$/ 167 || $$self{quotes} =~ /^(..)(..)$/) { 168 $$self{LQUOTE} = $1; 169 $$self{RQUOTE} = $2; 170 } else { 171 croak(qq(Invalid quote specification "$$self{quotes}")) 172 } 173 174 # Double the first quote; note that this should not be s///g as two double 175 # quotes is represented in *roff as three double quotes, not four. Weird, 176 # I know. 177 $$self{LQUOTE} =~ s/\"/\"\"/; 178 $$self{RQUOTE} =~ s/\"/\"\"/; 179} 180 181# Initialize the page title information and indentation from our arguments. 182sub init_page { 183 my ($self) = @_; 184 185 # We used to try first to get the version number from a local binary, but 186 # we shouldn't need that any more. Get the version from the running Perl. 187 # Work a little magic to handle subversions correctly under both the 188 # pre-5.6 and the post-5.6 version numbering schemes. 189 my @version = ($] =~ /^(\d+)\.(\d{3})(\d{0,3})$/); 190 $version[2] ||= 0; 191 $version[2] *= 10 ** (3 - length $version[2]); 192 for (@version) { $_ += 0 } 193 my $version = join ('.', @version); 194 195 # Set the defaults for page titles and indentation if the user didn't 196 # override anything. 197 $$self{center} = 'User Contributed Perl Documentation' 198 unless defined $$self{center}; 199 $$self{release} = 'perl v' . $version 200 unless defined $$self{release}; 201 $$self{indent} = 4 202 unless defined $$self{indent}; 203 204 # Double quotes in things that will be quoted. 205 for (qw/center release/) { 206 $$self{$_} =~ s/\"/\"\"/g if $$self{$_}; 207 } 208} 209 210############################################################################## 211# Core parsing 212############################################################################## 213 214# This is the glue that connects the code below with Pod::Simple itself. The 215# goal is to convert the event stream coming from the POD parser into method 216# calls to handlers once the complete content of a tag has been seen. Each 217# paragraph or POD command will have textual content associated with it, and 218# as soon as all of a paragraph or POD command has been seen, that content 219# will be passed in to the corresponding method for handling that type of 220# object. The exceptions are handlers for lists, which have opening tag 221# handlers and closing tag handlers that will be called right away. 222# 223# The internal hash key PENDING is used to store the contents of a tag until 224# all of it has been seen. It holds a stack of open tags, each one 225# represented by a tuple of the attributes hash for the tag, formatting 226# options for the tag (which are inherited), and the contents of the tag. 227 228# Add a block of text to the contents of the current node, formatting it 229# according to the current formatting instructions as we do. 230sub _handle_text { 231 my ($self, $text) = @_; 232 DEBUG > 3 and print "== $text\n"; 233 my $tag = $$self{PENDING}[-1]; 234 $$tag[2] .= $self->format_text ($$tag[1], $text); 235} 236 237# Given an element name, get the corresponding method name. 238sub method_for_element { 239 my ($self, $element) = @_; 240 $element =~ tr/-/_/; 241 $element =~ tr/A-Z/a-z/; 242 $element =~ tr/_a-z0-9//cd; 243 return $element; 244} 245 246# Handle the start of a new element. If cmd_element is defined, assume that 247# we need to collect the entire tree for this element before passing it to the 248# element method, and create a new tree into which we'll collect blocks of 249# text and nested elements. Otherwise, if start_element is defined, call it. 250sub _handle_element_start { 251 my ($self, $element, $attrs) = @_; 252 DEBUG > 3 and print "++ $element (<", join ('> <', %$attrs), ">)\n"; 253 my $method = $self->method_for_element ($element); 254 255 # If we have a command handler, we need to accumulate the contents of the 256 # tag before calling it. Turn off IN_NAME for any command other than 257 # <Para> and the formatting codes so that IN_NAME isn't still set for the 258 # first heading after the NAME heading. 259 if ($self->can ("cmd_$method")) { 260 DEBUG > 2 and print "<$element> starts saving a tag\n"; 261 $$self{IN_NAME} = 0 if ($element ne 'Para' && length ($element) > 1); 262 263 # How we're going to format embedded text blocks depends on the tag 264 # and also depends on our parent tags. Thankfully, inside tags that 265 # turn off guesswork and reformatting, nothing else can turn it back 266 # on, so this can be strictly inherited. 267 my $formatting = $$self{PENDING}[-1][1]; 268 $formatting = $self->formatting ($formatting, $element); 269 push (@{ $$self{PENDING} }, [ $attrs, $formatting, '' ]); 270 DEBUG > 4 and print "Pending: [", pretty ($$self{PENDING}), "]\n"; 271 } elsif ($self->can ("start_$method")) { 272 my $method = 'start_' . $method; 273 $self->$method ($attrs, ''); 274 } else { 275 DEBUG > 2 and print "No $method start method, skipping\n"; 276 } 277} 278 279# Handle the end of an element. If we had a cmd_ method for this element, 280# this is where we pass along the tree that we built. Otherwise, if we have 281# an end_ method for the element, call that. 282sub _handle_element_end { 283 my ($self, $element) = @_; 284 DEBUG > 3 and print "-- $element\n"; 285 my $method = $self->method_for_element ($element); 286 287 # If we have a command handler, pull off the pending text and pass it to 288 # the handler along with the saved attribute hash. 289 if ($self->can ("cmd_$method")) { 290 DEBUG > 2 and print "</$element> stops saving a tag\n"; 291 my $tag = pop @{ $$self{PENDING} }; 292 DEBUG > 4 and print "Popped: [", pretty ($tag), "]\n"; 293 DEBUG > 4 and print "Pending: [", pretty ($$self{PENDING}), "]\n"; 294 my $method = 'cmd_' . $method; 295 my $text = $self->$method ($$tag[0], $$tag[2]); 296 if (defined $text) { 297 if (@{ $$self{PENDING} } > 1) { 298 $$self{PENDING}[-1][2] .= $text; 299 } else { 300 $self->output ($text); 301 } 302 } 303 } elsif ($self->can ("end_$method")) { 304 my $method = 'end_' . $method; 305 $self->$method (); 306 } else { 307 DEBUG > 2 and print "No $method end method, skipping\n"; 308 } 309} 310 311############################################################################## 312# General formatting 313############################################################################## 314 315# Return formatting instructions for a new block. Takes the current 316# formatting and the new element. Formatting inherits negatively, in the 317# sense that if the parent has turned off guesswork, all child elements should 318# leave it off. We therefore return a copy of the same formatting 319# instructions but possibly with more things turned off depending on the 320# element. 321sub formatting { 322 my ($self, $current, $element) = @_; 323 my %options; 324 if ($current) { 325 %options = %$current; 326 } else { 327 %options = (guesswork => 1, cleanup => 1, convert => 1); 328 } 329 if ($element eq 'Data') { 330 $options{guesswork} = 0; 331 $options{cleanup} = 0; 332 $options{convert} = 0; 333 } elsif ($element eq 'X') { 334 $options{guesswork} = 0; 335 $options{cleanup} = 0; 336 } elsif ($element eq 'Verbatim' || $element eq 'C') { 337 $options{guesswork} = 0; 338 $options{literal} = 1; 339 } 340 return \%options; 341} 342 343# Format a text block. Takes a hash of formatting options and the text to 344# format. Currently, the only formatting options are guesswork, cleanup, and 345# convert, all of which are boolean. 346sub format_text { 347 my ($self, $options, $text) = @_; 348 my $guesswork = $$options{guesswork} && !$$self{IN_NAME}; 349 my $cleanup = $$options{cleanup}; 350 my $convert = $$options{convert}; 351 my $literal = $$options{literal}; 352 353 # Cleanup just tidies up a few things, telling *roff that the hyphens are 354 # hard, putting a bit of space between consecutive underscores, and 355 # escaping backslashes. Be careful not to mangle our character 356 # translations by doing this before processing character translation. 357 if ($cleanup) { 358 $text =~ s/\\/\\e/g; 359 $text =~ s/-/\\-/g; 360 $text =~ s/_(?=_)/_\\|/g; 361 } 362 363 # Normally we do character translation, but we won't even do that in 364 # <Data> blocks or if UTF-8 output is desired. 365 if ($convert && !$$self{utf8} && ASCII) { 366 $text =~ s/([^\x00-\x7F])/$ESCAPES{ord ($1)} || "X"/eg; 367 } 368 369 # Ensure that *roff doesn't convert literal quotes to UTF-8 single quotes, 370 # but don't mess up our accept escapes. 371 if ($literal) { 372 $text =~ s/(?<!\\\*)\'/\\*\(Aq/g; 373 $text =~ s/(?<!\\\*)\`/\\\`/g; 374 } 375 376 # If guesswork is asked for, do that. This involves more substantial 377 # formatting based on various heuristics that may only be appropriate for 378 # particular documents. 379 if ($guesswork) { 380 $text = $self->guesswork ($text); 381 } 382 383 return $text; 384} 385 386# Handles C<> text, deciding whether to put \*C` around it or not. This is a 387# whole bunch of messy heuristics to try to avoid overquoting, originally from 388# Barrie Slaymaker. This largely duplicates similar code in Pod::Text. 389sub quote_literal { 390 my $self = shift; 391 local $_ = shift; 392 393 # A regex that matches the portion of a variable reference that's the 394 # array or hash index, separated out just because we want to use it in 395 # several places in the following regex. 396 my $index = '(?: \[.*\] | \{.*\} )?'; 397 398 # If in NAME section, just return an ASCII quoted string to avoid 399 # confusing tools like whatis. 400 return qq{"$_"} if $$self{IN_NAME}; 401 402 # Check for things that we don't want to quote, and if we find any of 403 # them, return the string with just a font change and no quoting. 404 m{ 405 ^\s* 406 (?: 407 ( [\'\`\"] ) .* \1 # already quoted 408 | \\\*\(Aq .* \\\*\(Aq # quoted and escaped 409 | \\?\` .* ( \' | \\\*\(Aq ) # `quoted' 410 | \$+ [\#^]? \S $index # special ($^Foo, $") 411 | [\$\@%&*]+ \#? [:\'\w]+ $index # plain var or func 412 | [\$\@%&*]* [:\'\w]+ (?: -> )? \(\s*[^\s,]\s*\) # 0/1-arg func call 413 | [-+]? ( \d[\d.]* | \.\d+ ) (?: [eE][-+]?\d+ )? # a number 414 | 0x [a-fA-F\d]+ # a hex constant 415 ) 416 \s*\z 417 }xso and return '\f(FS' . $_ . '\f(FE'; 418 419 # If we didn't return, go ahead and quote the text. 420 return '\f(FS\*(C`' . $_ . "\\*(C'\\f(FE"; 421} 422 423# Takes a text block to perform guesswork on. Returns the text block with 424# formatting codes added. This is the code that marks up various Perl 425# constructs and things commonly used in man pages without requiring the user 426# to add any explicit markup, and is applied to all non-literal text. We're 427# guaranteed that the text we're applying guesswork to does not contain any 428# *roff formatting codes. Note that the inserted font sequences must be 429# treated later with mapfonts or textmapfonts. 430# 431# This method is very fragile, both in the regular expressions it uses and in 432# the ordering of those modifications. Care and testing is required when 433# modifying it. 434sub guesswork { 435 my $self = shift; 436 local $_ = shift; 437 DEBUG > 5 and print " Guesswork called on [$_]\n"; 438 439 # By the time we reach this point, all hypens will be escaped by adding a 440 # backslash. We want to undo that escaping if they're part of regular 441 # words and there's only a single dash, since that's a real hyphen that 442 # *roff gets to consider a possible break point. Make sure that a dash 443 # after the first character of a word stays non-breaking, however. 444 # 445 # Note that this is not user-controllable; we pretty much have to do this 446 # transformation or *roff will mangle the output in unacceptable ways. 447 s{ 448 ( (?:\G|^|\s) [\(\"]* [a-zA-Z] ) ( \\- )? 449 ( (?: [a-zA-Z\']+ \\-)+ ) 450 ( [a-zA-Z\']+ ) (?= [\)\".?!,;:]* (?:\s|\Z|\\\ ) ) 451 \b 452 } { 453 my ($prefix, $hyphen, $main, $suffix) = ($1, $2, $3, $4); 454 $hyphen ||= ''; 455 $main =~ s/\\-/-/g; 456 $prefix . $hyphen . $main . $suffix; 457 }egx; 458 459 # Translate "--" into a real em-dash if it's used like one. This means 460 # that it's either surrounded by whitespace, it follows a regular word, or 461 # it occurs between two regular words. 462 if ($$self{MAGIC_EMDASH}) { 463 s{ (\s) \\-\\- (\s) } { $1 . '\*(--' . $2 }egx; 464 s{ (\b[a-zA-Z]+) \\-\\- (\s|\Z|[a-zA-Z]+\b) } { $1 . '\*(--' . $2 }egx; 465 } 466 467 # Make words in all-caps a little bit smaller; they look better that way. 468 # However, we don't want to change Perl code (like @ARGV), nor do we want 469 # to fix the MIME in MIME-Version since it looks weird with the 470 # full-height V. 471 # 472 # We change only a string of all caps (2) either at the beginning of the 473 # line or following regular punctuation (like quotes) or whitespace (1), 474 # and followed by either similar punctuation, an em-dash, or the end of 475 # the line (3). 476 if ($$self{MAGIC_SMALLCAPS}) { 477 s{ 478 ( ^ | [\s\(\"\'\`\[\{<>] | \\\ ) # (1) 479 ( [A-Z] [A-Z] (?: [/A-Z+:\d_\$&] | \\- )* ) # (2) 480 (?= [\s>\}\]\(\)\'\".?!,;] | \\*\(-- | \\\ | $ ) # (3) 481 } { 482 $1 . '\s-1' . $2 . '\s0' 483 }egx; 484 } 485 486 # Note that from this point forward, we have to adjust for \s-1 and \s-0 487 # strings inserted around things that we've made small-caps if later 488 # transforms should work on those strings. 489 490 # Italize functions in the form func(), including functions that are in 491 # all capitals, but don't italize if there's anything between the parens. 492 # The function must start with an alphabetic character or underscore and 493 # then consist of word characters or colons. 494 if ($$self{MAGIC_FUNC}) { 495 s{ 496 ( \b | \\s-1 ) 497 ( [A-Za-z_] ([:\w] | \\s-?[01])+ \(\) ) 498 } { 499 $1 . '\f(IS' . $2 . '\f(IE' 500 }egx; 501 } 502 503 # Change references to manual pages to put the page name in italics but 504 # the number in the regular font, with a thin space between the name and 505 # the number. Only recognize func(n) where func starts with an alphabetic 506 # character or underscore and contains only word characters, periods (for 507 # configuration file man pages), or colons, and n is a single digit, 508 # optionally followed by some number of lowercase letters. Note that this 509 # does not recognize man page references like perl(l) or socket(3SOCKET). 510 if ($$self{MAGIC_MANREF}) { 511 s{ 512 ( \b | \\s-1 ) 513 ( [A-Za-z_] (?:[.:\w] | \\- | \\s-?[01])+ ) 514 ( \( \d [a-z]* \) ) 515 } { 516 $1 . '\f(IS' . $2 . '\f(IE\|' . $3 517 }egx; 518 } 519 520 # Convert simple Perl variable references to a fixed-width font. Be 521 # careful not to convert functions, though; there are too many subtleties 522 # with them to want to perform this transformation. 523 if ($$self{MAGIC_VARS}) { 524 s{ 525 ( ^ | \s+ ) 526 ( [\$\@%] [\w:]+ ) 527 (?! \( ) 528 } { 529 $1 . '\f(FS' . $2 . '\f(FE' 530 }egx; 531 } 532 533 # Fix up double quotes. Unfortunately, we miss this transformation if the 534 # quoted text contains any code with formatting codes and there's not much 535 # we can effectively do about that, which makes it somewhat unclear if 536 # this is really a good idea. 537 s{ \" ([^\"]+) \" } { '\*(L"' . $1 . '\*(R"' }egx; 538 539 # Make C++ into \*(C+, which is a squinched version. 540 if ($$self{MAGIC_CPP}) { 541 s{ \b C\+\+ } {\\*\(C+}gx; 542 } 543 544 # Done. 545 DEBUG > 5 and print " Guesswork returning [$_]\n"; 546 return $_; 547} 548 549############################################################################## 550# Output 551############################################################################## 552 553# When building up the *roff code, we don't use real *roff fonts. Instead, we 554# embed font codes of the form \f(<font>[SE] where <font> is one of B, I, or 555# F, S stands for start, and E stands for end. This method turns these into 556# the right start and end codes. 557# 558# We add this level of complexity because the old pod2man didn't get code like 559# B<someI<thing> else> right; after I<> it switched back to normal text rather 560# than bold. We take care of this by using variables that state whether bold, 561# italic, or fixed are turned on as a combined pointer to our current font 562# sequence, and set each to the number of current nestings of start tags for 563# that font. 564# 565# \fP changes to the previous font, but only one previous font is kept. We 566# don't know what the outside level font is; normally it's R, but if we're 567# inside a heading it could be something else. So arrange things so that the 568# outside font is always the "previous" font and end with \fP instead of \fR. 569# Idea from Zack Weinberg. 570sub mapfonts { 571 my ($self, $text) = @_; 572 my ($fixed, $bold, $italic) = (0, 0, 0); 573 my %magic = (F => \$fixed, B => \$bold, I => \$italic); 574 my $last = '\fR'; 575 $text =~ s< 576 \\f\((.)(.) 577 > < 578 my $sequence = ''; 579 my $f; 580 if ($last ne '\fR') { $sequence = '\fP' } 581 ${ $magic{$1} } += ($2 eq 'S') ? 1 : -1; 582 $f = $$self{FONTS}{ ($fixed && 1) . ($bold && 1) . ($italic && 1) }; 583 if ($f eq $last) { 584 ''; 585 } else { 586 if ($f ne '\fR') { $sequence .= $f } 587 $last = $f; 588 $sequence; 589 } 590 >gxe; 591 return $text; 592} 593 594# Unfortunately, there is a bug in Solaris 2.6 nroff (not present in GNU 595# groff) where the sequence \fB\fP\f(CW\fP leaves the font set to B rather 596# than R, presumably because \f(CW doesn't actually do a font change. To work 597# around this, use a separate textmapfonts for text blocks where the default 598# font is always R and only use the smart mapfonts for headings. 599sub textmapfonts { 600 my ($self, $text) = @_; 601 my ($fixed, $bold, $italic) = (0, 0, 0); 602 my %magic = (F => \$fixed, B => \$bold, I => \$italic); 603 $text =~ s< 604 \\f\((.)(.) 605 > < 606 ${ $magic{$1} } += ($2 eq 'S') ? 1 : -1; 607 $$self{FONTS}{ ($fixed && 1) . ($bold && 1) . ($italic && 1) }; 608 >gxe; 609 return $text; 610} 611 612# Given a command and a single argument that may or may not contain double 613# quotes, handle double-quote formatting for it. If there are no double 614# quotes, just return the command followed by the argument in double quotes. 615# If there are double quotes, use an if statement to test for nroff, and for 616# nroff output the command followed by the argument in double quotes with 617# embedded double quotes doubled. For other formatters, remap paired double 618# quotes to LQUOTE and RQUOTE. 619sub switchquotes { 620 my ($self, $command, $text, $extra) = @_; 621 $text =~ s/\\\*\([LR]\"/\"/g; 622 623 # We also have to deal with \*C` and \*C', which are used to add the 624 # quotes around C<> text, since they may expand to " and if they do this 625 # confuses the .SH macros and the like no end. Expand them ourselves. 626 # Also separate troff from nroff if there are any fixed-width fonts in use 627 # to work around problems with Solaris nroff. 628 my $c_is_quote = ($$self{LQUOTE} =~ /\"/) || ($$self{RQUOTE} =~ /\"/); 629 my $fixedpat = join '|', @{ $$self{FONTS} }{'100', '101', '110', '111'}; 630 $fixedpat =~ s/\\/\\\\/g; 631 $fixedpat =~ s/\(/\\\(/g; 632 if ($text =~ m/\"/ || $text =~ m/$fixedpat/) { 633 $text =~ s/\"/\"\"/g; 634 my $nroff = $text; 635 my $troff = $text; 636 $troff =~ s/\"\"([^\"]*)\"\"/\`\`$1\'\'/g; 637 if ($c_is_quote and $text =~ m/\\\*\(C[\'\`]/) { 638 $nroff =~ s/\\\*\(C\`/$$self{LQUOTE}/g; 639 $nroff =~ s/\\\*\(C\'/$$self{RQUOTE}/g; 640 $troff =~ s/\\\*\(C[\'\`]//g; 641 } 642 $nroff = qq("$nroff") . ($extra ? " $extra" : ''); 643 $troff = qq("$troff") . ($extra ? " $extra" : ''); 644 645 # Work around the Solaris nroff bug where \f(CW\fP leaves the font set 646 # to Roman rather than the actual previous font when used in headings. 647 # troff output may still be broken, but at least we can fix nroff by 648 # just switching the font changes to the non-fixed versions. 649 $nroff =~ s/\Q$$self{FONTS}{100}\E(.*?)\\f[PR]/$1/g; 650 $nroff =~ s/\Q$$self{FONTS}{101}\E(.*?)\\f([PR])/\\fI$1\\f$2/g; 651 $nroff =~ s/\Q$$self{FONTS}{110}\E(.*?)\\f([PR])/\\fB$1\\f$2/g; 652 $nroff =~ s/\Q$$self{FONTS}{111}\E(.*?)\\f([PR])/\\f\(BI$1\\f$2/g; 653 654 # Now finally output the command. Bother with .ie only if the nroff 655 # and troff output aren't the same. 656 if ($nroff ne $troff) { 657 return ".ie n $command $nroff\n.el $command $troff\n"; 658 } else { 659 return "$command $nroff\n"; 660 } 661 } else { 662 $text = qq("$text") . ($extra ? " $extra" : ''); 663 return "$command $text\n"; 664 } 665} 666 667# Protect leading quotes and periods against interpretation as commands. Also 668# protect anything starting with a backslash, since it could expand or hide 669# something that *roff would interpret as a command. This is overkill, but 670# it's much simpler than trying to parse *roff here. 671sub protect { 672 my ($self, $text) = @_; 673 $text =~ s/^([.\'\\])/\\&$1/mg; 674 return $text; 675} 676 677# Make vertical whitespace if NEEDSPACE is set, appropriate to the indentation 678# level the situation. This function is needed since in *roff one has to 679# create vertical whitespace after paragraphs and between some things, but 680# other macros create their own whitespace. Also close out a sequence of 681# repeated =items, since calling makespace means we're about to begin the item 682# body. 683sub makespace { 684 my ($self) = @_; 685 $self->output (".PD\n") if $$self{ITEMS} > 1; 686 $$self{ITEMS} = 0; 687 $self->output ($$self{INDENT} > 0 ? ".Sp\n" : ".PP\n") 688 if $$self{NEEDSPACE}; 689} 690 691# Output any pending index entries, and optionally an index entry given as an 692# argument. Support multiple index entries in X<> separated by slashes, and 693# strip special escapes from index entries. 694sub outindex { 695 my ($self, $section, $index) = @_; 696 my @entries = map { split m%\s*/\s*% } @{ $$self{INDEX} }; 697 return unless ($section || @entries); 698 699 # We're about to output all pending entries, so clear our pending queue. 700 $$self{INDEX} = []; 701 702 # Build the output. Regular index entries are marked Xref, and headings 703 # pass in their own section. Undo some *roff formatting on headings. 704 my @output; 705 if (@entries) { 706 push @output, [ 'Xref', join (' ', @entries) ]; 707 } 708 if ($section) { 709 $index =~ s/\\-/-/g; 710 $index =~ s/\\(?:s-?\d|.\(..|.)//g; 711 push @output, [ $section, $index ]; 712 } 713 714 # Print out the .IX commands. 715 for (@output) { 716 my ($type, $entry) = @$_; 717 $entry =~ s/\"/\"\"/g; 718 $entry =~ s/\\/\\\\/g; 719 $self->output (".IX $type " . '"' . $entry . '"' . "\n"); 720 } 721} 722 723# Output some text, without any additional changes. 724sub output { 725 my ($self, @text) = @_; 726 print { $$self{output_fh} } @text; 727} 728 729############################################################################## 730# Document initialization 731############################################################################## 732 733# Handle the start of the document. Here we handle empty documents, as well 734# as setting up our basic macros in a preamble and building the page title. 735sub start_document { 736 my ($self, $attrs) = @_; 737 if ($$attrs{contentless} && !$$self{ALWAYS_EMIT_SOMETHING}) { 738 DEBUG and print "Document is contentless\n"; 739 $$self{CONTENTLESS} = 1; 740 return; 741 } 742 743 # If we were given the utf8 option, set an output encoding on our file 744 # handle. Wrap in an eval in case we're using a version of Perl too old 745 # to understand this. 746 # 747 # This is evil because it changes the global state of a file handle that 748 # we may not own. However, we can't just blindly encode all output, since 749 # there may be a pre-applied output encoding (such as from PERL_UNICODE) 750 # and then we would double-encode. This seems to be the least bad 751 # approach. 752 if ($$self{utf8}) { 753 eval { binmode ($$self{output_fh}, ':encoding(UTF-8)') }; 754 } 755 756 # Determine information for the preamble and then output it. 757 my ($name, $section); 758 if (defined $$self{name}) { 759 $name = $$self{name}; 760 $section = $$self{section} || 1; 761 } else { 762 ($name, $section) = $self->devise_title; 763 } 764 my $date = $$self{date} || $self->devise_date; 765 $self->preamble ($name, $section, $date) 766 unless $self->bare_output or DEBUG > 9; 767 768 # Initialize a few per-document variables. 769 $$self{INDENT} = 0; # Current indentation level. 770 $$self{INDENTS} = []; # Stack of indentations. 771 $$self{INDEX} = []; # Index keys waiting to be printed. 772 $$self{IN_NAME} = 0; # Whether processing the NAME section. 773 $$self{ITEMS} = 0; # The number of consecutive =items. 774 $$self{ITEMTYPES} = []; # Stack of =item types, one per list. 775 $$self{SHIFTWAIT} = 0; # Whether there is a shift waiting. 776 $$self{SHIFTS} = []; # Stack of .RS shifts. 777 $$self{PENDING} = [[]]; # Pending output. 778} 779 780# Handle the end of the document. This does nothing but print out a final 781# comment at the end of the document under debugging. 782sub end_document { 783 my ($self) = @_; 784 return if $self->bare_output; 785 return if ($$self{CONTENTLESS} && !$$self{ALWAYS_EMIT_SOMETHING}); 786 $self->output (q(.\" [End document]) . "\n") if DEBUG; 787} 788 789# Try to figure out the name and section from the file name and return them as 790# a list, returning an empty name and section 1 if we can't find any better 791# information. Uses File::Basename and File::Spec as necessary. 792sub devise_title { 793 my ($self) = @_; 794 my $name = $self->source_filename || ''; 795 my $section = $$self{section} || 1; 796 $section = 3 if (!$$self{section} && $name =~ /\.pm\z/i); 797 $name =~ s/\.p(od|[lm])\z//i; 798 799 # If the section isn't 3, then the name defaults to just the basename of 800 # the file. Otherwise, assume we're dealing with a module. We want to 801 # figure out the full module name from the path to the file, but we don't 802 # want to include too much of the path into the module name. Lose 803 # anything up to the first off: 804 # 805 # */lib/*perl*/ standard or site_perl module 806 # */*perl*/lib/ from -Dprefix=/opt/perl 807 # */*perl*/ random module hierarchy 808 # 809 # which works. Also strip off a leading site, site_perl, or vendor_perl 810 # component, any OS-specific component, and any version number component, 811 # and strip off an initial component of "lib" or "blib/lib" since that's 812 # what ExtUtils::MakeMaker creates. splitdir requires at least File::Spec 813 # 0.8. 814 if ($section !~ /^3/) { 815 require File::Basename; 816 $name = uc File::Basename::basename ($name); 817 } else { 818 require File::Spec; 819 my ($volume, $dirs, $file) = File::Spec->splitpath ($name); 820 my @dirs = File::Spec->splitdir ($dirs); 821 my $cut = 0; 822 my $i; 823 for ($i = 0; $i < @dirs; $i++) { 824 if ($dirs[$i] =~ /perl/) { 825 $cut = $i + 1; 826 $cut++ if ($dirs[$i + 1] && $dirs[$i + 1] eq 'lib'); 827 last; 828 } elsif ($dirs[$i] eq 'lib' && $dirs[$i + 1] && $dirs[0] eq 'ext') { 829 $cut = $i + 1; 830 } 831 } 832 if ($cut > 0) { 833 splice (@dirs, 0, $cut); 834 shift @dirs if ($dirs[0] =~ /^(site|vendor)(_perl)?$/); 835 shift @dirs if ($dirs[0] =~ /^[\d.]+$/); 836 shift @dirs if ($dirs[0] =~ /^(.*-$^O|$^O-.*|$^O)$/); 837 } 838 shift @dirs if $dirs[0] eq 'lib'; 839 splice (@dirs, 0, 2) if ($dirs[0] eq 'blib' && $dirs[1] eq 'lib'); 840 841 # Remove empty directories when building the module name; they 842 # occur too easily on Unix by doubling slashes. 843 $name = join ('::', (grep { $_ ? $_ : () } @dirs), $file); 844 } 845 return ($name, $section); 846} 847 848# Determine the modification date and return that, properly formatted in ISO 849# format. If we can't get the modification date of the input, instead use the 850# current time. Pod::Simple returns a completely unuseful stringified file 851# handle as the source_filename for input from a file handle, so we have to 852# deal with that as well. 853sub devise_date { 854 my ($self) = @_; 855 my $input = $self->source_filename; 856 my $time; 857 if ($input) { 858 $time = (stat $input)[9] || time; 859 } else { 860 $time = time; 861 } 862 863 # Can't use POSIX::strftime(), which uses Fcntl, because MakeMaker 864 # uses this and it has to work in the core which can't load dynamic 865 # libraries. 866 my ($year, $month, $day) = (localtime $time)[5,4,3]; 867 return sprintf ("%04d-%02d-%02d", $year + 1900, $month + 1, $day); 868} 869 870# Print out the preamble and the title. The meaning of the arguments to .TH 871# unfortunately vary by system; some systems consider the fourth argument to 872# be a "source" and others use it as a version number. Generally it's just 873# presented as the left-side footer, though, so it doesn't matter too much if 874# a particular system gives it another interpretation. 875# 876# The order of date and release used to be reversed in older versions of this 877# module, but this order is correct for both Solaris and Linux. 878sub preamble { 879 my ($self, $name, $section, $date) = @_; 880 my $preamble = $self->preamble_template (!$$self{utf8}); 881 882 # Build the index line and make sure that it will be syntactically valid. 883 my $index = "$name $section"; 884 $index =~ s/\"/\"\"/g; 885 886 # If name or section contain spaces, quote them (section really never 887 # should, but we may as well be cautious). 888 for ($name, $section) { 889 if (/\s/) { 890 s/\"/\"\"/g; 891 $_ = '"' . $_ . '"'; 892 } 893 } 894 895 # Double quotes in date, since it will be quoted. 896 $date =~ s/\"/\"\"/g; 897 898 # Substitute into the preamble the configuration options. 899 $preamble =~ s/\@CFONT\@/$$self{fixed}/; 900 $preamble =~ s/\@LQUOTE\@/$$self{LQUOTE}/; 901 $preamble =~ s/\@RQUOTE\@/$$self{RQUOTE}/; 902 chomp $preamble; 903 904 # Get the version information. 905 my $version = $self->version_report; 906 907 # Finally output everything. 908 $self->output (<<"----END OF HEADER----"); 909.\\" Automatically generated by $version 910.\\" 911.\\" Standard preamble: 912.\\" ======================================================================== 913$preamble 914.\\" ======================================================================== 915.\\" 916.IX Title "$index" 917.TH $name $section "$date" "$$self{release}" "$$self{center}" 918.\\" For nroff, turn off justification. Always turn off hyphenation; it makes 919.\\" way too many mistakes in technical documents. 920.if n .ad l 921.nh 922----END OF HEADER---- 923 $self->output (".\\\" [End of preamble]\n") if DEBUG; 924} 925 926############################################################################## 927# Text blocks 928############################################################################## 929 930# Handle a basic block of text. The only tricky part of this is if this is 931# the first paragraph of text after an =over, in which case we have to change 932# indentations for *roff. 933sub cmd_para { 934 my ($self, $attrs, $text) = @_; 935 my $line = $$attrs{start_line}; 936 937 # Output the paragraph. We also have to handle =over without =item. If 938 # there's an =over without =item, SHIFTWAIT will be set, and we need to 939 # handle creation of the indent here. Add the shift to SHIFTS so that it 940 # will be cleaned up on =back. 941 $self->makespace; 942 if ($$self{SHIFTWAIT}) { 943 $self->output (".RS $$self{INDENT}\n"); 944 push (@{ $$self{SHIFTS} }, $$self{INDENT}); 945 $$self{SHIFTWAIT} = 0; 946 } 947 948 # Add the line number for debugging, but not in the NAME section just in 949 # case the comment would confuse apropos. 950 $self->output (".\\\" [At source line $line]\n") 951 if defined ($line) && DEBUG && !$$self{IN_NAME}; 952 953 # Force exactly one newline at the end and strip unwanted trailing 954 # whitespace at the end. 955 $text =~ s/\s*$/\n/; 956 957 # Output the paragraph. 958 $self->output ($self->protect ($self->textmapfonts ($text))); 959 $self->outindex; 960 $$self{NEEDSPACE} = 1; 961 return ''; 962} 963 964# Handle a verbatim paragraph. Put a null token at the beginning of each line 965# to protect against commands and wrap in .Vb/.Ve (which we define in our 966# prelude). 967sub cmd_verbatim { 968 my ($self, $attrs, $text) = @_; 969 970 # Ignore an empty verbatim paragraph. 971 return unless $text =~ /\S/; 972 973 # Force exactly one newline at the end and strip unwanted trailing 974 # whitespace at the end. 975 $text =~ s/\s*$/\n/; 976 977 # Get a count of the number of lines before the first blank line, which 978 # we'll pass to .Vb as its parameter. This tells *roff to keep that many 979 # lines together. We don't want to tell *roff to keep huge blocks 980 # together. 981 my @lines = split (/\n/, $text); 982 my $unbroken = 0; 983 for (@lines) { 984 last if /^\s*$/; 985 $unbroken++; 986 } 987 $unbroken = 10 if ($unbroken > 12 && !$$self{MAGIC_VNOPAGEBREAK_LIMIT}); 988 989 # Prepend a null token to each line. 990 $text =~ s/^/\\&/gm; 991 992 # Output the results. 993 $self->makespace; 994 $self->output (".Vb $unbroken\n$text.Ve\n"); 995 $$self{NEEDSPACE} = 1; 996 return ''; 997} 998 999# Handle literal text (produced by =for and similar constructs). Just output 1000# it with the minimum of changes. 1001sub cmd_data { 1002 my ($self, $attrs, $text) = @_; 1003 $text =~ s/^\n+//; 1004 $text =~ s/\n{0,2}$/\n/; 1005 $self->output ($text); 1006 return ''; 1007} 1008 1009############################################################################## 1010# Headings 1011############################################################################## 1012 1013# Common code for all headings. This is called before the actual heading is 1014# output. It returns the cleaned up heading text (putting the heading all on 1015# one line) and may do other things, like closing bad =item blocks. 1016sub heading_common { 1017 my ($self, $text, $line) = @_; 1018 $text =~ s/\s+$//; 1019 $text =~ s/\s*\n\s*/ /g; 1020 1021 # This should never happen; it means that we have a heading after =item 1022 # without an intervening =back. But just in case, handle it anyway. 1023 if ($$self{ITEMS} > 1) { 1024 $$self{ITEMS} = 0; 1025 $self->output (".PD\n"); 1026 } 1027 1028 # Output the current source line. 1029 $self->output ( ".\\\" [At source line $line]\n" ) 1030 if defined ($line) && DEBUG; 1031 return $text; 1032} 1033 1034# First level heading. We can't output .IX in the NAME section due to a bug 1035# in some versions of catman, so don't output a .IX for that section. .SH 1036# already uses small caps, so remove \s0 and \s-1. Maintain IN_NAME as 1037# appropriate. 1038sub cmd_head1 { 1039 my ($self, $attrs, $text) = @_; 1040 $text =~ s/\\s-?\d//g; 1041 $text = $self->heading_common ($text, $$attrs{start_line}); 1042 my $isname = ($text eq 'NAME' || $text =~ /\(NAME\)/); 1043 $self->output ($self->switchquotes ('.SH', $self->mapfonts ($text))); 1044 $self->outindex ('Header', $text) unless $isname; 1045 $$self{NEEDSPACE} = 0; 1046 $$self{IN_NAME} = $isname; 1047 return ''; 1048} 1049 1050# Second level heading. 1051sub cmd_head2 { 1052 my ($self, $attrs, $text) = @_; 1053 $text = $self->heading_common ($text, $$attrs{start_line}); 1054 $self->output ($self->switchquotes ('.SS', $self->mapfonts ($text))); 1055 $self->outindex ('Subsection', $text); 1056 $$self{NEEDSPACE} = 0; 1057 return ''; 1058} 1059 1060# Third level heading. *roff doesn't have this concept, so just put the 1061# heading in italics as a normal paragraph. 1062sub cmd_head3 { 1063 my ($self, $attrs, $text) = @_; 1064 $text = $self->heading_common ($text, $$attrs{start_line}); 1065 $self->makespace; 1066 $self->output ($self->textmapfonts ('\f(IS' . $text . '\f(IE') . "\n"); 1067 $self->outindex ('Subsection', $text); 1068 $$self{NEEDSPACE} = 1; 1069 return ''; 1070} 1071 1072# Fourth level heading. *roff doesn't have this concept, so just put the 1073# heading as a normal paragraph. 1074sub cmd_head4 { 1075 my ($self, $attrs, $text) = @_; 1076 $text = $self->heading_common ($text, $$attrs{start_line}); 1077 $self->makespace; 1078 $self->output ($self->textmapfonts ($text) . "\n"); 1079 $self->outindex ('Subsection', $text); 1080 $$self{NEEDSPACE} = 1; 1081 return ''; 1082} 1083 1084############################################################################## 1085# Formatting codes 1086############################################################################## 1087 1088# All of the formatting codes that aren't handled internally by the parser, 1089# other than L<> and X<>. 1090sub cmd_b { return $_[0]->{IN_NAME} ? $_[2] : '\f(BS' . $_[2] . '\f(BE' } 1091sub cmd_i { return $_[0]->{IN_NAME} ? $_[2] : '\f(IS' . $_[2] . '\f(IE' } 1092sub cmd_f { return $_[0]->{IN_NAME} ? $_[2] : '\f(IS' . $_[2] . '\f(IE' } 1093sub cmd_c { return $_[0]->quote_literal ($_[2]) } 1094 1095# Index entries are just added to the pending entries. 1096sub cmd_x { 1097 my ($self, $attrs, $text) = @_; 1098 push (@{ $$self{INDEX} }, $text); 1099 return ''; 1100} 1101 1102# Links reduce to the text that we're given, wrapped in angle brackets if it's 1103# a URL. 1104sub cmd_l { 1105 my ($self, $attrs, $text) = @_; 1106 if ($$attrs{type} eq 'url') { 1107 if (not defined($$attrs{to}) or $$attrs{to} eq $text) { 1108 return "<$text>"; 1109 } else { 1110 return "$text <$$attrs{to}>"; 1111 } 1112 } else { 1113 return $text; 1114 } 1115} 1116 1117############################################################################## 1118# List handling 1119############################################################################## 1120 1121# Handle the beginning of an =over block. Takes the type of the block as the 1122# first argument, and then the attr hash. This is called by the handlers for 1123# the four different types of lists (bullet, number, text, and block). 1124sub over_common_start { 1125 my ($self, $type, $attrs) = @_; 1126 my $line = $$attrs{start_line}; 1127 my $indent = $$attrs{indent}; 1128 DEBUG > 3 and print " Starting =over $type (line $line, indent ", 1129 ($indent || '?'), "\n"; 1130 1131 # Find the indentation level. 1132 unless (defined ($indent) && $indent =~ /^[-+]?\d{1,4}\s*$/) { 1133 $indent = $$self{indent}; 1134 } 1135 1136 # If we've gotten multiple indentations in a row, we need to emit the 1137 # pending indentation for the last level that we saw and haven't acted on 1138 # yet. SHIFTS is the stack of indentations that we've actually emitted 1139 # code for. 1140 if (@{ $$self{SHIFTS} } < @{ $$self{INDENTS} }) { 1141 $self->output (".RS $$self{INDENT}\n"); 1142 push (@{ $$self{SHIFTS} }, $$self{INDENT}); 1143 } 1144 1145 # Now, do record-keeping. INDENTS is a stack of indentations that we've 1146 # seen so far, and INDENT is the current level of indentation. ITEMTYPES 1147 # is a stack of list types that we've seen. 1148 push (@{ $$self{INDENTS} }, $$self{INDENT}); 1149 push (@{ $$self{ITEMTYPES} }, $type); 1150 $$self{INDENT} = $indent + 0; 1151 $$self{SHIFTWAIT} = 1; 1152} 1153 1154# End an =over block. Takes no options other than the class pointer. 1155# Normally, once we close a block and therefore remove something from INDENTS, 1156# INDENTS will now be longer than SHIFTS, indicating that we also need to emit 1157# *roff code to close the indent. This isn't *always* true, depending on the 1158# circumstance. If we're still inside an indentation, we need to emit another 1159# .RE and then a new .RS to unconfuse *roff. 1160sub over_common_end { 1161 my ($self) = @_; 1162 DEBUG > 3 and print " Ending =over\n"; 1163 $$self{INDENT} = pop @{ $$self{INDENTS} }; 1164 pop @{ $$self{ITEMTYPES} }; 1165 1166 # If we emitted code for that indentation, end it. 1167 if (@{ $$self{SHIFTS} } > @{ $$self{INDENTS} }) { 1168 $self->output (".RE\n"); 1169 pop @{ $$self{SHIFTS} }; 1170 } 1171 1172 # If we're still in an indentation, *roff will have now lost track of the 1173 # right depth of that indentation, so fix that. 1174 if (@{ $$self{INDENTS} } > 0) { 1175 $self->output (".RE\n"); 1176 $self->output (".RS $$self{INDENT}\n"); 1177 } 1178 $$self{NEEDSPACE} = 1; 1179 $$self{SHIFTWAIT} = 0; 1180} 1181 1182# Dispatch the start and end calls as appropriate. 1183sub start_over_bullet { my $s = shift; $s->over_common_start ('bullet', @_) } 1184sub start_over_number { my $s = shift; $s->over_common_start ('number', @_) } 1185sub start_over_text { my $s = shift; $s->over_common_start ('text', @_) } 1186sub start_over_block { my $s = shift; $s->over_common_start ('block', @_) } 1187sub end_over_bullet { $_[0]->over_common_end } 1188sub end_over_number { $_[0]->over_common_end } 1189sub end_over_text { $_[0]->over_common_end } 1190sub end_over_block { $_[0]->over_common_end } 1191 1192# The common handler for all item commands. Takes the type of the item, the 1193# attributes, and then the text of the item. 1194# 1195# Emit an index entry for anything that's interesting, but don't emit index 1196# entries for things like bullets and numbers. Newlines in an item title are 1197# turned into spaces since *roff can't handle them embedded. 1198sub item_common { 1199 my ($self, $type, $attrs, $text) = @_; 1200 my $line = $$attrs{start_line}; 1201 DEBUG > 3 and print " $type item (line $line): $text\n"; 1202 1203 # Clean up the text. We want to end up with two variables, one ($text) 1204 # which contains any body text after taking out the item portion, and 1205 # another ($item) which contains the actual item text. 1206 $text =~ s/\s+$//; 1207 my ($item, $index); 1208 if ($type eq 'bullet') { 1209 $item = "\\\(bu"; 1210 $text =~ s/\n*$/\n/; 1211 } elsif ($type eq 'number') { 1212 $item = $$attrs{number} . '.'; 1213 } else { 1214 $item = $text; 1215 $item =~ s/\s*\n\s*/ /g; 1216 $text = ''; 1217 $index = $item if ($item =~ /\w/); 1218 } 1219 1220 # Take care of the indentation. If shifts and indents are equal, close 1221 # the top shift, since we're about to create an indentation with .IP. 1222 # Also output .PD 0 to turn off spacing between items if this item is 1223 # directly following another one. We only have to do that once for a 1224 # whole chain of items so do it for the second item in the change. Note 1225 # that makespace is what undoes this. 1226 if (@{ $$self{SHIFTS} } == @{ $$self{INDENTS} }) { 1227 $self->output (".RE\n"); 1228 pop @{ $$self{SHIFTS} }; 1229 } 1230 $self->output (".PD 0\n") if ($$self{ITEMS} == 1); 1231 1232 # Now, output the item tag itself. 1233 $item = $self->textmapfonts ($item); 1234 $self->output ($self->switchquotes ('.IP', $item, $$self{INDENT})); 1235 $$self{NEEDSPACE} = 0; 1236 $$self{ITEMS}++; 1237 $$self{SHIFTWAIT} = 0; 1238 1239 # If body text for this item was included, go ahead and output that now. 1240 if ($text) { 1241 $text =~ s/\s*$/\n/; 1242 $self->makespace; 1243 $self->output ($self->protect ($self->textmapfonts ($text))); 1244 $$self{NEEDSPACE} = 1; 1245 } 1246 $self->outindex ($index ? ('Item', $index) : ()); 1247} 1248 1249# Dispatch the item commands to the appropriate place. 1250sub cmd_item_bullet { my $self = shift; $self->item_common ('bullet', @_) } 1251sub cmd_item_number { my $self = shift; $self->item_common ('number', @_) } 1252sub cmd_item_text { my $self = shift; $self->item_common ('text', @_) } 1253sub cmd_item_block { my $self = shift; $self->item_common ('block', @_) } 1254 1255############################################################################## 1256# Backward compatibility 1257############################################################################## 1258 1259# Reset the underlying Pod::Simple object between calls to parse_from_file so 1260# that the same object can be reused to convert multiple pages. 1261sub parse_from_file { 1262 my $self = shift; 1263 $self->reinit; 1264 1265 # Fake the old cutting option to Pod::Parser. This fiddings with internal 1266 # Pod::Simple state and is quite ugly; we need a better approach. 1267 if (ref ($_[0]) eq 'HASH') { 1268 my $opts = shift @_; 1269 if (defined ($$opts{-cutting}) && !$$opts{-cutting}) { 1270 $$self{in_pod} = 1; 1271 $$self{last_was_blank} = 1; 1272 } 1273 } 1274 1275 # Do the work. 1276 my $retval = $self->SUPER::parse_from_file (@_); 1277 1278 # Flush output, since Pod::Simple doesn't do this. Ideally we should also 1279 # close the file descriptor if we had to open one, but we can't easily 1280 # figure this out. 1281 my $fh = $self->output_fh (); 1282 my $oldfh = select $fh; 1283 my $oldflush = $|; 1284 $| = 1; 1285 print $fh ''; 1286 $| = $oldflush; 1287 select $oldfh; 1288 return $retval; 1289} 1290 1291# Pod::Simple failed to provide this backward compatibility function, so 1292# implement it ourselves. File handles are one of the inputs that 1293# parse_from_file supports. 1294sub parse_from_filehandle { 1295 my $self = shift; 1296 $self->parse_from_file (@_); 1297} 1298 1299############################################################################## 1300# Translation tables 1301############################################################################## 1302 1303# The following table is adapted from Tom Christiansen's pod2man. It assumes 1304# that the standard preamble has already been printed, since that's what 1305# defines all of the accent marks. We really want to do something better than 1306# this when *roff actually supports other character sets itself, since these 1307# results are pretty poor. 1308# 1309# This only works in an ASCII world. What to do in a non-ASCII world is very 1310# unclear -- hopefully we can assume UTF-8 and just leave well enough alone. 1311@ESCAPES{0xA0 .. 0xFF} = ( 1312 "\\ ", undef, undef, undef, undef, undef, undef, undef, 1313 undef, undef, undef, undef, undef, "\\%", undef, undef, 1314 1315 undef, undef, undef, undef, undef, undef, undef, undef, 1316 undef, undef, undef, undef, undef, undef, undef, undef, 1317 1318 "A\\*`", "A\\*'", "A\\*^", "A\\*~", "A\\*:", "A\\*o", "\\*(AE", "C\\*,", 1319 "E\\*`", "E\\*'", "E\\*^", "E\\*:", "I\\*`", "I\\*'", "I\\*^", "I\\*:", 1320 1321 "\\*(D-", "N\\*~", "O\\*`", "O\\*'", "O\\*^", "O\\*~", "O\\*:", undef, 1322 "O\\*/", "U\\*`", "U\\*'", "U\\*^", "U\\*:", "Y\\*'", "\\*(Th", "\\*8", 1323 1324 "a\\*`", "a\\*'", "a\\*^", "a\\*~", "a\\*:", "a\\*o", "\\*(ae", "c\\*,", 1325 "e\\*`", "e\\*'", "e\\*^", "e\\*:", "i\\*`", "i\\*'", "i\\*^", "i\\*:", 1326 1327 "\\*(d-", "n\\*~", "o\\*`", "o\\*'", "o\\*^", "o\\*~", "o\\*:", undef, 1328 "o\\*/" , "u\\*`", "u\\*'", "u\\*^", "u\\*:", "y\\*'", "\\*(th", "y\\*:", 1329) if ASCII; 1330 1331############################################################################## 1332# Premable 1333############################################################################## 1334 1335# The following is the static preamble which starts all *roff output we 1336# generate. Most is static except for the font to use as a fixed-width font, 1337# which is designed by @CFONT@, and the left and right quotes to use for C<> 1338# text, designated by @LQOUTE@ and @RQUOTE@. However, the second part, which 1339# defines the accent marks, is only used if $escapes is set to true. 1340sub preamble_template { 1341 my ($self, $accents) = @_; 1342 my $preamble = <<'----END OF PREAMBLE----'; 1343.de Sp \" Vertical space (when we can't use .PP) 1344.if t .sp .5v 1345.if n .sp 1346.. 1347.de Vb \" Begin verbatim text 1348.ft @CFONT@ 1349.nf 1350.ne \\$1 1351.. 1352.de Ve \" End verbatim text 1353.ft R 1354.fi 1355.. 1356.\" Set up some character translations and predefined strings. \*(-- will 1357.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left 1358.\" double quote, and \*(R" will give a right double quote. \*(C+ will 1359.\" give a nicer C++. Capital omega is used to do unbreakable dashes and 1360.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, 1361.\" nothing in troff, for use with C<>. 1362.tr \(*W- 1363.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' 1364.ie n \{\ 1365. ds -- \(*W- 1366. ds PI pi 1367. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch 1368. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch 1369. ds L" "" 1370. ds R" "" 1371. ds C` @LQUOTE@ 1372. ds C' @RQUOTE@ 1373'br\} 1374.el\{\ 1375. ds -- \|\(em\| 1376. ds PI \(*p 1377. ds L" `` 1378. ds R" '' 1379'br\} 1380.\" 1381.\" Escape single quotes in literal strings from groff's Unicode transform. 1382.ie \n(.g .ds Aq \(aq 1383.el .ds Aq ' 1384.\" 1385.\" If the F register is turned on, we'll generate index entries on stderr for 1386.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index 1387.\" entries marked with X<> in POD. Of course, you'll have to process the 1388.\" output yourself in some meaningful fashion. 1389.ie \nF \{\ 1390. de IX 1391. tm Index:\\$1\t\\n%\t"\\$2" 1392.. 1393. nr % 0 1394. rr F 1395.\} 1396.el \{\ 1397. de IX 1398.. 1399.\} 1400----END OF PREAMBLE---- 1401 1402 if ($accents) { 1403 $preamble .= <<'----END OF PREAMBLE----' 1404.\" 1405.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). 1406.\" Fear. Run. Save yourself. No user-serviceable parts. 1407. \" fudge factors for nroff and troff 1408.if n \{\ 1409. ds #H 0 1410. ds #V .8m 1411. ds #F .3m 1412. ds #[ \f1 1413. ds #] \fP 1414.\} 1415.if t \{\ 1416. ds #H ((1u-(\\\\n(.fu%2u))*.13m) 1417. ds #V .6m 1418. ds #F 0 1419. ds #[ \& 1420. ds #] \& 1421.\} 1422. \" simple accents for nroff and troff 1423.if n \{\ 1424. ds ' \& 1425. ds ` \& 1426. ds ^ \& 1427. ds , \& 1428. ds ~ ~ 1429. ds / 1430.\} 1431.if t \{\ 1432. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" 1433. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' 1434. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' 1435. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' 1436. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' 1437. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' 1438.\} 1439. \" troff and (daisy-wheel) nroff accents 1440.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' 1441.ds 8 \h'\*(#H'\(*b\h'-\*(#H' 1442.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] 1443.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' 1444.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' 1445.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] 1446.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] 1447.ds ae a\h'-(\w'a'u*4/10)'e 1448.ds Ae A\h'-(\w'A'u*4/10)'E 1449. \" corrections for vroff 1450.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' 1451.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' 1452. \" for low resolution devices (crt and lpr) 1453.if \n(.H>23 .if \n(.V>19 \ 1454\{\ 1455. ds : e 1456. ds 8 ss 1457. ds o a 1458. ds d- d\h'-1'\(ga 1459. ds D- D\h'-1'\(hy 1460. ds th \o'bp' 1461. ds Th \o'LP' 1462. ds ae ae 1463. ds Ae AE 1464.\} 1465.rm #[ #] #H #V #F C 1466----END OF PREAMBLE---- 1467#`# for cperl-mode 1468 } 1469 return $preamble; 1470} 1471 1472############################################################################## 1473# Module return value and documentation 1474############################################################################## 1475 14761; 1477__END__ 1478 1479=head1 NAME 1480 1481Pod::Man - Convert POD data to formatted *roff input 1482 1483=for stopwords 1484en em ALLCAPS teeny fixedbold fixeditalic fixedbolditalic stderr utf8 1485UTF-8 Allbery Sean Burke Ossanna Solaris formatters troff uppercased 1486Christiansen 1487 1488=head1 SYNOPSIS 1489 1490 use Pod::Man; 1491 my $parser = Pod::Man->new (release => $VERSION, section => 8); 1492 1493 # Read POD from STDIN and write to STDOUT. 1494 $parser->parse_file (\*STDIN); 1495 1496 # Read POD from file.pod and write to file.1. 1497 $parser->parse_from_file ('file.pod', 'file.1'); 1498 1499=head1 DESCRIPTION 1500 1501Pod::Man is a module to convert documentation in the POD format (the 1502preferred language for documenting Perl) into *roff input using the man 1503macro set. The resulting *roff code is suitable for display on a terminal 1504using L<nroff(1)>, normally via L<man(1)>, or printing using L<troff(1)>. 1505It is conventionally invoked using the driver script B<pod2man>, but it can 1506also be used directly. 1507 1508As a derived class from Pod::Simple, Pod::Man supports the same methods and 1509interfaces. See L<Pod::Simple> for all the details. 1510 1511new() can take options, in the form of key/value pairs that control the 1512behavior of the parser. See below for details. 1513 1514If no options are given, Pod::Man uses the name of the input file with any 1515trailing C<.pod>, C<.pm>, or C<.pl> stripped as the man page title, to 1516section 1 unless the file ended in C<.pm> in which case it defaults to 1517section 3, to a centered title of "User Contributed Perl Documentation", to 1518a centered footer of the Perl version it is run with, and to a left-hand 1519footer of the modification date of its input (or the current date if given 1520C<STDIN> for input). 1521 1522Pod::Man assumes that your *roff formatters have a fixed-width font named 1523C<CW>. If yours is called something else (like C<CR>), use the C<fixed> 1524option to specify it. This generally only matters for troff output for 1525printing. Similarly, you can set the fonts used for bold, italic, and 1526bold italic fixed-width output. 1527 1528Besides the obvious pod conversions, Pod::Man also takes care of 1529formatting func(), func(3), and simple variable references like $foo or 1530@bar so you don't have to use code escapes for them; complex expressions 1531like C<$fred{'stuff'}> will still need to be escaped, though. It also 1532translates dashes that aren't used as hyphens into en dashes, makes long 1533dashes--like this--into proper em dashes, fixes "paired quotes," makes C++ 1534look right, puts a little space between double underscores, makes ALLCAPS 1535a teeny bit smaller in B<troff>, and escapes stuff that *roff treats as 1536special so that you don't have to. 1537 1538The recognized options to new() are as follows. All options take a single 1539argument. 1540 1541=over 4 1542 1543=item center 1544 1545Sets the centered page header to use instead of "User Contributed Perl 1546Documentation". 1547 1548=item date 1549 1550Sets the left-hand footer. By default, the modification date of the input 1551file will be used, or the current date if stat() can't find that file (the 1552case if the input is from C<STDIN>), and the date will be formatted as 1553C<YYYY-MM-DD>. 1554 1555=item fixed 1556 1557The fixed-width font to use for verbatim text and code. Defaults to 1558C<CW>. Some systems may want C<CR> instead. Only matters for B<troff> 1559output. 1560 1561=item fixedbold 1562 1563Bold version of the fixed-width font. Defaults to C<CB>. Only matters 1564for B<troff> output. 1565 1566=item fixeditalic 1567 1568Italic version of the fixed-width font (actually, something of a misnomer, 1569since most fixed-width fonts only have an oblique version, not an italic 1570version). Defaults to C<CI>. Only matters for B<troff> output. 1571 1572=item fixedbolditalic 1573 1574Bold italic (probably actually oblique) version of the fixed-width font. 1575Pod::Man doesn't assume you have this, and defaults to C<CB>. Some 1576systems (such as Solaris) have this font available as C<CX>. Only matters 1577for B<troff> output. 1578 1579=item name 1580 1581Set the name of the manual page. Without this option, the manual name is 1582set to the uppercased base name of the file being converted unless the 1583manual section is 3, in which case the path is parsed to see if it is a Perl 1584module path. If it is, a path like C<.../lib/Pod/Man.pm> is converted into 1585a name like C<Pod::Man>. This option, if given, overrides any automatic 1586determination of the name. 1587 1588=item quotes 1589 1590Sets the quote marks used to surround CE<lt>> text. If the value is a 1591single character, it is used as both the left and right quote; if it is two 1592characters, the first character is used as the left quote and the second as 1593the right quoted; and if it is four characters, the first two are used as 1594the left quote and the second two as the right quote. 1595 1596This may also be set to the special value C<none>, in which case no quote 1597marks are added around CE<lt>> text (but the font is still changed for troff 1598output). 1599 1600=item release 1601 1602Set the centered footer. By default, this is the version of Perl you run 1603Pod::Man under. Note that some system an macro sets assume that the 1604centered footer will be a modification date and will prepend something like 1605"Last modified: "; if this is the case, you may want to set C<release> to 1606the last modified date and C<date> to the version number. 1607 1608=item section 1609 1610Set the section for the C<.TH> macro. The standard section numbering 1611convention is to use 1 for user commands, 2 for system calls, 3 for 1612functions, 4 for devices, 5 for file formats, 6 for games, 7 for 1613miscellaneous information, and 8 for administrator commands. There is a lot 1614of variation here, however; some systems (like Solaris) use 4 for file 1615formats, 5 for miscellaneous information, and 7 for devices. Still others 1616use 1m instead of 8, or some mix of both. About the only section numbers 1617that are reliably consistent are 1, 2, and 3. 1618 1619By default, section 1 will be used unless the file ends in C<.pm> in which 1620case section 3 will be selected. 1621 1622=item stderr 1623 1624Send error messages about invalid POD to standard error instead of 1625appending a POD ERRORS section to the generated *roff output. 1626 1627=item utf8 1628 1629By default, Pod::Man produces the most conservative possible *roff output 1630to try to ensure that it will work with as many different *roff 1631implementations as possible. Many *roff implementations cannot handle 1632non-ASCII characters, so this means all non-ASCII characters are converted 1633either to a *roff escape sequence that tries to create a properly accented 1634character (at least for troff output) or to C<X>. 1635 1636If this option is set, Pod::Man will instead output UTF-8. If your *roff 1637implementation can handle it, this is the best output format to use and 1638avoids corruption of documents containing non-ASCII characters. However, 1639be warned that *roff source with literal UTF-8 characters is not supported 1640by many implementations and may even result in segfaults and other bad 1641behavior. 1642 1643Be aware that, when using this option, the input encoding of your POD 1644source must be properly declared unless it is US-ASCII or Latin-1. POD 1645input without an C<=encoding> command will be assumed to be in Latin-1, 1646and if it's actually in UTF-8, the output will be double-encoded. See 1647L<perlpod(1)> for more information on the C<=encoding> command. 1648 1649=back 1650 1651The standard Pod::Simple method parse_file() takes one argument naming the 1652POD file to read from. By default, the output is sent to C<STDOUT>, but 1653this can be changed with the output_fd() method. 1654 1655The standard Pod::Simple method parse_from_file() takes up to two 1656arguments, the first being the input file to read POD from and the second 1657being the file to write the formatted output to. 1658 1659You can also call parse_lines() to parse an array of lines or 1660parse_string_document() to parse a document already in memory. To put the 1661output into a string instead of a file handle, call the output_string() 1662method. See L<Pod::Simple> for the specific details. 1663 1664=head1 DIAGNOSTICS 1665 1666=over 4 1667 1668=item roff font should be 1 or 2 chars, not "%s" 1669 1670(F) You specified a *roff font (using C<fixed>, C<fixedbold>, etc.) that 1671wasn't either one or two characters. Pod::Man doesn't support *roff fonts 1672longer than two characters, although some *roff extensions do (the canonical 1673versions of B<nroff> and B<troff> don't either). 1674 1675=item Invalid quote specification "%s" 1676 1677(F) The quote specification given (the quotes option to the constructor) was 1678invalid. A quote specification must be one, two, or four characters long. 1679 1680=back 1681 1682=head1 BUGS 1683 1684Encoding handling assumes that PerlIO is available and does not work 1685properly if it isn't. The C<utf8> option is therefore not supported 1686unless Perl is built with PerlIO support. 1687 1688There is currently no way to turn off the guesswork that tries to format 1689unmarked text appropriately, and sometimes it isn't wanted (particularly 1690when using POD to document something other than Perl). Most of the work 1691toward fixing this has now been done, however, and all that's still needed 1692is a user interface. 1693 1694The NAME section should be recognized specially and index entries emitted 1695for everything in that section. This would have to be deferred until the 1696next section, since extraneous things in NAME tends to confuse various man 1697page processors. Currently, no index entries are emitted for anything in 1698NAME. 1699 1700Pod::Man doesn't handle font names longer than two characters. Neither do 1701most B<troff> implementations, but GNU troff does as an extension. It would 1702be nice to support as an option for those who want to use it. 1703 1704The preamble added to each output file is rather verbose, and most of it 1705is only necessary in the presence of non-ASCII characters. It would 1706ideally be nice if all of those definitions were only output if needed, 1707perhaps on the fly as the characters are used. 1708 1709Pod::Man is excessively slow. 1710 1711=head1 CAVEATS 1712 1713If Pod::Man is given the C<utf8> option, the encoding of its output file 1714handle will be forced to UTF-8 if possible, overriding any existing 1715encoding. This will be done even if the file handle is not created by 1716Pod::Man and was passed in from outside. This maintains consistency 1717regardless of PERL_UNICODE and other settings. 1718 1719The handling of hyphens and em dashes is somewhat fragile, and one may get 1720the wrong one under some circumstances. This should only matter for 1721B<troff> output. 1722 1723When and whether to use small caps is somewhat tricky, and Pod::Man doesn't 1724necessarily get it right. 1725 1726Converting neutral double quotes to properly matched double quotes doesn't 1727work unless there are no formatting codes between the quote marks. This 1728only matters for troff output. 1729 1730=head1 AUTHOR 1731 1732Russ Allbery <rra@stanford.edu>, based I<very> heavily on the original 1733B<pod2man> by Tom Christiansen <tchrist@mox.perl.com>. The modifications to 1734work with Pod::Simple instead of Pod::Parser were originally contributed by 1735Sean Burke (but I've since hacked them beyond recognition and all bugs are 1736mine). 1737 1738=head1 COPYRIGHT AND LICENSE 1739 1740Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 1741Russ Allbery <rra@stanford.edu>. 1742 1743This program is free software; you may redistribute it and/or modify it 1744under the same terms as Perl itself. 1745 1746=head1 SEE ALSO 1747 1748L<Pod::Simple>, L<perlpod(1)>, L<pod2man(1)>, L<nroff(1)>, L<troff(1)>, 1749L<man(1)>, L<man(7)> 1750 1751Ossanna, Joseph F., and Brian W. Kernighan. "Troff User's Manual," 1752Computing Science Technical Report No. 54, AT&T Bell Laboratories. This is 1753the best documentation of standard B<nroff> and B<troff>. At the time of 1754this writing, it's available at 1755L<http://www.cs.bell-labs.com/cm/cs/cstr.html>. 1756 1757The man page documenting the man macro set may be L<man(5)> instead of 1758L<man(7)> on your system. Also, please see L<pod2man(1)> for extensive 1759documentation on writing manual pages if you've not done it before and 1760aren't familiar with the conventions. 1761 1762The current version of this module is always available from its web site at 1763L<http://www.eyrie.org/~eagle/software/podlators/>. It is also part of the 1764Perl core distribution as of 5.6.0. 1765 1766=cut 1767