usfm-grammar-web 3.0.0-beta.17 → 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 +33 -14
- package/dist/bundle.mjs +42047 -45
- package/dist/bundle.mjs.map +1 -1
- package/package.json +4 -1
- package/tree-sitter-usfm.wasm +0 -0
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.
|
|
27
|
-
"https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.
|
|
28
|
-
await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.
|
|
29
|
-
"https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.
|
|
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.
|
|
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.
|
|
67
|
-
"https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.
|
|
68
|
-
await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.
|
|
69
|
-
"https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.
|
|
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(
|
|
123
|
+
const usfmParser2 = new USFMParser(null, null, usxElem) // USX to USFM
|
|
124
124
|
const usfmGen = usfmParser2.usfm;
|
|
125
125
|
console.log(usfmGen);
|
|
126
126
|
```
|
|
@@ -132,13 +132,32 @@ Bible NLP format consists of two `txt` files: the first, with verse texts, one p
|
|
|
132
132
|
const output = usfmParser.toBibleNlpFormat()
|
|
133
133
|
//const output = my_parser.toBibleNlpFormat(true) //ignore_errors
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
output.text.forEach(txt => {
|
|
136
|
+
console.log(txt);
|
|
137
|
+
});
|
|
137
138
|
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
output.vref.forEach(ref => {
|
|
140
|
+
console.log(ref);
|
|
141
|
+
});
|
|
140
142
|
```
|
|
141
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
|
+
|
|
142
161
|
### Table/List format
|
|
143
162
|
|
|
144
163
|
```javascript
|