<h1 align="center">
  <a href="https://github.com/miguelms95/bible--core">
    Biblia 📖
  </a>
</h1>

<p align="center">
  Librería con la Biblia, open source!<br><br>
  Consulta los libros de la Biblia<br>
  Supports Node v18+, Modern Browsers (desktop and mobile).
</p>

<p align="center">
<a href="LICENSE">
    <img alt="License" src="https://img.shields.io/badge/license-MIT-blue?color=blue&style=flat">
</a>
<a href="https://www.npmjs.com/package/bible-core/v/latest" target="_blank" rel="noopener noreferrer">
    <img alt="latest" src="https://img.shields.io/npm/v/bible--core/latest?style=flat&logo=npm">
</a>
<a href="https://www.npmjs.com/package/bible-core/v/latest" target="_blank" rel="noopener noreferrer">
    <img alt="latest" src="https://img.shields.io/npm/dm/bible--core?label=downloads&logo=npm">
</a>
<a href="https://www.jsdelivr.com/package/npm/bible-core" target="_blank" rel="noopener noreferrer">
    <img alt="latest" src="https://data.jsdelivr.com/v1/package/npm/bible--core/badge?style=rounded">
</a>
<a href="https://bundlephobia.com/result?p=bible-core" target="_blank" rel="noopener noreferrer">
    <img alt="latest" src="https://badgen.net/bundlephobia/minzip/bible--core">
</a>

</p>

## Quickstart setup

```shell
npm install bible--core
```

## Library usage

```ts
import { Bible } from 'bible--core';

const bible = new Bible();

// Get the entire Bible object
const allContent = bible.bible;
console.log(allContent);

// Get a list of all book names
const bookNames = bible.getAllBooks();
console.log(bookNames);

// Get a specific book by name
const genesis = bible.getBook('Génesis');
console.log(genesis);

// Get a specific book versiculums
const genesisVersiculums = bible.getBookVersiculums('Génesis');
console.log(genesis);

// Get the cross references (parallel passages) of a versiculum
const crossReferences = bible.getCrossReferences({ b: 'Gn', c: '1', v: '1' });
console.log(crossReferences); // ['Job 38-39', 'Sl 8', 'Sl 104', 'Pr 8:22-31', 'Jn 1:1-3', ...]

// Same references, structured
const details = bible.getCrossReferenceDetails({ b: 'Gn', c: '1', v: '1' });
console.log(details); // [{ book: 'Job', chapter: '38', chapterTo: '39' }, ..., { book: 'Pr', chapter: '8', verses: [{ from: '22', to: '31' }] }, ...]
```

`getCrossReferences` takes a versiculum with the book abbreviation (`b`), chapter (`c`) and verse (`v`), the same shape returned by `getBookVersiculums` and `allVersiculums`. It returns an empty array when the verse has no references.

The references are the parallel passages of the Biblia, in the order the edition lists them. They use the book abbreviations of this library and keep the BJ notation:

- `Job 38-39`: chapters 38 to 39. `Sl 8`: the whole chapter.
- `Gn 1:1-2:4`: from chapter 1 verse 1 to chapter 2 verse 4.
- `Gn 25:26.29-34`: verse 26 and verses 29 to 34.
- Verse suffixes: `+` the passage has a note, `s` and the following verse, `p` and its parallels, `a`/`b` part of the verse.

Section titles have their own references, under the verse `t<n>`, e.g. `bible.getCrossReferences({ b: 'Gn', c: '2', v: 't2' })` returns `['Gn 1:1-2:4']`.

The data is built from `cross-references/paralelos.json` with `python3 cross-references/build_cross_references.py`.
