[NTG-context] Custom sorting of "pseudo-language" in a register

John Grasty johnpgrasty at gmail.com
Fri Mar 16 16:15:48 CET 2018

Hello all,

I’m just getting acquainted with ConTeXt, and I am finding it so much more suitable for my work and needs. Thanks for the great software. Here’s my situation. I write in Slovene and in English, and I need to make numerous references to biblical passages. I want to create an index of these citations, but I want them in the order they appear in the Bible rather than alphabetical order. Henri Menke provided a perfectly workable solution on TeX StackExchange[^1], but because this is a multi-year project, I wanted to find a bit more permanent solution. I discovered I can use Lua LPEG to parse and normalize my citations so they are referenced in a uniform style.

My problem comes in the register sorting. Hans, I saw where in the paste you have recommended a “pseudo-language” to implement a custom sort in such a situation. I have almost figured out how to accomplish this. (See the MWE below.) I have no problem with single word sections (Genesis, Exodus, etc.). I can turn off indicators, do the custom sort (see below), and I get the intended result. If I have a multiple word title (Evangelij po Janezu), that technique doesn’t work. The replacement for more than one word (or if a number is involved, like 1John) doesn’t seem to work. I have no doubt there is a good reason; I’m just a newbie!

It seems my options are to:

1. Figure out how to do a replacement for a phrase or a book with a number in its name. Then this technique seems to work ok.
2. Or to add an entries and figure out some way to not print the first level in the index. So the indicator will be the book name, and underneath the chapter and verses will be listed with out the book name being repeated.

Are there any ideas to point me in the right direction?

Thanks so much for your help,
John Grasty

[1]: https://tex.stackexchange.com/questions/418575/custom-ordering-for-a-index-register-in-context/

- - - -


local utfchar, utfbyte  = utf.char, utf.byte
local sorters           = sorters
local definitions       = sorters.definitions
local replacementoffset = sorters.constants.replacementoffset
local variables         = interfaces.variables

local gen  = utfchar(replacementoffset + 1), utfchar(replacementoffset + 11)
local exo = utfchar(replacementoffset + 2), utfchar(replacementoffset + 220)
local jn = utfchar(replacementoffset + 4), utfchar(replacementoffset + 27)

sorters.definitions['bbt'] = {
    replacements = {
        { "Geneza", gen },
        { "Eksodus", exo }, 
        { "Janez", jn },

    orders = {
        gen, exo, jn








More information about the ntg-context mailing list