package Perl::Tidy::HtmlWriter;
use strict;
use warnings;
-our $VERSION = '20220613';
+our $VERSION = '20230309';
use English qw( -no_match_vars );
use File::Basename;
if ( !eval { require Pod::Html; 1 } ) {
$missing_pod_html = $EVAL_ERROR ? $EVAL_ERROR : 1;
}
-}
+} ## end BEGIN
sub AUTOLOAD {
======================================================================
EOM
exit 1;
-}
+} ## end sub AUTOLOAD
sub DESTROY {
# name changes
_rlast_level => \$last_level, # brace indentation level
}, $class;
-}
+} ## end sub new
sub close_object {
my ($object) = @_;
# returns true if close works, false if not
# failure probably means there is no close method
return eval { $object->close(); 1 };
-}
+} ## end sub close_object
sub add_toc_item {
TOC_END
}
return;
-}
+} ## end sub add_toc_item
BEGIN {
);
# These token types will all be called identifiers for now
- # FIXME: could separate user defined modules as separate type
my @identifier = qw< i t U C Y Z G :: CORE::>;
@token_short_names{@identifier} = ('i') x scalar(@identifier);
# my @list = qw" .. -> <> ... \ ? ";
# @token_long_names{@list} = ('misc-operators') x scalar(@list);
-}
+} ## end BEGIN
sub make_getopt_long_names {
my ( $class, $rgetopt_names ) = @_;
push @{$rgetopt_names}, "podheader!";
push @{$rgetopt_names}, "podindex!";
return;
-}
+} ## end sub make_getopt_long_names
sub make_abbreviated_names {
${$rexpansion}{"text"} = ["html-toc-extension"];
${$rexpansion}{"sext"} = ["html-src-extension"];
return;
-}
+} ## end sub make_abbreviated_names
sub check_options {
}
$missing_html_entities = 1 unless $rOpts->{'html-entities'};
return;
-}
+} ## end sub check_options
sub write_style_sheet_file {
write_style_sheet_data($fh);
close_object($fh);
return;
-}
+} ## end sub write_style_sheet_file
sub write_style_sheet_data {
$fh->print("} /* $long_name */\n");
}
return;
-}
+} ## end sub write_style_sheet_data
sub set_default_color {
if ( $rOpts->{$key} ) { $color = $rOpts->{$key} }
$rOpts->{$key} = check_RGB($color);
return;
-}
+} ## end sub set_default_color
sub check_RGB {
my ($color) = @_;
if ( $color =~ /^[0-9a-fA-F]{6,6}$/ ) { $color = "#$color" }
return $color;
-}
+} ## end sub check_RGB
sub set_default_properties {
my ( $short_name, $color, $bold, $italic ) = @_;
$key = "html-italic-$short_to_long_names{$short_name}";
$rOpts->{$key} = ( defined $rOpts->{$key} ) ? $rOpts->{$key} : $italic;
return;
-}
+} ## end sub set_default_properties
sub pod_to_html {
# this error shouldn't happen ... we just used this filename
Perl::Tidy::Warn(
"unable to open temporary file $tmpfile; cannot use pod2html\n");
- goto RETURN;
+ return $success_flag;
}
my $html_fh = $self->{_html_fh};
$success_flag = 0;
}
- RETURN:
close_object($html_fh);
# note that we have to unlink tmpfile before making frames
$self->make_frame( \@toc );
}
return $success_flag;
-}
+} ## end sub pod_to_html
sub make_frame {
$toc_basename, $src_basename, $src_frame_name
);
return;
-}
+} ## end sub make_frame
sub write_toc_html {
EOM
return;
-}
+} ## end sub write_toc_html
sub write_frame_html {
</html>
EOM
return;
-}
+} ## end sub write_frame_html
sub change_anchor_names {
}
}
return $first_anchor;
-}
+} ## end sub change_anchor_names
sub close_html_file {
my $self = shift;
$self->make_frame( \@toc );
}
return;
-}
+} ## end sub close_html_file
sub markup_tokens {
my ( $self, $rtokens, $rtoken_type, $rlevels ) = @_;
push @colored_tokens, $token;
}
return ( \@colored_tokens );
-}
+} ## end sub markup_tokens
sub markup_html_element {
my ( $self, $token, $type ) = @_;
if ( $html_bold{$short_name} ) { $token = "<b>$token</b>" }
}
return $token;
-}
+} ## end sub markup_html_element
sub escape_html {
HTML::Entities::encode_entities($token);
}
return $token;
-}
+} ## end sub escape_html
sub finish_formatting {
my $self = shift;
$self->close_html_file();
return;
-}
+} ## end sub finish_formatting
sub write_line {
# write the line
$html_pre_fh->print("$html_line\n");
return;
-}
+} ## end sub write_line
1;