At 09:37 AM 11/27/2001 +0100, Taco Hoekwater wrote:
>"Hans Hagen" <[EMAIL PROTECTED]> wrote:
> > At 03:20 PM 11/26/2001 +0100, Patrick Gundlach wrote:
> > >Hi,
> > >
> > >xml comments have a bug (!?): spaces are critical at the
> > >beginning of a comment.
> >
> > you may try (and play with):
> >
> > \long\def\xparseXMLescape !#1#2#3{\parseXMLescape{#1#2}#3}
>
>Adding #3 is safe, sort of. <! is always followed by one of the language's
>keywords, and <!-- is by far the shortest of those. Just watch out
>that <!----> is a valid comment (although very unlikely to appear).
>
>The string "<!-- crap -->" is actually a comment that starts with
>a space. The comment itself in this case is: " crap ".
>
>It is possible to take advantage of the fact that '<!--' is the only
>keyword that starts with the same character twice, so the 'best' thing
>to do is something along these lines:
>
>\long\def\xparseXMLescape!#1#2%
> {\if#1#2%
> \@EA\handleXMLcomment
> \else
> \@EA\doxparseXMLescape
> \fi#1#2}
>
>\def\handleXMLcomment--#1-->{}
>
>\def\doxparseXMLescape#1 {\parseXMLescape{#1}}
yesterday i found out that i needed both alternatives , so i came up with:
\long\def\xparseXMLescape !#1#2%
{\if#1-%
\if#2-%
\expandafter\expandafter\expandafter\xxparseXMLescape
\else
\expandafter\expandafter\expandafter\xyparseXMLescape
\fi
\else
\expandafter\xyparseXMLescape
\fi#1#2}
\long\def\xxparseXMLescape --#1{\parseXMLescape{--}#1}
\long\def\xyparseXMLescape #1 {\parseXMLescape{#1}}
so far this one works ok.
indeed, if we assume that #1 and #1 are the same and -, we can have a
faster alternative, but we may want to play safe. How does this keyword
mechanism work? Are there only officially registered ones?
Hans
-------------------------------------------------------------------------
Hans Hagen | PRAGMA ADE | [EMAIL PROTECTED]
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------