* 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.
my $indent = "";
my sub procline;
sub procline {
- $_ = $_[0];
+ $_ = shift;
chop;
if (/\r$/) {
chop;
}
sub nodename {
- $_ = $_[0];
- tr/./-/;
+ $_ = shift;
+ tr'():,.'-----';
return $_;
}
+sub printMenuEntry {
+ print "* " . (nodename $_) . ": " . (nodename $_) . ".\n";
+}
+
sub genInfo {
my $page = shift;
my %links;
$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;
if ($#backs != -1) {
print "\n* Menu:\nBacklinks:\n";
foreach (@backs) {
- print "* " . (nodename $_) . ": " . (nodename $_) . ".\n";
+ printMenuEntry $_;
}
print "\n";
}
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";
}
if ($#links != -1) {
print "\n* Menu:\nBacklinks:\n";
foreach (@links) {
- print "* " . (nodename $_) . ": " . (nodename $_) . ".\n";
+ printMenuEntry $_;
}
print "\n";
}
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";
}