]> Sergey Matveev's repositories - swg.git/commitdiff
Various corrections
authorSergey Matveev <stargrave@stargrave.org>
Mon, 12 May 2025 18:01:10 +0000 (21:01 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 12 May 2025 18:07:34 +0000 (21:07 +0300)
USAGE
zk

diff --git a/USAGE b/USAGE
index 77b185bec71a8c61796789e6ee3508ecc8e3cd95..6db859fa869240cdfa2d318dfcaf7e615cb1a8ad 100644 (file)
--- a/USAGE
+++ b/USAGE
@@ -9,7 +9,7 @@
 * zk dot | dot -Tpng >relations.png
   Generates Graphviz'es dot graph with internal links relationships.
 * zk info >out.info
-  Generates Info output.
+  Generates GNU Info output.
 
 If directory does not have "index" file, then it will be autogenerated
 with all files in the directory (category) and all backlinks to it.
diff --git a/zk b/zk
index 4a66592a154959ca469d83dbcb70f15af7250b02..3409b5c2975d64b00bd23f79790133da7c8cc542 100755 (executable)
--- a/zk
+++ b/zk
@@ -240,7 +240,7 @@ sub genHTML {
     my $indent = "";
     my sub procline;
     sub procline {
-        $_ = $_[0];
+        $_ = shift;
         chop;
         if (/\r$/) {
             chop;
@@ -319,11 +319,15 @@ sub genHTML {
 }
 
 sub nodename {
-    $_ = $_[0];
-    tr/./-/;
+    $_ = shift;
+    tr'():,.'-----';
     return $_;
 }
 
+sub printMenuEntry {
+    print "* " . (nodename $_) . ": " . (nodename $_) . ".\n";
+}
+
 sub genInfo {
     my $page = shift;
     my %links;
@@ -336,20 +340,23 @@ sub genInfo {
             $links{$_} = 1;
         }
     }
+    my sub linked {
+        my $n = shift;
+        return $n unless exists $links{$n};
+        $n = nodename $n;
+        return "[*note ${n}::]";
+    }
     open(my $fh, "<:encoding(UTF-8)", $page) or die "$!";
     while (<$fh>) {
         chop;
         if (/\r$/) {
             chop;
             /^\s*(.*)$/;
-            if ($1 =~ /^do-backs/) {
-                next;
-            }
-            if ($1 =~ /^#/) {
+            if (($1 =~ /^#/) || ($1 =~ /^do-backs/)) {
                 next;
             }
         }
-        s/\[([^]]+)\]/my $n = nodename $1; (exists $links{$1}) ? ("*note ${n}::") : $1/ge;
+        s/\[([^]]+)\]/linked $1/ge;
         print "$_\n";
     }
     close $fh;
@@ -357,7 +364,7 @@ sub genInfo {
     if ($#backs != -1) {
         print "\n* Menu:\nBacklinks:\n";
         foreach (@backs) {
-            print "* " . (nodename $_) . ": " . (nodename $_) . ".\n";
+            printMenuEntry $_;
         }
         print "\n";
     }
@@ -368,14 +375,14 @@ sub genInfoIndex {
     my $pth;
     print "* Menu:\n\n";
     foreach (sort @{$CatFiles{$page}}) {
-        print "* " . (nodename $_) . ": " . (nodename $_) . ".\n";
+        printMenuEntry $_;
     }
     print "\n";
     my @links = sort @{$CatDirs{$page}};
     if ($#links != -1) {
         print "\n* Menu:\nSubcategories:\n";
         foreach (@links) {
-            print "* " . (nodename $_) . ": " . (nodename $_) . ".\n";
+            printMenuEntry $_;
         }
         print "\n";
     }
@@ -383,7 +390,7 @@ sub genInfoIndex {
     if ($#links != -1) {
         print "\n* Menu:\nBacklinks:\n";
         foreach (@links) {
-            print "* " . (nodename $_) . ": " . (nodename $_) . ".\n";
+            printMenuEntry $_;
         }
         print "\n";
     }
@@ -465,14 +472,12 @@ if ($ARGV[0] eq "dump") {
         genInfo "index";
         delete $Mtimes{"index"};
         delete $CatFiles{"/"};
-        delete $CatDirs{"/"};
     } else {
         genInfoIndex "/";
         delete $CatFiles{"/"};
-        delete $CatDirs{"/"};
     }
     sub up {
-        my $p = dirname noindex $_[0];
+        my $p = dirname noindex shift;
         if (($p eq ".") or ($p eq "/")) {
             return "Top";
         }