Cross-references in Reference Bible

Hello all,

I’d like to ask your help to make a Reference Bible.
We have a Bible text with cross-refenreces.

In default the order of cross reference is
“callee - verse number - references”
like “a 1 Ps 102:25; Is 40:21; John 1:1,2; Heb 1:10”

I want to change it to put the chapter first, then getting together all callees under the same verse, like ordinary reference Bibles, like
“Chapter 1
1 a Ps 102:25; Is 40:21; John 1:1,2; Heb 1:10 b Psa 89:11; 90:2; Acts 17:24; Rom 1:20; Heb 11:3 c Job 38:4…”

I think some scripts are needed. Does someone has any help?

Hmm. Yes, this can almost certainly only be done by preprocessing the code. The first in the chapter gets additional ‘Chapter’ text and so on. Trying to do this in the TeX would be very hard.

Assuming that you will re-run the process any time you use selections from the text, then it should work OK. The current code works by building a trigger list to apply the external lists, which holds entries like this:

\AddTrigger MAT28.15
\x - \xo 28:15 \xt Mt 9:31; 27:8\x*
\EndTrigger

\AddTrigger MAT28.19
\x - \xo 28:19 \xt Mt 13:52; 24:14; Mk 16:15-16; Lk 24:47; Acts 1:8; 2:38; 8:16; 14:21; Rom 6:3; 1 Cor 1:13; 2 Cor 13:14; Gal 3:27\x*
\EndTrigger

You can make your own trigger files instead of letting python do it with whatever text manipulation program you like - perl, python, or even sed would be things I’d consider, from the unix world.
Quite what you’d put into the USFM portion of the file to generate the format you want, I’m not 100% certain. There shouldn’t be a problem with having multiple triggers on one
verse, so you don’t need to merge your lines together, but I expect you’ll need some custom markers to generate the superscripted calees.

But I’ve been assuming you don’t want callers in the text, am I wrong about that? Your example has them… How does the reader connect the callee with the word? Do you actually want to merge your xrefs into the middle of the Biblical text? I expect that would need to be a manual or at best semi-manual process.

Hello,

I think my explanation was not enough.
Our text has cross-references in the middle of the text, like

\v 1 \x + \xo 1:1 \xt Иох 1:1,2; Евр 1:10\xЭхэнд \x + \xo 1:1 \xt Дуу 8:3; 33:6; 89:11,12; 102:25; 136:5; 146:6; Иса 44:24; Иер 10:12; 51:15; Зех 12:1; Үйл 14:15; 17:24; Кол 1:16,17; Евр 11:3; Илч 4:11; 10:6\xБурхан тэнгэр ба газрыг бүтээжээ.

Then, the result is like this:
タイトルなし

So, my question is changing order and merging callees ouder the same verse.

So, if I can restate what I understand now… what you want to do is process the \xo data doing the following:

  1. Prepend to the current note a null note with the (annontated) chapter if that is different to the last one. (e.g. \x - \xo Chapter 2\x* \x + \xo 1 \xt ...\*)
  2. Only print the verse number if that is different to the last reference.
  3. Entirely delete the \xo entry if it is identical to the last one.

I’m sure I could write this in perl, but don’t know python well enough. Whether you want a perl script or not would depend on things like what OS you and your colleagues are running on (perl is almost certainly available on linux, but not, I believe, normally on windows).

Yes, exactly.
I use Perl on Windows, so make a perl script for that, please.
Thank you.

This seems to work. You’ll have to replace the first line with whatever is needed on windows.

#!/usr/bin/perl -w
# This little script answers a request https://community.scripture.software.sil.org/t/cross-references-in-reference-bible/3470/2 "
# * Prepend to the current note a null note with the (annontated) chapter if that is different to the last one. (e.g. \x - \xo Chapter 2\x* \x + \xo 1 \xt ...\*)
# * Only print the verse number if that is different to the last reference.
# * Entirely delete the \xo entry if it is identical to the last one.
#
# It assumes that all xo entries are in the format chapter:verse, and that verses in xref \xo entries are only numeric. 

use strict;
my $chapter='';
my $verse='';

$\=''; # Swallow whole file as one chunk
$/='';
sub beautify {
        my ($c,$v)=@_;
        if ($c ne $chapter) {
                $chapter=$c;
                $verse='';
                print "\\x - \\xo Chapter $c\\x*";
        }
        if ($v ne $verse) {
                $verse=$v;
                "\\xo $v";
        }
}

while(my $file=(<>)) {
        foreach my $chunk (split(/(\\x.*?\\x\*)/, $file)) {
                $chunk=~s/\\xo (\d+):(\d+)/beautify($1,$2)/e;
                print $chunk;
        }
}

Thank you. Your script works well on Windows without any issues.
The result is this:
タイトルなし
Now, I want to change the order. The result so far is
“callee - verse number - references” like “а 1 Иох 1:1,2; Евр 1:10”,
I want
“verse number - callee - references” like “1 а Иох 1:1,2; Евр 1:10” as in my first post.
Also, can all callees in a same verse be in one line?
Do you have any ideas?

If you want to achieve this, you’ll need to do a bit of programming, to:

  1. Pull all the cross references from a verse into a single cross reference, either in the SFM or in a trigger file and then remove them from within the text
  2. Convert cross reference positions in the text into simple label points with a suitable fixed label (so it looks like a cross reference anchor, but there is no cross reference)
  3. Pull those same labels into the complex cross reference you have at the start of the verse.
  4. Turn off any callees both in the text and the note.

To contradict Martin (slightly), the script can probably be modified to give you something close. I’m not sure exactly how it’ll display, though. If you make it say:

     if ($v ne $verse) {
                $verse=$v;
                print "\\x - \\xo $v\\*";
        }

Then similar to how you get an empty footnote saying Chapter X, you’ll then get an empty footnote saying Y (at the first footnote on verse Y) and then the rest of the 1st footnote in that verse. Other footnotes won’t have a chapter or a verse number. BUT you will need to turn on paragraphed notes and probably need to alter some things like the inter-footnote spacing (I can’t remember what it’s called, but I think it’s in the user interface now). Once you’ve turned on paragraphed notes, you won’t be getting verse Y on its own line, unless you include some raw TeX commands in what the perl is spitting out. (prefixing the footnote contents for verse Y with \penalty -10000\space might be sufficient).

Probably, at some point in this exercise, then fudging it like this will reach its limits, and either Martin’s answer will become the right way to do it, or very significant changes to the TeX code (which would probably break other people’s projects) will be needed.

On the TeX side of things, you’d need to ‘hijack’ the \xo macro and make it interpret the chapter:verse parameters as values, before they enter the output stream, and then do the comparison and output redefinition in TeX. The danger is that if anyone had an \xo that wasn’t always followed by chapter:verse, and instead had chapter.verse or similar, the code would give strange and unexpected errors.
Defining robust macros in TeX is hard, and there is no standard that defines what people will put in \xo (nor a guarantee they only use it in cross-references!).
Thinking about it a bit more, it’d actually be far better to define your own macro with a defined terminator, that in turn resolved to \xo, rather than hijacking \xo.
e.g. \def\zmyxrefstyle#1:#2\*{comparisonde} to set any prefixes to the callee.
Of course, you’d still have to make the footnote caller generator code put the chapter number and / or verse number before the callee. I’m guessing it would take about a half a week of programming and debugging at the least, but there may be things I’ve forgotten that would push it unto a week or 3.

Without a very clear call from multiple users, it is unlikely that we will find the time to do this any time in the next year.