jota-parser
v1.0.7
Published
Jota Parser finds references to Bible passages in the given text
Downloads
9
Readme
Jota Parser finds references to Bible passages in the given text.
For example it will understand that "Read J 3 16" refers to the Gospel of John chapter 3 verse 16. Lots of examples of what it can parse are displayed here.
The output of parsing is an array of references, where reference can be a:
- Single chapter:
[bookIndex, chapter]
- Single verse:
[bookIndex, chapter, verse]
- Range of verses in a single chapter:
[bookIndex, chapter, startVerse, endVerse]
- Chapter crossing range of verses:
[[bookIndex1, chapter1, verse1?], [bookIndex2, chapter2, verse2?]]
Currently supported locales: en
, pl
. Locale bundles provide support for names of books in the given language.
Usage
ES6:
import { Parser, en } from 'jota-parser'
const parser = new Parser({ locales: [en] })
console.log(parser.parse('J 3 16'))
Browser:
<script type="module">
import { Parser, en } from "https://unpkg.com/jota-parser?module"
const parser = new Parser({locales: [en]})
console.log(parser.parse('Read J 3:16'))
</script>
Development
Install the dependencies
npm install
Start the app in development mode (hot-code reloading, error reporting, etc.)
npm run dev
Build for production
It builds both library using vite.config.lib.js
config and the github pages site using vite-config.gh-pages.js
config
npm run build
Unit test
npm run test
Deploy github pages
npm run deploy:gh-pages
Add support for a new locale
- Create
parser-${locale}.js
in/src
folder - Create
data-${locale}.js
andparser.${locale}.spec.js
in/test
folder - Add locale to
supportedLocales
constance inindex.js