mansplit.pl 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/perl
  2. # Work on the files that are created by makeinfo for html output
  3. # split into many small files.
  4. # This will walk though the files listed on the command line, install
  5. # Sebastian Rose's key reader and add a small top-level-only table
  6. # of contents that will be placed into a special region and visible
  7. # in all subfiles. The small contents is a constant and has to be updated
  8. # by hand, currently.
  9. $contents = <<EOF;
  10. <div id="table-of-contents">
  11. <h2>Table of Contents</h2>
  12. <div id="text-table-of-contents">
  13. <ul>
  14. <li><a name="toc_Top" href="index.html#Top">Org Mode Manual</a>
  15. <li><a name="toc_Introduction" href="Introduction.html#Introduction">1 Introduction</a>
  16. <li><a name="toc_Document-Structure" href="Document-Structure.html#Document-Structure">2 Document Structure</a>
  17. <li><a name="toc_Tables" href="Tables.html#Tables">3 Tables</a>
  18. <li><a name="toc_Hyperlinks" href="Hyperlinks.html#Hyperlinks">4 Hyperlinks</a>
  19. <li><a name="toc_TODO-Items" href="TODO-Items.html#TODO-Items">5 TODO Items</a>
  20. <li><a name="toc_Tags" href="Tags.html#Tags">6 Tags</a>
  21. <li><a name="toc_Properties-and-Columns" href="Properties-and-Columns.html#Properties-and-Columns">7 Properties and Columns</a>
  22. <li><a name="toc_Dates-and-Times" href="Dates-and-Times.html#Dates-and-Times">8 Dates and Times</a>
  23. <li><a name="toc_Capture" href="Capture.html#Capture">9 Capture</a>
  24. <li><a name="toc_Agenda-Views" href="Agenda-Views.html#Agenda-Views">10 Agenda Views</a>
  25. <li><a name="toc_Embedded-LaTeX" href="Embedded-LaTeX.html#Embedded-LaTeX">11 Embedded LaTeX</a>
  26. <li><a name="toc_Exporting" href="Exporting.html#Exporting">12 Exporting</a>
  27. <li><a name="toc_Publishing" href="Publishing.html#Publishing">13 Publishing</a>
  28. <li><a name="toc_Miscellaneous" href="Miscellaneous.html#Miscellaneous">14 Miscellaneous</a>
  29. <li><a name="toc_Hacking" href="Hacking.html#Hacking">A Hacking</a>
  30. <li><a name="toc_History-and-Acknowledgments" href="History-and-Acknowledgments.html#History-and-Acknowledgments">B History and Acknowledgments</a>
  31. <li><a name="toc_Main-Index" href="Main-Index.html#Main-Index">Main Index</a>
  32. <li><a name="toc_Key-Index" href="Key-Index.html#Key-Index">Key Index</a>
  33. </li></ul>
  34. </div>
  35. </div>
  36. </div>
  37. EOF
  38. $script = <<'EOF';
  39. </style><link rel="stylesheet" href="http://orgmode.org/org.css" type="text/css" />
  40. <script type="text/javascript" src="http://orgmode.org/org-keys.js"></script>
  41. <script type="text/javascript">
  42. <!--/*--><![CDATA[/*><!--*/
  43. OrgKeyReader.registerHref('h', 'index.html');
  44. OrgKeyReader.registerHref('t', 'index.html');
  45. /*]]>*/-->
  46. </script>
  47. EOF
  48. while ($page = shift) {
  49. system "mv $page $page.orig";
  50. open IN,"<$page.orig" or die "Cannot read from $page.orig\n";
  51. undef $/;
  52. $all = <IN>;
  53. close IN;
  54. $all =~ s/<meta http-equiv="Content-Style-Type" content="text\/css">/$&\n$script/;
  55. $all =~ s/^<body>/<body onload="OrgKeyReader.init();">\n$contents/m;
  56. open OUT,">$page" or die "Cannot write to $page\n";
  57. print OUT $all;
  58. close OUT;
  59. system "rm $page.orig";
  60. }