From: Sergey Matveev Date: Thu, 8 May 2025 11:22:27 +0000 (+0300) Subject: Various miscellaneous fixes X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=739feb8265b6597288dde214d23c640423aabcb2;p=zk.git Various miscellaneous fixes --- diff --git a/zk b/zk index e400661..8a4c90a 100755 --- a/zk +++ b/zk @@ -96,6 +96,8 @@ to other pages. It also will include all backlinks in them. Each directory will also contain index page with links to all existing pages in current directory and to subdirectories. +=head1 HISTORY + Older version of that script, written on Z shell, can be found in Git history. =cut @@ -209,9 +211,12 @@ sub genHTML { my $rel; foreach (@lnks) { $rel = File::Spec->abs2rel($_, $page); - $rel = substr $rel, 3; - if (-d $rel) { - $rel .= "/index"; + $rel = (length $rel > 2) ? (substr $rel, 3) : ""; + if (-d $_) { + if ($rel ne "") { + $rel .= "/"; + } + $rel .= "index"; } push @rels, $rel; } @@ -219,8 +224,7 @@ sub genHTML { startHead $out, $page; { my $fn = basename $page; - print $out "\n"; + print $out "\n"; } print $out "
";
     open(my $fh, "<", $page) or die "$!";
@@ -228,14 +232,18 @@ sub genHTML {
         chop;
         if (/
$/) {
             chop;
+            s/^(\s*)//g;
+            my $head = $1;
             my @cols = split /\s+/;
             if ($cols[0] eq ">") {
                 my $t = ($#cols > 1) ? (join " ", @cols[2..$#cols]) : $cols[1];
                 $t = htmlescape $t;
-                $_ = "$t";
+                $t =~ s/"/\&guot;/g;
+                $_ = "${head}=> $t";
             } elsif ($cols[0] eq "I") {
                 if ($#cols > 1) {
                     my $t = htmlescape join " ", @cols[2..$#cols];
+                    $t =~ s/"/\&guot;/g;
                     $_ = "\"$t\"";
                 } else {
                     $_ = "";
@@ -247,7 +255,7 @@ sub genHTML {
             $_ = htmlescape $_;
             if (/\[.+\]/) {
                 while (my ($i, $l) = each @lnks) {
-                    s/\[$l\]/[$l]<\/a>/g;
+                    s/\[\Q$l\E\]/[$l]<\/a>/g;
                 }
             }
         }