Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

231 lines
7.3 KiB

  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S %0 %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
  11. goto endofperl
  12. @rem ';
  13. #!perl
  14. #line 15
  15. eval 'exec C:\Perl\bin\perl.exe -S $0 ${1+"$@"}'
  16. if $running_under_some_shell;
  17. # pod2text -- Convert POD data to formatted ASCII text.
  18. #
  19. # Copyright 1999, 2000 by Russ Allbery <[email protected]>
  20. #
  21. # This program is free software; you can redistribute it and/or modify it
  22. # under the same terms as Perl itself.
  23. #
  24. # The driver script for Pod::Text, Pod::Text::Termcap, and Pod::Text::Color,
  25. # invoked by perldoc -t among other things.
  26. require 5.004;
  27. use Getopt::Long qw(GetOptions);
  28. use Pod::Text ();
  29. use Pod::Usage qw(pod2usage);
  30. use strict;
  31. # Take an initial pass through our options, looking for one of the form
  32. # -<number>. We turn that into -w <number> for compatibility with the
  33. # original pod2text script.
  34. for (my $i = 0; $i < @ARGV; $i++) {
  35. last if $ARGV[$i] =~ /^--$/;
  36. if ($ARGV[$i] =~ /^-(\d+)$/) {
  37. splice (@ARGV, $i++, 1, '-w', $1);
  38. }
  39. }
  40. # Insert -- into @ARGV before any single dash argument to hide it from
  41. # Getopt::Long; we want to interpret it as meaning stdin (which Pod::Parser
  42. # does correctly).
  43. my $stdin;
  44. @ARGV = map { $_ eq '-' && !$stdin++ ? ('--', $_) : $_ } @ARGV;
  45. # Parse our options. Use the same names as Pod::Text for simplicity, and
  46. # default to sentence boundaries turned off for compatibility.
  47. my %options;
  48. $options{sentence} = 0;
  49. Getopt::Long::config ('bundling');
  50. GetOptions (\%options, 'alt|a', 'color|c', 'help|h', 'indent|i=i',
  51. 'loose|l', 'overstrike|o', 'quotes|q=s', 'sentence|s',
  52. 'termcap|t', 'width|w=i') or exit 1;
  53. pod2usage (1) if $options{help};
  54. # Figure out what formatter we're going to use. -c overrides -t.
  55. my $formatter = 'Pod::Text';
  56. if ($options{color}) {
  57. $formatter = 'Pod::Text::Color';
  58. eval { require Term::ANSIColor };
  59. if ($@) { die "-c (--color) requires Term::ANSIColor be installed\n" }
  60. require Pod::Text::Color;
  61. } elsif ($options{termcap}) {
  62. $formatter = 'Pod::Text::Termcap';
  63. require Pod::Text::Termcap;
  64. } elsif ($options{overstrike}) {
  65. $formatter = 'Pod::Text::Overstrike';
  66. require Pod::Text::Overstrike;
  67. }
  68. delete @options{'color', 'termcap', 'overstrike'};
  69. # Initialize and run the formatter.
  70. my $parser = $formatter->new (%options);
  71. $parser->parse_from_file (@ARGV);
  72. __END__
  73. =head1 NAME
  74. pod2text - Convert POD data to formatted ASCII text
  75. =head1 SYNOPSIS
  76. pod2text [B<-aclost>] [B<-i> I<indent>] [B<-q> I<quotes>] [B<-w> I<width>]
  77. [I<input> [I<output>]]
  78. pod2text B<-h>
  79. =head1 DESCRIPTION
  80. B<pod2text> is a front-end for Pod::Text and its subclasses. It uses them
  81. to generate formatted ASCII text from POD source. It can optionally use
  82. either termcap sequences or ANSI color escape sequences to format the text.
  83. I<input> is the file to read for POD source (the POD can be embedded in
  84. code). If I<input> isn't given, it defaults to STDIN. I<output>, if given,
  85. is the file to which to write the formatted output. If I<output> isn't
  86. given, the formatted output is written to STDOUT.
  87. =head1 OPTIONS
  88. =over 4
  89. =item B<-a>, B<--alt>
  90. Use an alternate output format that, among other things, uses a different
  91. heading style and marks C<=item> entries with a colon in the left margin.
  92. =item B<-c>, B<--color>
  93. Format the output with ANSI color escape sequences. Using this option
  94. requires that Term::ANSIColor be installed on your system.
  95. =item B<-i> I<indent>, B<--indent=>I<indent>
  96. Set the number of spaces to indent regular text, and the default indentation
  97. for C<=over> blocks. Defaults to 4 spaces if this option isn't given.
  98. =item B<-h>, B<--help>
  99. Print out usage information and exit.
  100. =item B<-l>, B<--loose>
  101. Print a blank line after a C<=head1> heading. Normally, no blank line is
  102. printed after C<=head1>, although one is still printed after C<=head2>,
  103. because this is the expected formatting for manual pages; if you're
  104. formatting arbitrary text documents, using this option is recommended.
  105. =item B<-o>, B<--overstrike>
  106. Format the output with overstruck printing. Bold text is rendered as
  107. character, backspace, character. Italics and file names are rendered as
  108. underscore, backspace, character. Many pagers, such as B<less>, know how
  109. to convert this to bold or underlined text.
  110. =item B<-q> I<quotes>, B<--quotes>=I<quotes>
  111. Sets the quote marks used to surround CE<lt>> text to I<quotes>. If
  112. I<quotes> is a single character, it is used as both the left and right
  113. quote; if I<quotes> is two characters, the first character is used as the
  114. left quote and the second as the right quoted; and if I<quotes> is four
  115. characters, the first two are used as the left quote and the second two as
  116. the right quote.
  117. I<quotes> may also be set to the special value C<none>, in which case no
  118. quote marks are added around CE<lt>> text.
  119. =item B<-s>, B<--sentence>
  120. Assume each sentence ends with two spaces and try to preserve that spacing.
  121. Without this option, all consecutive whitespace in non-verbatim paragraphs
  122. is compressed into a single space.
  123. =item B<-t>, B<--termcap>
  124. Try to determine the width of the screen and the bold and underline
  125. sequences for the terminal from termcap, and use that information in
  126. formatting the output. Output will be wrapped at two columns less than the
  127. width of your terminal device. Using this option requires that your system
  128. have a termcap file somewhere where Term::Cap can find it and requires that
  129. your system support termios. With this option, the output of B<pod2text>
  130. will contain terminal control sequences for your current terminal type.
  131. =item B<-w>, B<--width=>I<width>, B<->I<width>
  132. The column at which to wrap text on the right-hand side. Defaults to 76,
  133. unless B<-t> is given, in which case it's two columns less than the width of
  134. your terminal device.
  135. =back
  136. =head1 DIAGNOSTICS
  137. If B<pod2text> fails with errors, see L<Pod::Text> and L<Pod::Parser> for
  138. information about what those errors might mean. Internally, it can also
  139. produce the following diagnostics:
  140. =over 4
  141. =item -c (--color) requires Term::ANSIColor be installed
  142. (F) B<-c> or B<--color> were given, but Term::ANSIColor could not be
  143. loaded.
  144. =item Unknown option: %s
  145. (F) An unknown command line option was given.
  146. =back
  147. In addition, other L<Getopt::Long|Getopt::Long> error messages may result
  148. from invalid command-line options.
  149. =head1 ENVIRONMENT
  150. =over 4
  151. =item COLUMNS
  152. If B<-t> is given, B<pod2text> will take the current width of your screen
  153. from this environment variable, if available. It overrides terminal width
  154. information in TERMCAP.
  155. =item TERMCAP
  156. If B<-t> is given, B<pod2text> will use the contents of this environment
  157. variable if available to determine the correct formatting sequences for your
  158. current terminal device.
  159. =back
  160. =head1 SEE ALSO
  161. L<Pod::Text|Pod::Text>, L<Pod::Text::Color|Pod::Text::Color>,
  162. L<Pod::Text::Termcap|Pod::Text::Termcap>, L<Pod::Parser|Pod::Parser>
  163. =head1 AUTHOR
  164. Russ Allbery E<lt>[email protected]<gt>.
  165. =cut
  166. __END__
  167. :endofperl