transmogriverse

0.1.2 • Public • Published

Build Status NPM version License

transmogriverse

This module will search through text for Bible verse references (of various formats and abbreviations) and normalize. The caller may pass in a custom replacer function to use in order to replace the references with other formats, create hyper links, etc.

Install

npm install transmogriverse

Usage Example

var replacer = require('transmogriverse');
var text = 'The first verse is Gen. 1:1';
text = replacer(text); // -> 'The first verse is Genesis 1:1'

API

var result = replacer(text [,callback])

The text is simply passed through String.replace() using a generated regular expression and a bunch of bailing-wire/chewing-gum type string manipulation. It tries to recognize various forms of common abbreviations for the names of the books of the Bible.

A callback function may be passed as an optional second argument and is called once for each verse reference discovered in the text.

The callback is passed a single argument, which is an object containing up to four fields:

  • book - {String} the name of the book, minus any ordinal prefix
  • chap - {Number} the chapter, integer
  • verse - {Number:optional} verse
  • ord - {Number:optional} the ordinal value of the book (ie: 1 for 1 Corinthians)

Whatever the callback returns will be used to replace the reference that has been found. You may return fancy hyperlinks, pretty html or UTF8 strings with roman numerals, etc.

TODO

  • add support for apocrypha in abbreviations

Readme

Keywords

none

Package Sidebar

Install

npm i transmogriverse

Weekly Downloads

0

Version

0.1.2

License

MIT

Last publish

Collaborators

  • burl.bn