# [l2h] Temporarily redefining '~', or "Which environment am I in?"

Igor Pechtchanski pechtcha at cs.nyu.edu
Tue Dec 28 00:17:02 CET 2004

Hi,

I'm trying to restore ~ to its original meaning (i.e., the '~' character)
within a particular environment (\begin{CodeBox}...\end{CodeBox}, which is
an 'alltt' environment, so there's no need for a separate unbreakable
space).  It's rather easy to redefine ~'s everywhere (with something like

sub pre_pre_process { s/(^|[^\\])\~/\$1;spiTILDE;/g; }  # [1]
sub post_post_process { s/;spiTILDE;/\~/g; }

in .latex2html-init).  However, this also breaks legitimate uses of ~
outside of the environment.

A further difficulty is that the environment is defined in LaTeX, not as a
do_env_CodeBox() function, so I can't just add the above command ([1]) to
the right function...  FWIW, it would probably be too much work to
redefine the whole environment in Perl.

So, does anyone know of a way to do the above substitution ([1]) only
within the CodeBox environment, or, alternatively, have a callback of
sorts that would be executed for every CodeBox environment that doesn't
have to redefine all of its processing?  A way of invoking the latex2html
default processing from the callback would do it as well.

Igor
P.S. My LaTeX code for CodeBox does a \begingroup\catcode~=11...\endgroup
within the environment definition, so that's no help. :-(
--
http://cs.nyu.edu/~pechtcha/
|\      _,,,---,,_		pechtcha at cs.nyu.edu
ZZZzz /,.-''    -.  ;-;;,_		igor at watson.ibm.com
|,4-  ) )-,_. ,\ (  '-'		Igor Pechtchanski, Ph.D.
'---''(_/--'  -'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

`