Multi Book References
It is possible for a single reference to be a range than spans more than one book of the Bible.
For example, the following references are all equally referencing the entire first five books of the Bible:
- Genesis - Deuteronomy
- Genesis 1 - Deuteronomy 34
- Genesis 1:1 - Deuteronomy 34:12
#
Finding ReferencesWhen parsing a given text to find all the references contained within, if we find a ranged reference like those above that span multiple books of the Bible, we should parse that into a single normalized reference that includes the optional end_book
attribute.
For example, "Genesis - Deuteronomy" vs "Genesis;Exodus;Numbers;Leviticus;Deuteronomy":
If rather than using the range, the text specified each book of the Bible separated by a comma or semi-colon (or just about anything), then the result would be a list of five normalized references, one for each of the five books referenced.
That list can optionally be optimized by converting it to verse ids and then back into references if so desired.
That optimization is optional as it can degrade performance for processing large ranges if that particular optimization is not necessary. This optimization will be run automatically when the list of references is formatted into a Scripture reference string.
#
Converting References to Verse IDsWhether a multi book range reference is in a single normalized reference or a list of one normalized reference for each book does not affect the results of converting that reference into a list of verse ids.
#
Converting Verse IDs to ReferencesWhen converting a list of verse ids into a list of references, multi book range references will always be optimized into a single normalized reference when possible.
#
Formatting References for Print/DisplayAs mentioned earlier, when formatting references for print/display, pythonbible always optimizes the list of references into as few references as possible by using multi book range references.
By default, chapter numbers will not be included when the entire book is included in the reference.
#
Always Include Chapter NumbersIf you want to force pythonbible to include the chapter numbers even when the entire book is covered by the reference, you can use the optional always_include_chapter_numbers
optional parameter of the format_scripture_references
or format_single_reference
functions, setting that optional parameter to be True
.
For example: