$0 backs PAGE -- show backlinks to the PAGE
$0 cats [PREFIX] -- show categories
$0 htmls DIR -- render HTMLs in DIR
- $0 info >out.info
$0 dot | dot -Tpng >relations.png
+ $0 info >out.info
+ $0 latex >out.tex
For debugging:
$0 files -- list files that will be processed
return;
}
+sub genLaTeXSection {
+ my $page = shift;
+ my $buf = shift;
+ print <<"END_LATEX"
+\\addcontentsline{toc}{section}{$page}
+\\section*{$page}
+\\begin{verbatim}
+END_LATEX
+;
+ my $fh;
+ if (defined $buf) {
+ open $fh, q{<:encoding(UTF-8)}, \$buf or croak "$!";
+ } else {
+ open $fh, q{<:encoding(UTF-8)}, $page or croak "$!";
+ }
+ my $wasClosed = 0;
+ while (<$fh>) {
+ chop;
+ if (/${CR}$/) {
+ chop;
+ /^\s*(.*)$/;
+ my $cmd = $1;
+ if (($cmd =~ /^#/) or ($cmd =~ /^do-backs/)) {
+ next;
+ }
+ if ($cmd =~ /^=> (\S+)\s?(.*)$/) {
+ my $url = $1;
+ my $t = ($2 eq q{}) ? $1 : $2;
+ if (not $wasClosed) {
+ print "\\end{verbatim}\n";
+ }
+ print "\$\\Rightarrow\$ \\href{$url}{$t} \\newline\n";
+ $wasClosed = 1;
+ next;
+ } elsif ($cmd =~ /^img (\S+)\s?(.*)$/) {
+ if (not $wasClosed) {
+ print "\\end{verbatim}\n";
+ }
+ print "\\includegraphics{$1} \\newline\n";
+ next;
+ }
+ }
+ if ($wasClosed) {
+ $wasClosed = 0;
+ print "\\begin{verbatim}\n";
+ }
+ if (/^(.*)\\end\{verbatim\}(.*)$/) {
+ print "$1\\end{verbatim}\\verb|\\end{verbatim}|\\begin{verbatim}$2";
+ next;
+ }
+ print "$_\n";
+ }
+ my @backs = sort keys %{$Backs{noindex $page}};
+ if ($#backs != -1) {
+ print "\nBacklinks:\n";
+ foreach (@backs) {
+ print "[$_]\n";
+ }
+ }
+ if (not $wasClosed) {
+ print "\\end{verbatim}\n";
+ }
+ return;
+}
+
sub genInfoIndex {
my $page = shift;
my $pth;
(nodename noindex $page) . ". (line 0)\n";
}
print "${sep}Local Variables:\ncoding: utf-8\nEnd:\n";
+} elsif ($ARGV[0] eq q{latex}) {
+ print <<"END_LATEX"
+\\documentclass[a4paper,10pt]{report}
+\\usepackage{iftex}
+\\ifxetex
+ \\usepackage{fontspec}
+ \\setmainfont{CMU Serif}
+ \\setmonofont{Go Mono}
+\\else
+ \\usepackage[T2A]{fontenc}
+ \\usepackage[utf8]{inputenc}
+\\fi
+\\usepackage[pdfa,colorlinks=true,final]{hyperref}
+\\usepackage{a4wide}
+\\usepackage{graphicx}
+\\begin{document}
+\\small
+END_LATEX
+;
+ if (exists $Mtimes{q{index}}) {
+ genLaTeXSection q{index};
+ delete $Mtimes{q{index}};
+ delete $CatFiles{q{/}};
+ } else {
+ genLaTeXSection "/", genIndex2Buf q{/};
+ delete $CatFiles{q{/}};
+ }
+ foreach my $cat (keys %CatFiles) {
+ next if (exists $Mtimes{"${cat}index"});
+ genLaTeXSection $cat, genIndex2Buf $cat;
+ }
+ foreach my $page (keys %Mtimes) {
+ genLaTeXSection $page;
+ }
+ print "\\tableofcontents\n";
+ print "\\end{document}\n";
} elsif ($ARGV[0] eq q{dot}) {
print "digraph d {\n";
print "rankdir=LR\n";