Skip to content

Commit

Permalink
Add html_h_level option in Pod::Simple
Browse files Browse the repository at this point in the history
  • Loading branch information
dafrito committed Aug 16, 2011
1 parent 8d0e7ff commit acb857a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/Pod/Simple/HTML.pm
Expand Up @@ -69,6 +69,8 @@ __PACKAGE__->_accessorize(
'title_prefix', 'title_postfix',
# What to put before and after the title in the head.
# Should already be &-escaped

'html_h_level',

'html_header_before_title',
'html_header_after_title',
Expand Down Expand Up @@ -211,6 +213,21 @@ sub new {
return $new;
}

sub __adjust_html_h_levels {
my ($self) = @_;
my $Tagmap = $self->{'Tagmap'};

my $add = $self->html_h_level;
return unless defined $add;
return if ($self->{'Adjusted_html_h_levels'}||0) == $add;

$add -= 1;
for (1 .. 4) {
$Tagmap->{"head$_"} =~ s/$_/$_ + $add/e;
$Tagmap->{"/head$_"} =~ s/$_/$_ + $add/e;
}
}

sub batch_mode_page_object_init {
my($self, $batchconvobj, $module, $infile, $outfile, $depth) = @_;
DEBUG and print "Initting $self\n for $module\n",
Expand Down Expand Up @@ -433,6 +450,8 @@ sub _do_middle_main_loop {
my $self = $_[0];
my $fh = $self->{'output_fh'};
my $tagmap = $self->{'Tagmap'};

$self->__adjust_html_h_levels;

my($token, $type, $tagname, $linkto, $linktype);
my @stack;
Expand Down
6 changes: 6 additions & 0 deletions lib/Pod/Simple/XHTML.pm
Expand Up @@ -117,6 +117,12 @@ default value is just a content type header tag:
Add additional meta tags here, or blocks of inline CSS or JavaScript
(wrapped in the appropriate tags).
=head2 html_h_level
This is the level of HTML "Hn" element to which a Pod "head1" corresponds. For
example, if C<html_h_level> is set to 2, a head1 will produce an H2, a head2
will produce an H3, and so on.
=head2 default_title
Set a default title for the page if no title can be determined from the
Expand Down

0 comments on commit acb857a

Please sign in to comment.