From: Sergey Matveev Date: Mon, 12 May 2025 18:01:10 +0000 (+0300) Subject: Various corrections X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=b750892ba8f37502664ab9fad2dd90a5a416451e;p=swg.git Various corrections --- diff --git a/USAGE b/USAGE index 77b185b..6db859f 100644 --- 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 4a66592..3409b5c 100755 --- a/zk +++ b/zk @@ -240,7 +240,7 @@ sub genHTML { my $indent = ""; my sub procline; sub procline { - $_ = $_[0]; + $_ = shift; chop; if (/ $/) { 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 (/ $/) { 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"; }