% Context file
% Filename: test-index.tex
% 
% 04-05-2011
% Copyright (c) 2011 BOEDE. All rights reserved.

\startluacode
function Indexing(text)
   local data = text
   data = (string.gsub(data, ",", "%+"))
   data = (string.gsub(data, "%+ ", "%+"))
   return data
end
\stopluacode

\def\IndexItems#1{\index{\cldcontext{Indexing("#1")}}}

\starttext
We start with some text and a single entry to the index.
\IndexItems{magnet}

We have then more text and two entries to the subindex
\IndexItems{magnet,electro}
\IndexItems{magnet, permanent}

Then we add non macro indexes:

\index{Glass lamp}
\index{Glass lamp+bulb}
\index{Glass lamp+bulb+wire}

These index entries show up as expected.


\blank 
Indexing with \type{\cldcontext}\dots
                             
\index{\cldcontext{Indexing("Bulb")}}
                                     
\index{\cldcontext{Indexing("Bulb, fitting")}}
\index{\cldcontext{Indexing("Bulb,connector")}}
\index{\cldcontext{Indexing("Motor")}}

\blank[3cm]

\placeregister[index]
\stoptext