From 2288b8c924fe41d554463a1dc12fe08ace48e630 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 30 Nov 2013 23:55:35 +0000 Subject: [PATCH] more debug and unique anchors git-svn-id: file:///home/dpavlin/private/svn/sysadmin-cookbook-html@14 3e18072f-9615-4e06-9d3a-648eafba3f8d --- bin/html.pl | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/bin/html.pl b/bin/html.pl index f247856..e87f1a5 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|\.conf|\.pl)$}i || -e $path ? qq|$path| : '' ) + . ( $path =~ m{(\.sh|Makefile|\.conf|\.pl)$}i || -x "$recepies/$path" ? qq|$path| : '' ) . qq|
$content
| ; } @@ -53,17 +54,22 @@ 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, $name) = @_; + 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+$}{}; - my $anchor = $name; + my $anchor = $full_name; $anchor =~ s{]+>}{}g; $anchor =~ s{\W+}{_}g; @@ -72,8 +78,10 @@ sub header { if ( $last_level > $level ) { $toc_html .= ""; + warn "## $last_level > $level toc /ul"; } elsif ( $last_level < $level ) { $toc_html .= "