PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/Pod-Perldoc-3.17/lib/Pod/Perldoc/ToANSI.pm

#
Perl | 96 lines | 64 code | 32 blank | 0 comment | 2 complexity | 3648c0d67f35f13211898d0cad084ddf MD5 | raw file
  1. package Pod::Perldoc::ToANSI;
  2. use strict;
  3. use warnings;
  4. use parent qw(Pod::Perldoc::BaseTo);
  5. use vars qw($VERSION);
  6. $VERSION = '3.17';
  7. sub is_pageable { 1 }
  8. sub write_with_binmode { 0 }
  9. sub output_extension { 'txt' }
  10. use Pod::Text::Color ();
  11. sub alt { shift->_perldoc_elem('alt' , @_) }
  12. sub indent { shift->_perldoc_elem('indent' , @_) }
  13. sub loose { shift->_perldoc_elem('loose' , @_) }
  14. sub quotes { shift->_perldoc_elem('quotes' , @_) }
  15. sub sentence { shift->_perldoc_elem('sentence', @_) }
  16. sub width { shift->_perldoc_elem('width' , @_) }
  17. sub new { return bless {}, ref($_[0]) || $_[0] }
  18. sub parse_from_file {
  19. my $self = shift;
  20. my @options =
  21. map {; $_, $self->{$_} }
  22. grep !m/^_/s,
  23. keys %$self
  24. ;
  25. defined(&Pod::Perldoc::DEBUG)
  26. and Pod::Perldoc::DEBUG()
  27. and print "About to call new Pod::Text::Color ",
  28. $Pod::Text::VERSION ? "(v$Pod::Text::VERSION) " : '',
  29. "with options: ",
  30. @options ? "[@options]" : "(nil)", "\n";
  31. ;
  32. Pod::Text::Color->new(@options)->parse_from_file(@_);
  33. }
  34. 1;
  35. =head1 NAME
  36. Pod::Perldoc::ToANSI - render Pod with ANSI color escapes
  37. =head1 SYNOPSIS
  38. perldoc -o ansi Some::Modulename
  39. =head1 DESCRIPTION
  40. This is a "plug-in" class that allows Perldoc to use
  41. Pod::Text as a formatter class.
  42. It supports the following options, which are explained in
  43. L<Pod::Text>: alt, indent, loose, quotes, sentence, width
  44. For example:
  45. perldoc -o term -w indent:5 Some::Modulename
  46. =head1 CAVEAT
  47. This module may change to use a different text formatter class in the
  48. future, and this may change what options are supported.
  49. =head1 SEE ALSO
  50. L<Pod::Text>, L<Pod::Text::Color>, L<Pod::Perldoc>
  51. =head1 COPYRIGHT AND DISCLAIMERS
  52. Copyright (c) 2011 Mark Allen. All rights reserved.
  53. This library is free software; you can redistribute it and/or modify it
  54. under the same terms as Perl itself.
  55. This program is distributed in the hope that it will be useful, but
  56. without any warranty; without even the implied warranty of
  57. merchantability or fitness for a particular purpose.
  58. =head1 AUTHOR
  59. Current maintainer: Mark Allen C<< <mallen@cpan.org> >>
  60. Past contributions from:
  61. brian d foy C<< <bdfoy@cpan.org> >>
  62. Adriano R. Ferreira C<< <ferreira@cpan.org> >>,
  63. Sean M. Burke C<< <sburke@cpan.org> >>
  64. =cut