usfm-grammar-web 3.0.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,10 +23,10 @@ function App() {
23
23
 
24
24
  useEffect(() => {
25
25
  const initParser = async () => {
26
- await USFMParser.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.0.0/tree-sitter-usfm.wasm",
27
- "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.0.0/tree-sitter.wasm");
28
- await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.0.0/tree-sitter-usfm.wasm",
29
- "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.0.0/tree-sitter.wasm");
26
+ await USFMParser.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.1.1/tree-sitter-usfm.wasm",
27
+ "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.1.1/tree-sitter.wasm");
28
+ await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.1.1/tree-sitter-usfm.wasm",
29
+ "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.1.1/tree-sitter.wasm");
30
30
 
31
31
  };
32
32
  initParser();
@@ -60,13 +60,13 @@ It can be used directly in the HTML script tag too. Please ensure its dependenci
60
60
 
61
61
  ```html
62
62
  <script type="module">
63
- import { USFMParser, Filter, Validator } from 'https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.0.0/dist/bundle.mjs';
63
+ import { USFMParser, Filter, Validator } from 'https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.1.1/dist/bundle.mjs';
64
64
  console.log('Hello world');
65
65
  (async () => {
66
- await USFMParser.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.0.0/tree-sitter-usfm.wasm",
67
- "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.0.0/tree-sitter.wasm");
68
- await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.0.0/tree-sitter-usfm.wasm",
69
- "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.0.0/tree-sitter.wasm");
66
+ await USFMParser.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.1.1/tree-sitter-usfm.wasm",
67
+ "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.1.1/tree-sitter.wasm");
68
+ await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.1.1/tree-sitter-usfm.wasm",
69
+ "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.1.1/tree-sitter.wasm");
70
70
  const usfmParser = new USFMParser('\\id GEN\n\\c 1\n\\p\n\\v 1 In the begining..\\v 2 more text')
71
71
  const output = usfmParser.toUSJ()
72
72
  console.log({ output })
@@ -120,7 +120,7 @@ const usx = usxSerializer.serializeToString(usxElem);
120
120
 
121
121
  console.log(usx);
122
122
 
123
- const usfmParser2 = new USFMParser(usfmString=null, fromUsj=null, fromUsx=usxElem) // USX to USFM
123
+ const usfmParser2 = new USFMParser(null, null, usxElem) // USX to USFM
124
124
  const usfmGen = usfmParser2.usfm;
125
125
  console.log(usfmGen);
126
126
  ```
@@ -141,6 +141,23 @@ output.vref.forEach(ref => {
141
141
  });
142
142
  ```
143
143
 
144
+ Biblenlp format data can also be used to initialize the parser and generate other formats like USFM, USX, USJ, List etc from.
145
+ ```javascript
146
+ import {ORIGINAL_VREF} from 'usfm-grammar';
147
+
148
+ const bibleNlpObj = {'vref': ["GEN 1:1", "GEN 1:2"], 'text':["In the begining ...", "The earth was formless ..."]}
149
+
150
+ const myParser = new USFMParser(null, null, null, bibleNlpObj);
151
+ console.log(myParser.usfm);
152
+
153
+ // To use the default versification in BibleNLP
154
+ const bibleNlpObj2 = {'vref':ORIGINAL_VREF, 'text':["In the begining ...", "The earth was formless ...", ...]} //Full text of a book or the whole Bible as per BibleNLP format (23213, 31170 or 41899 lines)
155
+ const myParser2 = new USFMParser(null, null, null, bibleNlpObj2, "GEN");
156
+ console.log(myParser2.usfm);
157
+ console.log(myParser2.warnings)
158
+ ```
159
+ > :warning: USFM and its sister formats are designed to contain only one book per file. In contrast, the BibleNLP format can store an entire Bible with multiple books in a single file. When converting BibleNLP to USFM, if multiple books are present, the resulting USFM file will contain multiple books. This deviates from the expected structure of a valid USFM file, causing further conversions to other formats to fail. To ensure successful parsing, the generated USFM file must be split into separate files, each containing a single book.
160
+
144
161
  ### Table/List format
145
162
 
146
163
  ```javascript