ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: John Grasty <johnpgrasty@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Custom sorting of "pseudo-language" in a register
Date: Fri, 16 Mar 2018 16:15:48 +0100	[thread overview]
Message-ID: <A4932737-2FA6-4657-917B-3B918E7CEAA2@gmail.com> (raw)

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/

- - - -

\startluacode

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
    }
}
\stopluacode

\mainlanguage[sl]

\defineregister[booksort]
\setupregister[booksort]
 [language=bbt,
  n=1,
  indicator=yes,
  ]
  

\starttext

\booksort{Janez+5.2}One
\booksort{Eksodus+2}Two
\booksort{Geneza+45}Three

\page

\placeregister[booksort][language=bbt]

\stoptext
 











___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

             reply	other threads:[~2018-03-16 15:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-16 15:15 John Grasty [this message]
     [not found] ` <CAG5iGsCskySkdFZmOiM6J9PhpiPsZtAkxN-ZqjfmeNgjS=yg4Q@mail.gmail.com>
2018-03-22 18:50   ` Fwd: " Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A4932737-2FA6-4657-917B-3B918E7CEAA2@gmail.com \
    --to=johnpgrasty@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).