mansplit.pl 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. <p>This is the official manual for the latest <a href="https://orgmode.org">Org-mode</a> release.</p>
  12. <h2>Table of Contents</h2>
  13. <div id="text-table-of-contents">
  14. <ul>
  15. <li><a name="Top" href="index.html#Top">Org Mode Manual</a>
  16. <li><a name="Introduction" href="Introduction.html#Introduction">1 Introduction</a>
  17. <li><a name="Document-Structure" href="Document-Structure.html#Document-Structure">2 Document Structure</a>
  18. <li><a name="Tables" href="Tables.html#Tables">3 Tables</a>
  19. <li><a name="Hyperlinks" href="Hyperlinks.html#Hyperlinks">4 Hyperlinks</a>
  20. <li><a name="TODO-Items" href="TODO-Items.html#TODO-Items">5 TODO Items</a>
  21. <li><a name="Tags" href="Tags.html#Tags">6 Tags</a>
  22. <li><a name="Properties-and-Columns" href="Properties-and-Columns.html#Properties-and-Columns">7 Properties and Columns</a>
  23. <li><a name="Dates-and-Times" href="Dates-and-Times.html#Dates-and-Times">8 Dates and Times</a>
  24. <li><a name="Capture" href="Capture-_002d-Refile-_002d-Archive.html#Capture-_002d-Refile-_002d-Archive">9 Capture-Refile-Archive</a>
  25. <li><a name="Agenda-Views" href="Agenda-Views.html#Agenda-Views">10 Agenda Views</a>
  26. <li><a name="Markup" href="Markup.html#Markup">11 Markup</a>
  27. <li><a name="Exporting" href="Exporting.html#Exporting">12 Exporting</a>
  28. <li><a name="Publishing" href="Publishing.html#Publishing">13 Publishing</a>
  29. <li><a name="Working-With-Source-Code" href="Working-With-Source-Code.html#Working-With-Source-Code">14 Source Code</a>
  30. <li><a name="Miscellaneous" href="Miscellaneous.html#Miscellaneous">15 Miscellaneous</a>
  31. <li><a name="Hacking" href="Hacking.html#Hacking">A Hacking</a>
  32. <li><a name="MobileOrg" href="MobileOrg.html#MobileOrg">B MobileOrg</a>
  33. <li><a name="History-and-Acknowledgments" href="History-and-Acknowledgments.html#History-and-Acknowledgments">C History and Thanks</a>
  34. <li><a name="Main-Index" href="Main-Index.html#Main-Index">Main Index</a>
  35. <li><a name="Key-Index" href="Key-Index.html#Key-Index">Key Index</a>
  36. <li><a name="Variable-Index" href="Variable-Index.html#Variable-Index">Variable Index</a>
  37. </li></ul>
  38. </div>
  39. </div>
  40. </div>
  41. EOF
  42. $script = <<'EOF';
  43. <link rel="stylesheet" href="https://orgmode.org/org-manual.css" type="text/css" />
  44. <script src="https://orgmode.org/org-keys.js"></script>
  45. <script>
  46. <!--/*--><![CDATA[/*><!--*/
  47. OrgKeyReader.registerHref('h', 'index.html');
  48. OrgKeyReader.registerHref('t', 'index.html');
  49. /*]]>*/-->
  50. </script>
  51. EOF
  52. while ($page = shift) {
  53. system "mv $page $page.orig";
  54. open IN,"<$page.orig" or die "Cannot read from $page.orig\n";
  55. undef $/;
  56. $all = <IN>;
  57. close IN;
  58. $all =~ s/<meta http-equiv="Content-Style-Type" content="text\/css">/$&\n$script/;
  59. $all =~ s/^<body>/<body onload="OrgKeyReader.init();">\n$contents/m;
  60. open OUT,">$page" or die "Cannot write to $page\n";
  61. print OUT $all;
  62. close OUT;
  63. system "rm $page.orig";
  64. }