manfull.pl 908 B

1234567891011121314151617181920212223242526272829
  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="http://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="http://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="http://orgmode.org">http://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. }