]> Sergey Matveev's repositories - dotfiles.git/blob - bin/bin/texinavfix.pl
More fzf/path-extractor convenience
[dotfiles.git] / bin / bin / texinavfix.pl
1 #!/usr/bin/env perl
2
3 use strict;
4 use warnings;
5
6 my %rels;
7 my $header = 0;
8 my $printed = 0;
9
10 while(<STDIN>){
11     ($rels{$2} = $1) if /^<link href="([^#]*)[^"]*" rel="([^"]*)" title/;
12     if(/^<div class="header">$/){
13         print "$_<center><p>";
14         if(defined $rels{"prev"}){
15             print "<a href=\"$rels{'prev'}\" accesskey=\"p\" rel=\"prev\">[&lt;&lt;&lt;]</a>";
16         };
17         if(defined $rels{"up"}){
18             print "<a href=\"$rels{'up'}\" accesskey=\"u\" rel=\"up\">[^^^]</a>";
19         };
20         if(defined $rels{"next"}){
21             print "<a href=\"$rels{'next'}\" accesskey=\"n\" rel=\"next\">[&gt;&gt;&gt;]</a>";
22         };
23         $header++;
24     };
25     if($header && /^<.div>$/){
26         print "</p></center>$_";
27         $header--;
28     };
29     next if $header;
30     print;
31 };