[sword-devel] Best way to encode interlinear texts in OSIS?

Karl Kleinpaste karl at kleinpaste.org
Thu Aug 9 07:57:19 MST 2007

DM Smith <dmsmith555 at yahoo.com> writes:
> Different question:
> How would one display an interlinear in HTML?
> The key requirement is that a line of stacked text would naturally wrap, 
> responding to window resizes in an expected way.

GnomeSword has solved this problem, though for Strong's and morph, not
for interlinear purposes.  Troy has suggested I look into the
possibility of an actual dynamic interlinear implementation using KJV's
Strong's with src="" data, but I'm afraid my masochism has limits.  And
it would be CPU-expensive.


The basic principle requires CSS support, and is a major reason why
GnomeSword is becoming GtkMozEmbed-capable (along with the desire for
things like superscripted note/xref indicators, as well as double-spaced
display and underline-less links), though maintaining backward
compatibility with gtkhtml3.

In essence, for my "blocked" implementation of Strong's and morph:

#define HTML_START "<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"><STYLE type=\"text/css\"><!-- A { text-decoration:none } %s --></STYLE></head>"

Note the %s above:

// CSS style blocks to control blocked strongs+morph output
// BOTH is when the user wants to see both types of markup.
// ONE is when he wants one or the other, so we can use a single
// specification which overlays both on top of one another.
#define CSS_BLOCK_BOTH \
" *        { line-height: 3.5em; }" \
" .word    { position: relative; }" \
" .strongs { position: absolute; top: 0.3em; left: 0 }" \
" .morph   { position: absolute; top: 1.3em; left: 0 }"
#define CSS_BLOCK_ONE \
" *        { line-height: 2.7em; }" \
" .word    { position: relative; }" \
" .strongs { position: absolute; top:  0.6em; left: 0 }" \
" .morph   { position: absolute; top:  0.6em; left: 0 }"

Then the generated HTML takes this form:

<span class="word">
    <span class="strongs">1984</span>
    <span class="morph">N-GSF</span>

The "word" content controls spacing and line-flow behavior, with the
Strong's and morph coming along for the ride.

In practice, it's enormously more complicated due to the embedded
hotlinks around the Strong's and morph content:

<span class="word">bishop&nbsp;&nbsp;<span class="strongs"><small><em><a href="passagestudy.jsp?action=showStrongs&type=Greek&value=1984">1984</a></em></small></span><span class="morph"><small><em><a href="passagestudy.jsp?action=showMorph&type=robinson%3AN-GSF&value=N-GSF">N-GSF</a></em></small></span></span>

Further complication is raised due the need to manufacture extra
spacing, because some short words have references attached which are
much longer, especially Robinson's codes, which is why you see the use
of &nbsp; after "bishop"; also see "ruleth" in the screenshot, v.4, for
an example of a very long Robinson's requiring much extra spacing.  I've
got a crude heuristic for how to get "enough" spacing.  It's imprecise,
but works pretty well in practice.

The last level of complication is raised by the need to handle the case
where there are multiple Strong's or morph in a row, without intervening
English, for which state must be maintained to know whether an
artificial placeholder "word" must be inserted.  You can see this in the
screenshot on the word "bishop" in v.2 -- the KJV markup really is that
way, "A bishop" followed by G3588 + G1985.

The same concept could be extended to include a <span class="greek">
component, though the set of formatting cases in need of being covered
is multiplicative.


More information about the sword-devel mailing list