openbibleinfo / Bible-Passage-Reference-Parser

Coffeescript to identify and understand Bible references like "John 3:16."
223 stars 65 forks source link

Book name is not parsed #14

Closed rawcomposition closed 9 years ago

rawcomposition commented 9 years ago

I'm running into a problem where "Genesis" returns blank with .osis() and "Genesis 1:1" returns the correctly formatted result.

A JSFiddle of this can be seen here: https://jsfiddle.net/zd92o8m4/1/

openbibleinfo commented 9 years ago

By default, it doesn't parse book names on their own (to avoid false positives). If you want to handle this case, try:

var bcv = new bcv_parser;
bcv.set_options({book_alone_strategy: "full"});
ref1 = bcv.parse( "Genesis" ).osis(); // "Gen"

You can also set book_alone_strategy to first_chapter if that works better for you. You may want to look at book_range_strategy and book_sequence_strategy and, depending on your needs, consider changing the osis_compaction_strategy.

Thanks for the JSFiddle; it was helpful.