PerlBench

 view release on metacpan or  search on metacpan

benchmarks/app/MyPodHtml.pm  view on Meta::CPAN

    $Htmlroot = "/";	    	# http-server base directory from which all
				#   relative paths in $podpath stem.
    $Htmldir = "";	    	# The directory to which the html pages
				# will (eventually) be written.
    $Htmlfile = "";		# write to stdout by default
    $Htmlfileurl = "" ;		# The url that other files would use to
				# refer to this file.  This is only used
				# to make relative urls that point to
				# other files.

    $Podfile = "";		# read from stdin by default
    @Podpath = ();		# list of directories containing library pods.
    $Podroot = $Curdir;	        # filesystem base directory from which all
				#   relative paths in $podpath stem.
    $Css = '';                  # Cascading style sheet
    $Recurse = 1;		# recurse on subdirectories in $podpath.
    $Quiet = 0;		        # not quiet by default
    $Verbose = 0;		# not verbose by default
    $Doindex = 1;   	    	# non-zero if we should generate an index
    $Backlink = '';		# text for "back to top" links
    $Listlevel = 0;		# current list depth
    @Listend = ();		# the text to use to end the list.
    $After_Lpar = 0;            # set to true after a par in an =item
    $Ignore = 1;		# whether or not to format text.  we don't
				#   format text until we hit our first pod
				#   directive.

    @Items_Seen = ();	        # for multiples of the same item in perlfunc
    %Items_Named = ();
    $Header = 0;		# produce block header/footer
    $Title = '';		# title to give the pod(s)
    $Top = 1;			# true if we are at the top of the doc.  used
				#   to prevent the first <hr /> directive.
    $Paragraph = '';		# which paragraph we're processing (used
				#   for error messages)
    $PTQuote = 0;               # status of double-quote conversion
    %Sections = ();		# sections within this page

    %Local_Items = ();
    $Is83 = $^O eq 'dos';       # Is it an 8.3 filesystem?
}

#
# clean_data: global clean-up of pod data
#
sub clean_data($){
    my( $dataref ) = @_;
    for my $i ( 0..$#{$dataref} ) {
	${$dataref}[$i] =~ s/\s+\Z//;

        # have a look for all-space lines
      if( ${$dataref}[$i] =~ /^\s+$/m and $dataref->[$i] !~ /^\s/ ){
	    my @chunks = split( /^\s+$/m, ${$dataref}[$i] );
	    splice( @$dataref, $i, 1, @chunks );
	}
    }
}


sub pod2html {
    local(@ARGV) = @_;
    local($/);
    local $_;

    init_globals();

    $Is83 = 0 if (defined (&Dos::UseLFN) && Dos::UseLFN());

    # cache of %Pages and %Items from last time we ran pod2html

    #undef $opt_help if defined $opt_help;

    # parse the command-line parameters
    parse_command_line();

    # escape the backlink argument (same goes for title but is done later...)
    $Backlink = html_escape($Backlink) if defined $Backlink;

    # set some variables to their default values if necessary
    local *POD;
    unless (@ARGV && $ARGV[0]) {
	$Podfile  = "-" unless $Podfile;	# stdin
	open(POD, "<$Podfile")
		|| die "$0: cannot open $Podfile file for input: $!\n";
    } else {
	$Podfile = $ARGV[0];  # XXX: might be more filenames
	*POD = *ARGV;
    }
    $Htmlfile = "-" unless $Htmlfile;	# stdout
    $Htmlroot = "" if $Htmlroot eq "/";	# so we don't get a //
    $Htmldir =~ s#/\z## ;               # so we don't get a //
    if (  $Htmlroot eq ''
       && defined( $Htmldir )
       && $Htmldir ne ''
       && substr( $Htmlfile, 0, length( $Htmldir ) ) eq $Htmldir
       )
    {
	# Set the 'base' url for this file, so that we can use it
	# as the location from which to calculate relative links
	# to other files. If this is '', then absolute links will
	# be used throughout.
        $Htmlfileurl= "$Htmldir/" . substr( $Htmlfile, length( $Htmldir ) + 1);
    }

    # read the pod a paragraph at a time
    warn "Scanning for sections in input file(s)\n" if $Verbose;
    $/ = "";
    my @poddata  = <POD>;
    close(POD);

    # be eol agnostic
    for (@poddata) {
	if (/\r/) {
	    if (/\r\n/) {
		@poddata = map { s/\r\n/\n/g;
				 /\n\n/ ?
				     map { "$_\n\n" } split /\n\n/ :
				     $_ } @poddata;
	    } else {
		@poddata = map { s/\r/\n/g;
				 /\n\n/ ?



( run in 1.753 second using v1.01-cache-2.11-cpan-98e64b0badf )