mirror of
https://github.com/scotttomaszewski/obsidian-disciples-journal.git
synced 2026-07-22 12:20:30 +00:00
1.9 KiB
1.9 KiB
Bible reference formats
Supported reference syntax and how it is parsed. Primary code:
src/core/BibleReference.ts (BibleReference.parse) and
src/services/BookNames.ts.
Supported formats
| Example | Meaning | Parsed fields |
|---|---|---|
Genesis 1 |
whole chapter | chapter |
Genesis 1-2 |
chapter range | chapter, endChapter |
John 3:16 |
single verse | chapter, verse |
Genesis 1:1-10 |
verse range in one chapter | chapter, verse, endVerse |
Philippians 1:27-2:11 |
cross-chapter range | chapter, verse, endChapter, endVerse |
1 Corinthians 13:4-7 |
book name with a number/space | (as above) |
Song of Solomon 2:1 |
multi-word book name | (as above) |
How parsing works
BibleReference.parse(str):
- Extracts the book name with
BookNames.extractBookFromReference, then normalizes it viaBookNames.normalize(handles abbreviations and multi-word / numbered book names). An unknown book →parsereturnsnull. - Normalizes en-dashes (
–) to hyphens in the chapter/verse remainder. - Matches the remainder against patterns in this order: cross-chapter
(
C:V-C:V) → chapter range (C-C) → verse range (C:V-V) → single verse (C:V) → single chapter (C). The first match wins.
parse returns null (not throws) for anything it can't interpret. The
BibleReference constructor, however, throws if given an unnormalizable book
name — parse guards against this by normalizing first.
The value object
BibleReference carries { book, chapter, verse?, endVerse?, endChapter? } and
provides:
toString()— canonical form (round-trips the formats above).isChapterReference()— true when no specific verse is set.isRange()— true whenendVerseorendChapteris set.clone()— deep copy.
These fields also drive note filenames — see
esv-api.md and BibleFiles.pathForPassage.