convtexi.pl 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #!/usr/local/bin/perl -- # -*-Perl-*-
  2. eval "exec /usr/local/bin/perl -S $0 $*"
  3. if 0;
  4. # Copy a Texinfo file, replacing @value's, @FIXME's and other gooddies.
  5. # Copyright (C) 1996, 2001 Free Software Foundation, Inc.
  6. #
  7. # This program is free software; you can redistribute it and/or modify it
  8. # under the terms of the GNU General Public License as published by the
  9. # Free Software Foundation; either version 2, or (at your option) any later
  10. # version.
  11. #
  12. # This program is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  15. # Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License along
  18. # with this program. If not, write to the Free Software Foundation, Inc.,
  19. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. # François Pinard <pinard@iro.umontreal.ca>, 1996.
  21. $_ = <>;
  22. while ($_)
  23. {
  24. if (/^\@c()$/ || /^\@c (.*)/ || /^\@(include .*)/)
  25. {
  26. if ($topseen)
  27. {
  28. print "\@format\n";
  29. print "\@strong{\@\@c} $1\n";
  30. $_ = <>;
  31. while (/\@c (.*)/)
  32. {
  33. print "\@strong{\@\@c} $1\n";
  34. $_ = <>;
  35. }
  36. print "\@end format\n";
  37. }
  38. else
  39. {
  40. $delay .= "\@format\n";
  41. $delay .= "\@strong{\@\@c} $1\n";
  42. $_ = <>;
  43. while (/\@c (.*)/)
  44. {
  45. $delay .= "\@strong{\@\@c} $1\n";
  46. $_ = <>;
  47. }
  48. $delay .= "\@end format\n";
  49. }
  50. }
  51. elsif (/^\@chapter /)
  52. {
  53. print;
  54. # print $delay;
  55. $delay = '';
  56. $topseen = 1;
  57. $_ = <>;
  58. }
  59. elsif (/^\@macro /)
  60. {
  61. $_ = <> while ($_ && ! /^\@end macro/);
  62. $_ = <>;
  63. }
  64. elsif (/^\@set ([^ ]+) (.*)/)
  65. {
  66. $set{$1} = $2;
  67. $_ = <>;
  68. }
  69. elsif (/^\@UNREVISED/)
  70. {
  71. print "\@quotation\n";
  72. print "\@emph{(This message will disappear, once this node is revised.)}\n";
  73. print "\@end quotation\n";
  74. $_ = <>;
  75. }
  76. else
  77. {
  78. while (/\@value{([^\}]*)}/)
  79. {
  80. if (defined $set{$1})
  81. {
  82. $_ = "$`$set{$1}$'";
  83. }
  84. else
  85. {
  86. $_ = "$`\@strong{<UNDEFINED>}$1\@strong{</UNDEFINED>}$'";
  87. }
  88. }
  89. while (/\@FIXME-?([a-z]*)\{/)
  90. {
  91. $tag = $1 eq '' ? 'fixme' : $1;
  92. $tag =~ y/a-z/A-Z/;
  93. print "$`\@strong{<$tag>}";
  94. $_ = $';
  95. $level = 1;
  96. while ($level > 0)
  97. {
  98. if (/([{}])/)
  99. {
  100. if ($1 eq '{')
  101. {
  102. $level++;
  103. print "$`\{";
  104. $_ = $';
  105. }
  106. elsif ($level > 1)
  107. {
  108. $level--;
  109. print "$`\}";
  110. $_ = $';
  111. }
  112. else
  113. {
  114. $level = 0;
  115. print "$`\@strong{</$tag>}";
  116. $_ = $';
  117. }
  118. }
  119. else
  120. {
  121. print;
  122. $_ = <>;
  123. }
  124. }
  125. }
  126. print;
  127. $_ = <>;
  128. }
  129. }
  130. exit 0;