X-Git-Url: http://git.rot13.org/?p=sysadmin-cookbook-html;a=blobdiff_plain;f=bin%2Fhtml.pl;h=fd355f1ccdc9303e279b4c6214365f7cfac24db0;hp=35827eb8bf8fbe7fcd2d652fe011f2f2bcdc7065;hb=HEAD;hpb=c13b4194deff3dd1b19d73c6a4849649d54dfbc1 diff --git a/bin/html.pl b/bin/html.pl index 35827eb..fd355f1 100755 --- a/bin/html.pl +++ b/bin/html.pl @@ -41,9 +41,10 @@ sub file { ); $path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next; +warn "## path = $path\n"; return '' . qq|| - . ( $path =~ m{(\.sh|Makefile)$}i ? qq|$path| : '' ) + . ( $path =~ m{(\.sh|Makefile|\.conf|\.pl)$}i || -x "$recepies/$path" ? qq|$path| : '' ) . qq|
$content
| ; } @@ -53,24 +54,36 @@ find({ follow => 0, no_chdir => 1, wanted => sub { push @names, $_ unless m{/\.} || m{^\.}; }}, $recepies ); -my $last_level = 0; -my $toc_html = ''; +warn "## names = ",dump( @names ); + +our $last_level = 0; +our $toc_html = ''; sub header { - my ($level, $content) = @_; - my $display = $content; + my ($level, $name, $full_name) = @_; + $full_name ||= $name; + $full_name =~ s{recepies/}{}; + warn "## header $level $name [$full_name]\n"; + + my $display = $name; $display =~ s{^\d+[\.-]}{}; $display =~ s{-}{ }g; $display =~ s{\.\w+$}{}; - $content =~ s{\W+}{_}g; - html qq||; + + my $anchor = $full_name; + $anchor =~ s{]+>}{}g; + $anchor =~ s{\W+}{_}g; + + html qq||; html qq|$display|; if ( $last_level > $level ) { $toc_html .= ""; + warn "## $last_level > $level toc /ul"; } elsif ( $last_level < $level ) { $toc_html .= "