--- branches/no-pager/lib/Frey/Pod.pm 2008/12/03 21:12:43 702 +++ branches/no-pager/lib/Frey/Pod.pm 2008/12/06 15:29:10 738 @@ -9,16 +9,17 @@ extends 'Frey::ClassLoader'; with 'Frey::Web'; +with 'Frey::File'; has 'class' => ( is => 'rw', isa => 'Str', required => 1, + default => 'Frey::Manual', ); -use File::Slurp; -use Data::Dump qw/dump/; use Pod::Find qw/pod_where/; +use Data::Dump qw/dump/; sub as_markup { my $self = shift; @@ -26,7 +27,7 @@ use Pod::Simple::HTML; my $path = pod_where( { -inc => 1 }, $class ); return $self->error( "Can't find pod for $class\n" ) unless $path; - my $pod = read_file( $path ); + my $pod = $self->read_file( $path ); my $converter = Pod::Simple::HTML->new(); my $body; my $my_classes = join('|', $self->classes); @@ -41,8 +42,70 @@ $body =~ s!!!; $body =~ s!

!!; $body =~ s!__index__!index!g; + + our @toc = (); + + sub heading { + my ($level,$html) = @_; + push @toc, { $level => $html }; + warn "# heading $level $html"; + qq|<$level>$html|; + } + $body =~ s{<(h\d+)>(.+?)}{heading($1,$2)}egs; + $self->title( $class ); - return $body; + +# $body .= $self->html_dump( $toc ); + warn "# toc ", dump( @toc ); + + my $toc_html = ''; + my $current_level = 0; + foreach my $entry ( @toc ) { + my ( $level, $html ) = %$entry; + + if ( $level =~ m{h(\d+)} ) { + my $num = $1; + if ( $num > $current_level ) { + if ( ! $toc_html ) { # first ul + $toc_html .= qq|