maz

maz

Bible_ex - An Elixir package that parses strings for Bible references

bible_ex - An Elixir package that parses strings for Bible references.

This is a port of the Dart package GitHub - joshpetit/reference_parser: Parse strings for bible references · GitHub to Elixir.

An Elixir package that parses strings for bible references. You can parse single references or multiple references from a string in a variety of formats.

Parsing References

use the parse_references function to retrieve a single reference:

alias BibleEx.RefParser
refs = RefParser.parse_references("I like Mat 2:4-10 and 1john 3:16")

This will return two reference objects, one describing “Matthew 2:4-10” and the other “1 John 3:16”

Note: The word ‘is’ will be parsed as the book of Isaiah.

[
  %BibleEx.Reference{
    book: "Matthew",
    book_names: %{abbr: "MAT", name: "Matthew", osis: "Matt", short: "Mt"},
    book_number: 40,
    reference: "Matthew 2:4-10",
    reference_type: :verse_range,
    start_chapter: %BibleEx.Chapter{
      ...
    }
  ...
  },
  %BibleEx.Reference{
  book: "1 John",
  book_names: %{abbr: "1JO", name: "1 John", osis: "1John", short: "1 Jn"},
  book_number: 62,
  reference: "1 John 3:16",
  reference_type: :verse,
  start_chapter: %BibleEx.Chapter{
    ...
  }
  ...
]

Objects and References

Reference

Reference objects are the broadest kind of reference.
You can directly construct one by following this format:

genesis_ref = Reference.new(book: "Genesis", start_chapter: 2, start_verse: 3, end_chapter: 4, end_verse: 5)
%BibleEx.Reference{
  book: "Genesis",
  book_names: %{abbr: "GEN", name: "Genesis", osis: "Gen", short: "Gn"},
  book_number: 1,
  reference: "Genesis 2:3 - 4:5",
  reference_type: :chapter_range,
  start_chapter: %BibleEx.Chapter{
    ...
  }
}

Their most important fields are these:

genesis_ref.reference # The string representation (osis_reference, short_reference, and abbr also available)
genesis_ref.start_verse_number
genesis_ref.end_verse_number
genesis_ref.start_chapter_number
genesis_ref.end_chapter_number
genesis_ref.reference_type # :verse, :chapter, :verse_range, :chapter_range, :book

Based on what is passed in, the constructor will figure out
certain fields. For example, if you were to construct Reference('James')
the last chapter and verse numbers in James will be initialized accordingly.

There is more to the library including Chapter and Verse structs. Please take a look at the HexDocs.

Most Liked

maz

maz

  1. No, it’s just a text parser.

  2. It’s not concerned with any bible version. It just extracts the book, chapter and verse structure.

  3. Yes for sure.

winsalva

winsalva

Thank you sir. I’ll try this lib and see what i can create with it. :heart:

Where Next?

Popular in Announcing Top

Crowdhailer
Experimenting with this code. OK.try do user <- fetch_user(1) cart <- fetch_cart(1) order = checkout(cart, user) save_orde...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
josevalim
Yes, yet another parser combinator library! Most of the parser combinators in the ecosystem are either compile-time, often using AST tra...
159 19417 141
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
tmbb
PhoenixWS - Websockets over Phoenix Channels Source code on Github here: GitHub - tmbb/phoenix_ws: Websockets implemented over Phoenix Ch...
New
Qqwy
TypeCheck: Fast and flexible runtime type-checking for your Elixir projects. Core ideas Type- and function specifications are const...
336 14482 100
New
tfwright
After working on it for a couple of months and using it in production for most of that time, today I’ve released LiveAdmin, a LiveView ba...
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
New
mtrudel
Bandit is an HTTP server for Plug and WebSock apps. Bandit is written entirely in Elixir and is built atop Thousand Island. It can serve...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 127089 1222
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement