fakehtml.sty 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 1997, by Michael Van Canneyt
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \ProvidesPackage{fakehtml}[2001/07/01]
  22. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  23. % based upon Eijkhout's comment.sty v2.0
  24. % with modifications to avoid conflicts with later versions
  25. % of this package, should a user be requiring it.
  26. % Ross Moore, 10 March 1999
  27. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  28. % Comment.sty version 2.0, 19 June 1992
  29. % selectively in/exclude pieces of text: the user can define new
  30. % comment versions, and each is controlled separately.
  31. % This style can be used with plain TeX or LaTeX, and probably
  32. % most other packages too.
  33. %
  34. % Examples of use in LaTeX and TeX follow \endinput
  35. %
  36. % Author
  37. % Victor Eijkhout
  38. % Department of Computer Science
  39. % University Tennessee at Knoxville
  40. % 104 Ayres Hall
  41. % Knoxville, TN 37996
  42. % USA
  43. %
  44. % [email protected]
  45. %
  46. % Usage: all text included in between
  47. % \comment ... \endcomment
  48. % or \begin{comment} ... \end{comment}
  49. % is discarded. The closing command should appear on a line
  50. % of its own. No starting spaces, nothing after it.
  51. % This environment should work with arbitrary amounts
  52. % of comment.
  53. %
  54. % Other 'comment' environments are defined by
  55. % and are selected/deselected with
  56. % \includecomment{versiona}
  57. % \excludecoment{versionb}
  58. %
  59. % These environments are used as
  60. % \versiona ... \endversiona
  61. % or \begin{versiona} ... \end{versiona}
  62. % with the closing command again on a line of its own.
  63. %
  64. % Basic approach:
  65. % to comment something out, scoop up every line in verbatim mode
  66. % as macro argument, then throw it away.
  67. % For inclusions, both the opening and closing comands
  68. % are defined as noop
  69. %
  70. % Changed \next to \html@next to prevent clashes with other sty files
  71. % ([email protected])
  72. % Changed \html@next to \htmlnext so the \makeatletter and
  73. % \makeatother commands could be removed (they were causing other
  74. % style files - changebar.sty - to crash) ([email protected])
  75. % Changed \htmlnext back to \html@next...
  76. \def\makeinnocent#1{\catcode`#1=12 }
  77. \def\csarg#1#2{\expandafter#1\csname#2\endcsname}
  78. \def\ThrowAwayComment#1{\begingroup
  79. \def\CurrentComment{#1}%
  80. \let\do\makeinnocent \dospecials
  81. \makeinnocent\^^L% and whatever other special cases
  82. %%RRM
  83. %% use \xhtmlComment for \xComment
  84. %% use \html@next for \next
  85. \endlinechar`\^^M \catcode`\^^M=12 \xhtmlComment}
  86. {\catcode`\^^M=12 \endlinechar=-1 %
  87. \gdef\xhtmlComment#1^^M{\def\test{#1}\edef\test{\meaning\test}
  88. \csarg\ifx{PlainEnd\CurrentComment Test}\test
  89. \let\html@next\endgroup
  90. \else \csarg\ifx{LaLaEnd\CurrentComment Test}\test
  91. \edef\html@next{\endgroup\noexpand\end{\CurrentComment}}
  92. \else \csarg\ifx{LaInnEnd\CurrentComment Test}\test
  93. \edef\html@next{\endgroup\noexpand\end{\CurrentComment}}
  94. \else \let\html@next\xhtmlComment
  95. \fi \fi \fi \html@next}
  96. }
  97. %%\def\includecomment %%RRM
  98. \def\htmlincludecomment
  99. #1{\expandafter\def\csname#1\endcsname{}%
  100. \expandafter\def\csname end#1\endcsname{}}
  101. %%\def\excludecomment %%RRM
  102. \def\htmlexcludecomment
  103. #1{\expandafter\def\csname#1\endcsname{\ThrowAwayComment{#1}}%
  104. {\escapechar=-1\relax
  105. \edef\tmp{\string\\end#1}%
  106. \csarg\xdef{PlainEnd#1Test}{\meaning\tmp}%
  107. \edef\tmp{\string\\end\string\{#1\string\}}%
  108. \csarg\xdef{LaLaEnd#1Test}{\meaning\tmp}%
  109. \edef\tmp{\string\\end \string\{#1\string\}}%
  110. \csarg\xdef{LaInnEnd#1Test}{\meaning\tmp}%
  111. }}
  112. %%\excludecomment{comment} %%RRM
  113. \htmlexcludecomment{comment}
  114. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  115. % end Comment.sty
  116. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  117. \let\includecomment=\htmlincludecomment
  118. \let\excludecomment=\htmlexcludecomment
  119. \newcommand{\latex}[1]{#1}
  120. \newcommand{\html}[1]{}
  121. \htmlexcludecomment{htmlonly}
  122. \newenvironment{latexonly}{}{}