Skip to content

Commit

Permalink
Add Laridian Book Builder export format
Browse files Browse the repository at this point in the history
This has been tested with Laridian Book Builder 2.1.0.624. Note that the
resulting Bibles cannot be opened in the current stable version of
Laridian Pocket Bible for Windows yet; to test on Windows you need to
remove the `pb_biblebooks` meta tag and convert for an older Laridian
version. Also, while interlinear bible export has been tested (in the
sense that the Book Builder does not show any errors), the resulting
Bible file cannot (yet) be tested in Laridian Pocket Bible for Windows
(no Interlinear books supported yet).

Therefore, treat this code with a grain of salt.

I will re-test this once the new Pocket Bible for Windows version has
been released.
  • Loading branch information
schierlm committed Apr 5, 2024
1 parent 9e33514 commit 0cd7922
Show file tree
Hide file tree
Showing 5 changed files with 798 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ In addition, the following other formats are supported, with varying accuracy:
- **[MySword](https://www.mysword.info/)**: import and export
- **[Obsidian](https://obsidian.md/)**: export only
- **[Beblia XML](https://beblia.com/)**: import and export
- **[Laridian Book Builder](https://www.laridian.com/): export only

In combination with third party tools, other export formats are available:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public Collection<Module<ExportFormat>> getExportFormats() {
result.add(new Module<ExportFormat>("LogosRenumberedDiffable", "Renumber named verses for Logos before exporting as Diffable.", LogosRenumberedDiffable.HELP_TEXT, LogosRenumberedDiffable.class));
result.add(new Module<ExportFormat>("AugmentLogosLinks", "Add values of Logos links to Extra Attributes of a Bible", AugmentLogosLinks.HELP_TEXT, AugmentLogosLinks.class));
result.add(new Module<ExportFormat>("LogosHTML", "HTML Export format for Logos Bible Software", LogosHTML.HELP_TEXT, LogosHTML.class));
result.add(new Module<ExportFormat>("LaridianPocketBibleExtendedInterlinear", "Export to Laridian Pocket Bible with Interlinear fields from Logos links", LaridianPocketBibleExtendedInterlinear.HELP_TEXT, LaridianPocketBibleExtendedInterlinear.class));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package biblemulticonverter.logos.format;

import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

import biblemulticonverter.data.Versification.Reference;
import biblemulticonverter.format.LaridianPocketBible;

public class LaridianPocketBibleExtendedInterlinear extends LaridianPocketBible {

public static final String[] HELP_TEXT = new String[LaridianPocketBible.HELP_TEXT.length + 2];

static {
HELP_TEXT[0] = "Export to Laridian Pocket Bible with Interlinear fields from Logos links";
for (int i = 1; i < LaridianPocketBible.HELP_TEXT.length; i++) {
HELP_TEXT[i] = LaridianPocketBible.HELP_TEXT[i];
}
HELP_TEXT[HELP_TEXT.length - 2] = "Additionally, any Logos link prefix can be used as interlinear type, by prefixing it with 'LogosLink:'.";
HELP_TEXT[HELP_TEXT.length - 1] = "You will need to edit the generate meta tag in the head, though.";
};

@Override
protected InterlinearType parseInterlinearType(int index, String type) {
if (type.startsWith("LogosLink:")) {
return new LogosLinkInterlinearType(index, type.substring(10));
}
return super.parseInterlinearType(index, type);
}

public static class LogosLinkInterlinearType extends InterlinearType<List<String>> {

private static final InterlinearTypePrecalculator<List<String>> LOGOS_LINK_PRECALCULATOR = new InterlinearTypePrecalculator<List<String>>() {
private final LogosLinksGenerator generator;
{
try {
generator = new LogosLinksGenerator();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}

public List<String> precalculate(boolean nt, Reference verseReference, char[] strongsPrefixes, int[] strongs, String[] rmac, int[] sourceIndices) {
return generator.generateLinks(nt, verseReference, strongsPrefixes, strongs, rmac, sourceIndices);
}
};

private final String linkPrefix;

protected LogosLinkInterlinearType(int index, String linkPrefix) {
super(LOGOS_LINK_PRECALCULATOR, "extra" + (index + 1), "Name for LogosLink:" + linkPrefix + " (edit me), , , , , , sync:\\\\, yes");
this.linkPrefix = linkPrefix;
}

@Override
protected List<String> determineValues(List<String> links, boolean nt, Reference verseReference, char[] strongsPrefixes, int[] strongs, String[] rmac, int[] sourceIndices) {
return links.stream().filter(l -> l.startsWith(linkPrefix)).map(l -> l.substring(linkPrefix.length())).collect(Collectors.toList());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public Collection<Module<ExportFormat>> getExportFormats() {
result.add(new Module<ExportFormat>("SwordSearcher", "Export format for SwordSearcher", SwordSearcher.HELP_TEXT, SwordSearcher.class));
result.add(new Module<ExportFormat>("Obsidian", "Export to Markdown for Obsidian (one chapter per file)", Obsidian.HELP_TEXT, Obsidian.class));
result.add(new Module<ExportFormat>("AugmentGrammar", "Analyze used Grammar information in one bible and augment another one from that data.", AugmentGrammar.HELP_TEXT, AugmentGrammar.class));
result.add(new Module<ExportFormat>("LaridianPocketBible", "Export to Laridian Pocket Bible", LaridianPocketBible.HELP_TEXT, LaridianPocketBible.class));
return result;
}

Expand Down

0 comments on commit 0cd7922

Please sign in to comment.