manfull.pl 912 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/perl
  2. while ($page = shift) {
  3. system "mv $page $page.orig";
  4. open IN,"<$page.orig" or die "Cannot read from $page.orig\n";
  5. open OUT,">$page" or die "Cannot write to $page\n";
  6. while (<IN>) {
  7. if (/<meta http-equiv="Content-Style-Type" content="text\/css">/) {
  8. print OUT;
  9. print OUT '<link rel="stylesheet" href="https://orgmode.org/org-manual.css" type="text/css" />';
  10. } elsif (/<div class="contents">/) {
  11. print OUT;
  12. print OUT '<p>This is the official manual for the latest <a href="https://orgmode.org">Org mode</a> release.</p><div id="table-of-contents">';
  13. } elsif (/<h2>Table of Contents<\/h2>/) {
  14. print OUT;
  15. print OUT '<a href="https://orgmode.org">https://orgmode.org</a><br/><div id="text-table-of-contents">';
  16. $toc = 1;
  17. } elsif (/<\/div>/ and $toc) {
  18. print OUT "</div></div></div>";
  19. $toc = 0;
  20. } else {
  21. print OUT;
  22. }
  23. }
  24. system "rm $page.orig";
  25. }