diff options
Diffstat (limited to 'ssg')
-rwxr-xr-x | ssg | 53 |
1 files changed, 34 insertions, 19 deletions
@@ -1,6 +1,9 @@ #!/usr/bin/perl use strict; use warnings; +use v5.22; +# Disable experimental warnings. +no warnings 'experimental'; use File::Path qw(make_path remove_tree); use Path::Class; @@ -11,6 +14,10 @@ my $indir; my $outdir; my $VERSION = "v0.1"; +my @exlude_files = ( + qr/TIL\/\w+\/*/ +); + sub help { print<<EOF $0 [switches] input-directory @@ -90,29 +97,37 @@ sub generate_link { my ($file, $options) = @_; $options->{hl} = 0 if !exists($options->{hl}); - my $path = $file->stringify; - my $str = $file->basename; + # Exclude links + given($file) { + when(@exlude_files) { + return ""; + } + default { + my $path = $file->stringify; + my $str = $file->basename; - if($path =~ /index\.md$/) { - return ""; - } + if($path =~ /index\.md$/) { + return ""; + } - # remove the input directory. - $path =~ s/^$indir//g; - if($file->is_dir()) { - $str = "$str/" if $file->is_dir(); - } else { - $path =~ s/\.md$/.html/g; - $str =~ s/\.md$//g; - } + # remove the input directory. + $path =~ s/^$indir//g; + if($file->is_dir()) { + $str = "$str/" if $file->is_dir(); + } else { + $path =~ s/\.md$/.html/g; + $str =~ s/\.md$//g; + } - # Higlight? - my $hl = ""; - if($options->{hl} eq 1) { - $hl = "class='hl'"; - } + # Higlight? + my $hl = ""; + if($options->{hl} eq 1) { + $hl = "class='hl'"; + } - return "<li><a $hl href='$path'>$str</a></li>"; + return "<li><a $hl href='$path'>$str</a></li>"; + } + } } sub transverse { |