usfm-grammar-web 3.2.0-beta.2 → 3.2.0-beta.3

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.2.0-beta.2/tree-sitter-usfm.wasm",
27
- "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.2/tree-sitter.wasm");
28
- await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.2/tree-sitter-usfm.wasm",
29
- "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.2/tree-sitter.wasm");
26
+ await USFMParser.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.3/tree-sitter-usfm.wasm",
27
+ "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.3/tree-sitter.wasm");
28
+ await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.3/tree-sitter-usfm.wasm",
29
+ "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.3/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.2.0-beta.2/dist/bundle.mjs';
63
+ import { USFMParser, Filter, Validator } from 'https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.3/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.2.0-beta.2/tree-sitter-usfm.wasm",
67
- "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.2/tree-sitter.wasm");
68
- await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.2/tree-sitter-usfm.wasm",
69
- "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.2/tree-sitter.wasm");
66
+ await USFMParser.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.3/tree-sitter-usfm.wasm",
67
+ "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.3/tree-sitter.wasm");
68
+ await Validator.init("https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.3/tree-sitter-usfm.wasm",
69
+ "https://cdn.jsdelivr.net/npm/usfm-grammar-web@3.2.0-beta.3/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 })
package/dist/bundle.mjs CHANGED
@@ -3832,7 +3832,8 @@ const $28b0061e56e1edf2$export$af42bd8f70df8555 = [
3832
3832
  'th',
3833
3833
  'tcr',
3834
3834
  'thr',
3835
- 'tcc'
3835
+ 'tcc',
3836
+ 'thc'
3836
3837
  ];
3837
3838
  const $28b0061e56e1edf2$export$c4d2f24f22330b2a = [
3838
3839
  'fig',
@@ -4097,7 +4098,7 @@ class $1bdca1468aa54399$var$USJGenerator {
4097
4098
  // Build USJ nodes for character markups, both regular and nested
4098
4099
  const tagNode = node.children[0];
4099
4100
  let childrenRange = node.children.length;
4100
- if (node.children[node.children.length - 1].type.startsWith('\\')) childrenRange -= 1; // Exclude the last node if it starts with '\', treating it as a closing node
4101
+ for(let i = node.children.length - 1; i > 0; i--)if (node.children[i].type.startsWith('\\') || node.children[i].type === '*' || node.children[i].type.endsWith('Tag')) childrenRange -= 1;
4101
4102
  const style = this.usfm.substring(tagNode.startIndex, tagNode.endIndex).replace('\\', '').replace('+', '').trim();
4102
4103
  const charJsonObj = {
4103
4104
  type: 'char',
@@ -4137,7 +4138,7 @@ class $1bdca1468aa54399$var$USJGenerator {
4137
4138
  type: 'table:cell',
4138
4139
  marker: style,
4139
4140
  content: [],
4140
- align: style.includes('tcc') ? 'center' : style.includes('r') ? 'end' : 'start'
4141
+ align: style.includes('tcc') || style.includes('thc') ? 'center' : style.includes('r') ? 'end' : 'start'
4141
4142
  };
4142
4143
  node.children.slice(1).forEach((child)=>{
4143
4144
  this.nodeToUSJ(child, cellJsonObj);
@@ -4699,7 +4700,7 @@ class $02bc2da10d8b76e8$var$USXGenerator {
4699
4700
  // Build USJ nodes for character markups, both regular and nested
4700
4701
  const tagNode = node.children[0];
4701
4702
  let childrenRange = node.children.length;
4702
- if (node.children[node.children.length - 1].type.startsWith('\\')) childrenRange -= 1; // Exclude the last node if it starts with '\', treating it as a closing node
4703
+ for(let i = node.children.length - 1; i > 0; i--)if (node.children[i].type.startsWith('\\') || node.children[i].type === '*' || node.children[i].type.endsWith('Tag')) childrenRange -= 1;
4703
4704
  const charXmlNode = parentXmlNode.ownerDocument.createElement('char');
4704
4705
  const style = this.usfm.substring(tagNode.startIndex, tagNode.endIndex).replace('\\', '').replace('+', '').trim();
4705
4706
  charXmlNode.setAttribute('style', style);
@@ -4743,7 +4744,7 @@ class $02bc2da10d8b76e8$var$USXGenerator {
4743
4744
  const style = this.usfm.substring(tagNode.startIndex, tagNode.endIndex).replace('\\', '').trim();
4744
4745
  const cellXmlNode = parentXmlNode.ownerDocument.createElement('cell');
4745
4746
  cellXmlNode.setAttribute('style', style);
4746
- cellXmlNode.setAttribute('align', style.includes('tcc') ? 'center' : style.includes('r') ? 'end' : 'start');
4747
+ cellXmlNode.setAttribute('align', style.includes('tcc') || style.includes('thc') ? 'center' : style.includes('r') ? 'end' : 'start');
4747
4748
  parentXmlNode.appendChild(cellXmlNode);
4748
4749
  node.children.slice(1).forEach((child)=>{
4749
4750
  this.node2Usx(child, cellXmlNode);