4
0

convtexi.pl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 © 1996 Free Software Foundation, Inc.
  6. # François Pinard <[email protected]>, 1996.
  7. $_ = <>;
  8. while ($_)
  9. {
  10. if (/^\@c()$/ || /^\@c (.*)/ || /^\@(include .*)/)
  11. {
  12. if ($topseen)
  13. {
  14. print "\@format\n";
  15. print "\@strong{\@\@c} $1\n";
  16. $_ = <>;
  17. while (/\@c (.*)/)
  18. {
  19. print "\@strong{\@\@c} $1\n";
  20. $_ = <>;
  21. }
  22. print "\@end format\n";
  23. }
  24. else
  25. {
  26. $delay .= "\@format\n";
  27. $delay .= "\@strong{\@\@c} $1\n";
  28. $_ = <>;
  29. while (/\@c (.*)/)
  30. {
  31. $delay .= "\@strong{\@\@c} $1\n";
  32. $_ = <>;
  33. }
  34. $delay .= "\@end format\n";
  35. }
  36. }
  37. elsif (/^\@chapter /)
  38. {
  39. print;
  40. # print $delay;
  41. $delay = '';
  42. $topseen = 1;
  43. $_ = <>;
  44. }
  45. elsif (/^\@macro /)
  46. {
  47. $_ = <> while ($_ && ! /^\@end macro/);
  48. $_ = <>;
  49. }
  50. elsif (/^\@set ([^ ]+) (.*)/)
  51. {
  52. $set{$1} = $2;
  53. $_ = <>;
  54. }
  55. elsif (/^\@UNREVISED/)
  56. {
  57. print "\@quotation\n";
  58. print "\@emph{(This message will disappear, once this node is revised.)}\n";
  59. print "\@end quotation\n";
  60. $_ = <>;
  61. }
  62. else
  63. {
  64. while (/\@value{([^\}]*)}/)
  65. {
  66. if (defined $set{$1})
  67. {
  68. $_ = "$`$set{$1}$'";
  69. }
  70. else
  71. {
  72. $_ = "$`\@strong{<UNDEFINED>}$1\@strong{</UNDEFINED>}$'";
  73. }
  74. }
  75. while (/\@FIXME-?([a-z]*)\{/)
  76. {
  77. $tag = $1 eq '' ? 'fixme' : $1;
  78. $tag =~ y/a-z/A-Z/;
  79. print "$`\@strong{<$tag>}";
  80. $_ = $';
  81. $level = 1;
  82. while ($level > 0)
  83. {
  84. if (/([{}])/)
  85. {
  86. if ($1 eq '{')
  87. {
  88. $level++;
  89. print "$`\{";
  90. $_ = $';
  91. }
  92. elsif ($level > 1)
  93. {
  94. $level--;
  95. print "$`\}";
  96. $_ = $';
  97. }
  98. else
  99. {
  100. $level = 0;
  101. print "$`\@strong{</$tag>}";
  102. $_ = $';
  103. }
  104. }
  105. else
  106. {
  107. print;
  108. $_ = <>;
  109. }
  110. }
  111. }
  112. print;
  113. $_ = <>;
  114. }
  115. }
  116. exit 0;