projects
/
sysadmin-cookbook-html
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
link to .pl files
[sysadmin-cookbook-html]
/
bin
/
html.pl
diff --git
a/bin/html.pl
b/bin/html.pl
index
35827eb
..
f247856
100755
(executable)
--- a/
bin/html.pl
+++ b/
bin/html.pl
@@
-43,7
+43,7
@@
sub file {
$path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next;
return ''
. qq|<ul class=changes>$changes</ul>|
$path =~ s{^$recepies/*(.*?[^/]+)$}{$1} || next;
return ''
. qq|<ul class=changes>$changes</ul>|
- . ( $path =~ m{(\.sh|Makefile
)$}i
? qq|<a class="path" href="$svn/view/recepies/$path">$path</a>| : '' )
+ . ( $path =~ m{(\.sh|Makefile
|\.conf|\.pl)$}i || -e $path
? qq|<a class="path" href="$svn/view/recepies/$path">$path</a>| : '' )
. qq|<pre class=content>$content</pre>|
;
}
. qq|<pre class=content>$content</pre>|
;
}
@@
-56,13
+56,18
@@
find({ follow => 0, no_chdir => 1, wanted => sub {
my $last_level = 0;
my $toc_html = '';
sub header {
my $last_level = 0;
my $toc_html = '';
sub header {
- my ($level, $content) = @_;
- my $display = $content;
+ my ($level, $name) = @_;
+
+ my $display = $name;
$display =~ s{^\d+[\.-]}{};
$display =~ s{-}{ }g;
$display =~ s{\.\w+$}{};
$display =~ s{^\d+[\.-]}{};
$display =~ s{-}{ }g;
$display =~ s{\.\w+$}{};
- $content =~ s{\W+}{_}g;
- html qq|<a name=$content></a>|;
+
+ my $anchor = $name;
+ $anchor =~ s{</?[^>]+>}{}g;
+ $anchor =~ s{\W+}{_}g;
+
+ html qq|<a name=$anchor></a>|;
html qq|<h$level>$display</h$level>|;
if ( $last_level > $level ) {
html qq|<h$level>$display</h$level>|;
if ( $last_level > $level ) {
@@
-70,7
+75,7
@@
sub header {
} elsif ( $last_level < $level ) {
$toc_html .= "<ul>";
}
} elsif ( $last_level < $level ) {
$toc_html .= "<ul>";
}
- $toc_html .= qq|<li><a href="#$
content
">$display</li>|;
+ $toc_html .= qq|<li><a href="#$
anchor
">$display</li>|;
$last_level = $level;
}
$last_level = $level;
}