Re: Changing text "in place"

Subject: Re: Changing text "in place"
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 4 May 1999 10:29:29 +0100 (BST)

> I have a problem
> to get some characters that are "special" for LaTeX into a form that is
> acceptable (e.g., $, %, #, &, etc. have a special meaning). So the easiest
> would be to escape such characters when they get transferred

Actually for machine generated latex there is not really a lot of point
in leaving those with special meanings. I would just make all of those
normal letters in latex (ie \catcode`\$=12 etc) and not bother messing
around quoting stuff. Similarly

>  to the result tree, _if necessary_. The latter is important, since
> inside verbatim-like environments the characters can be used as-is, 

There is certainly no need to use verbatim environments for machine
generated latex. They are a minor aid to authoring but complicate
latex greatly and in this situation you just need to switch to
a monospaced font, you don't need to change all of latex's parsing


> Before I go off and write a set
> of Java routines using xt's extension mechanism, 

You can do string replacements just in XSLT without relying on

to change $ to \$ and % to \% and # to \#


<xsl:import href=""/>

<xsl:template match="/">
  <xsl:call-template name="string-replace">
    <xsl:param name="to" expr="'\$'"/>
    <xsl:param name="from" expr="'$'"/> 
    <xsl:param name="string">
      <xsl:call-template name="string-replace">
        <xsl:param name="to" expr="'\%'"/>
        <xsl:param name="from" expr="'%'"/> 
        <xsl:param name="string">
          <xsl:call-template name="string-replace">
            <xsl:param name="to" expr="'\#'"/>
            <xsl:param name="from" expr="'#'"/> 
            <xsl:param name="string" expr="."/>


would convert 

hello world (%) (#) ($)


hello world (\%) (\#) (\$)


 XSL-List info and archive:

Current Thread