2.0.0 • Published 11 months ago

@idrw/bible-ref-parser v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Bible Reference Parser

License: MIT

A Node.js package to parses Bible references into structured objects. It supports complex references such as Genesis 1:1-2; II Peter; John 1:1,3-5,8.

Installation

npm install @idrw/bible-ref-parser

Usage

Example query, with errors

import { parseQuery } from '@idrw/bible-ref-parser';

const result: QueryResult = parseQuery("! pasta;RM-RF/;1John1:2,2:1;IIPeter1:1;IJohn2:4;#--324;1 kebab 2:1;'_&%\"!\"¥");
{
    "books": [
        {
            "name": "1 John",
            "references": [
                { "chapter": 1, "verses": [{ "from": 2 }] },
                { "chapter": 2, "verses": [{ "from": 1 }] }
            ]
        },
        {
            "name": "2 Peter",
            "references": [
                { "chapter": 1, "verses": [{ "from": 1 }] }
            ]
        },
        {
            "name": "1 John",
            "references": [
                { "chapter": 2, "verses": [{ "from": 4 }] }
            ]
        }
    ],
    "errors": ["! pasta", "RM-RF/", "#--324", "1 kebab", "'_&%\"!\"¥"]
}

Example query, without errors

import { parseQuery } from '@idrw/bible-ref-parser';

const result: QueryResult = parseQuery("Genesis 1:1-2; II Peter; John 1:1,3-5,8");
{
    "books": [
        {
            "name": "Genesis",
            "references": [
                { "chapter": 1, "verses": [{ "from": 1, "to": 2 }] }
            ]
        },
        { "name": "2 Peter", "references": [] },
        {
            "name": "John",
            "references": [
                {
                    "chapter": 1,
                    "verses": [
                        { "from": 1 },
                        { "from": 3, "to": 5 },
                        { "from": 8 }
                    ]
                }
            ]
        }
    ],
    "errors": []
}

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

2.0.0

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago