3.0.0-alpha.9 • Published 10 months ago

usfm-grammar v3.0.0-alpha.9

Weekly downloads
127
License
MIT
Repository
github
Last release
10 months ago

USFM Grammar

Description

USFM Grammar is a JavaScript library for parsing and converting USFM (Unified Standard Format Markers) to/from USJ (Unified Standard JSON) format. This library provides functionalities to parse USFM strings into a syntax tree and convert them into a JSON-like structure (USJ), and vice versa.

Installation

You can install USFM Grammar via npm:

npm install usfm-grammar

Usage

Here's how you can use USFM Grammar in your JavaScript/TypeScript projects:

const usfmParser = new USFMParser(USFM);

const USFM = '\\id GEN\n\\c 1\n\\p\n\\v 1 In the begining..\\v 2 some more text'
const USJ = usfmParser.toUSJ()
console.log(USJ);

const usfmParser2 = new USFMParser(usfmString=null, fromUsj=USJ)
const usfmGen = usfmParser2.usfm;
console.log(usfmGen);

When using in an ESModule, if import {USFMParser} from 'usfm-grammar doesnt work for you, you could try:

import pkg from 'usfm-grammar';
const {USFMParser} = pkg;

...

API Documentation

USFMParser.toUSJ(): Object

Converts a USFM string to a USJ object.

  • usfmString: The input USFM string.

Returns: A JSON-like object representing the USJ.

USFMParser.usjToUsfm(usjObject: Object): string

Converts a USJ object to a USFM string.

  • usjObject: The input USJ object.

Returns: The converted USFM string.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request on GitHub.

License

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

3.0.0-alpha.7

11 months ago

3.0.0-alpha.9

10 months ago

3.0.0-alpha.8

11 months ago

3.0.0-alpha.6

11 months ago

3.0.0-alpha.1

12 months ago

3.0.0-alpha.3

12 months ago

3.0.0-alpha.2

12 months ago

3.0.0-alpha.5

11 months ago

3.0.0-alpha.4

11 months ago

2.3.1

2 years ago

2.3.0

3 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

2.0.0-beta.9

4 years ago

2.0.0-beta.8

5 years ago

2.0.0-beta.7

5 years ago

2.0.0-beta.6

5 years ago

2.0.0-beta.4

5 years ago

2.0.0-beta.3

5 years ago

2.0.0-beta.2

5 years ago

1.1.0

6 years ago

1.1.0-beta.2

6 years ago

1.1.0-beta.1

6 years ago

1.0.0

6 years ago

0.1.2

6 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.2-security

7 years ago

0.0.1-security

7 years ago