Sorry, messed up something. New version followws:

\newbox\chemlowbox
\def\chemlow#1%
   {\setbox\chemlowbox\hbox{{\switchtobodyfont[small]#1}}}

\def\chemhigh#1%
   {\ifvoid\chemlowbox \high{{\switchtobodyfont[small]#1}}%
    \else \lohi[left]{\box\chemlowbox}{{\switchtobodyfont[small]#1}}\fi }

\def\finishchem{\ifvoid\chemlowbox \else \low{\box\chemlowbox}\fi}

\unexpanded\def\molecule%
   {\bgroup
    \catcode`\_=\active \uccode`\~=`\_ \uppercase{\let~\chemlow}%
    \catcode`\^=\active \uccode`\~=`\^ \uppercase{\let~\chemhigh}%
    \dostepwiserecurse {65}{90}{1}
       {\catcode \recurselevel = \active
        \uccode`\~=\recurselevel
        \uppercase{\edef~{\noexpand\finishchem 
\rawcharacter{\recurselevel}}}}%
    \catcode`\-=\active \uccode`\~=`\- \uppercase{\def~{--}}%
    \domolecule }%

\def\domolecule#1{#1\finishchem\egroup}

\starttext
{\bf A test \variant[Caps] in small caps}

\molecule{HSO_4^{-}}
\molecule{H_2SO_4}

{\bfa A story about \molecule{SF_6}}
{\scx A story about \molecule{sf_6}}
{\bsb A story about \molecule{SF_6}}


\stoptext
_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to