How to customize In-Dexter #index function?

Hi,

I would like to have a word-index in my document, so I included dexter with:
#import "@preview/in-dexter:0.7.2": *

I now can use #index[some words] to fill the index. So far, so good. But because #index is a little bit long and it makes a difference (for dexter) if I write #index[SoMe WoRdS] or #index[some words], which gives two different entries, I thought it to be a good idea to write a little wrapper to lower-case the entries:

#let I( string ) = {
    let stringLower = lower( string )
    index( stringLower )
    string
}

The result however is a little bit unexpected. I still can see the “indexed” words in my document (for example #I[blah] on page 11 will lead to an entry for page 11, but the word is an empty string). Result: In the index there now is just a single empty (“”) entry, showing all page numbers of all words in one line…

I am relatively new to Typst and have to admit, that this puzzles me. So, I would like not only to know how to fix it but also, why this happens. For sure I am doing something stupid…

Stefan

By using square brackets (#index[...]), the function receives content not string (would be #index("...")). Typst does not allow converting content to string, in-dexter still tries to do it, but the conversion doesn’t cover all possible cases which result in the empty entry. There is an open issue about it, see #34.
You can call your function I("SoMe WoRdS") with a string then in-dexter doesn’t try to convert the parameter.

Many thanks for the solution and the explaination!