[Foxet] Support for &entities (and undescore)

Hans Hagen pragma at wxs.nl
Wed Jan 19 20:02:45 CET 2005


Adam Lindsay wrote:

> Okay, agreed on that point.
> Foxet handles the basic set of entities well, AFAIK (that is, they're
> handled well in the underlying ConTeXt XML layer), so & will work.
> 
> For decimal number character entities, I've been advising the following
> patch (added to cont-new.tex, for example):
> \def\executeXMLdeccharacter#1\relax % 
>   {\utfunifontglyph{#1}}
> 
> I couldn't quite get it right for the hexadecimal entities (“),
> however.

I now have this code (you can add that to cont-new.tex if needed):

\def\executeXMLcharacter#1#2\relax
   {\if#1x%
      \@EA\noexecuteXMLhexcharacter
    \else
      \@EA\doexecuteXMLdeccharacter
    \fi#1#2\relax}

\def\noexecuteXMLhexcharacter x#1\relax
   {\uppercase{\doexecuteXMLhexcharacter#1\relax}}

\unexpanded\def\getXMLcharacter#1%
   {\ifXMLrawentities
      \@EA\firstofoneargument
    \else\ifcsname\@@XMLentity:#1\endcsname
      \@EAEAEA\getXMLentity
    \else
      \@EAEAEA\unicodechar % was: \rawcharacter
    \fi\fi{#1}}

\def\doexecuteXMLhexcharacter#1\relax{\getXMLcharacter{"#1}}
\def\doexecuteXMLdeccharacter#1\relax{\getXMLcharacter {#1}}

section of mail for adam -) :

the old code originates from before the time we had those unicode vector files; 
this mechanism still permits overloading, like

\defineXMLentity [1234]  {Adam}
\defineXMLentity ["1234] {Eve}

and since we dislike the " there, we can better define:

\unexpanded\def\getXMLdeccharacter#1%
   {\ifXMLrawentities
      \@EA\firstofoneargument
    \else\ifcsname\@@XMLentity:#1\endcsname
      \@EAEAEA\getXMLdecentity
    \else
      \@EAEAEA\unicodechar
    \fi\fi{#1}}

\unexpanded\def\getXMLhexcharacter#1%
   {\ifXMLrawentities
      \@EA\firstofoneargument
    \else\ifcsname\@@XMLentity:x#1\endcsname
      \@EAEAEA\getXMLhexentity
    \else
      \@EAEAEA\unicodehexchar
    \fi\fi{#1}}

\def\unicodehexchar#1%
   {\unicodechar{"#1}}

\let\getXMLcharacter\getXMLdeccharacter

\def\getXMLdecentity#1{\getXMLentity {#1}}
\def\getXMLhexentity#1{\getXMLentity{x#1}}

\def\doexecuteXMLhexcharacter#1\relax{\getXMLhexcharacter{#1}}
\def\doexecuteXMLdeccharacter#1\relax{\getXMLdeccharacter{#1}}

\defineXMLentity[8218] {Adam}
\defineXMLentity[x007D]{Eve}

now it works nicely

\starttext

\startbuffer
@ ‘ ‚ “ ” „•
&
$ { }   …
\stopbuffer

\typebuffer

\processXMLbuffer



Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the Foxet mailing list