Skip to content

USFM and stylesheets in Bibledit Desktop

Matt Postiff edited this page Sep 18, 2018 · 11 revisions

I produced these notes while debugging a problem with the \ili marker that would not work properly in Bibledit-Desktop. Evidently not all usfm is supported by Bibledit-Desktop if it is not in a certain stylesheet.

The following files are relevant:

  1. User directory ~/.bibledit/stylesheets/Standard.xml2 - this had no \ili in it.
  2. Source directory templates/stylesheet.xml - this had no \ili in it. It is the same as above, Standard.xml2. This file is copied to the package data dir, e.g. /usr/share/bibledit-desktop on Linux, to ~/.bibledit/stylesheets/Standard.xml2 by Bibledit in stylesheetutiles.cpp:stylesheet_create_new().
  3. Source directory templates/usfm.xml - this has \ili. This is read by usfmstandard.cpp
  4. Source directory usfm/usfm.sty - this has \ili, ili1, ili2 (version 2.208 updated Apr 21, 2009 Jeff Klassen)
  5. Source directory BiblesInternational/BI_usfm_005.sty (derived from 2.503, version 23 Apr 2018). Very similar to above, but over 100 diffs.

The \ili marker does not have an endmarker like \rq \rq* and many others.

To add the \ili marker, I had to add it to usfmtools.cpp in the IntroductionOtherElements section.

And then also stylesheet.xml (#2 above) which will get copied to Standard.xml2 (#1 above). But it will only be copied if the Standard.xml2 is first erased, and you do a make install from bibledit-desktop to copy the new stylesheet.xml from the build directory into the /usr/share/bibledit-desktop directory (which is where bibledit takes a copy from to put into the user's directory).

Make sure to change the first four lines of the style.

<style marker="ili2">

<marker>ili2</marker>

<name translatable="yes">Introduction List Entry Level 2</name>

<info translatable="yes">An introduction list entry, level 2</info>

That all is still not enough to get Bibledit-Desktop to recognize the new style.

Then, you have to add the new marker to check_validate_usfm.cpp and any checks that it needs (in at least two places). This should not be necessary, or, perhaps better said, there should be a way that this can all be based on the xml description file for usfm so it is easier to upgrade new markers.

You also have to make sure the marker is in usfmtools.cpp. (Yes, this is all too much and too confusing. It needs to be simplified so there is a one-stop shop for adding USFM codes to the program.) If you go into Styles window, and File | Styles | Edit mode and double click Headings \ rq Inline quotation references, you will see that its information is messed up in the large dialog box. It doesn't say that it has an endmarker.

Now about the \rq marker, I added a check in check_validate_usfm.cpp to make sure that it has an endmarker. That works well. But when I manually added \rq* everywhere it needs to be, it shows up in the formatted text view, as well as the USFM view. So for some reason, Bibledit-Desktop doesn't understand that it is an endmarker.

The solution to this is to first check usfm.xml. It says that rq hasendmarker="yes". And though there are a few of these, one particular translation I examined had only two markers that actually have endmarkers: \qt..\qt* and \rq..\rq*. The problem was in Standard.xml2 (from stylesheet.xml) that had rq as a type 3 subtype 3 (paragraph type) instead of a character type 4, inline text.

I realized that I don't know what the type and subtype numbers mean in the stylesheet.xml. type is from enum style.h::StyleType.

Clone this wiki locally