Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S5 support #259

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/Dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ pytest -k "not compare_usx_with_testsuite_samples and not testsuite_usx_with_rnc

```

## How to build and publish JS module for local Development
## How to build and publish JS web module for local Development

First compile the grammar and get the wasm file
```bash
cd tree-sitter-usfm3
export PATH=$PATH:./node_modules/.bin
tree-sitter generate
tree-sitter build --wasm
cp tree-sitter-usfm.wasm ../js-usfm-parser/
cd ..
```
Expand All @@ -69,7 +70,9 @@ cp node_modules/web-tree-sitter/tree-sitter.wasm ./

```

Build the code base generating both cjs and esm versions of the same code base. This used parcel and its configs are in package.json(main, module, source, etc). Upon running the commands two folders `dist/cjs/` and `dist/esm` would be created.
### To publish the node and web modules

Build the code base generating both cjs and esm versions of the same code base. This used parcel and its configs are in package.json(main, module, source, etc). These steps can be followed in both the node module directory and web module directory.

```bash
rm -fr ./dist
Expand Down
2 changes: 1 addition & 1 deletion node-usfm-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "usfm-grammar",
"version": "3.0.0-alpha.8",
"version": "3.0.0-alpha.9",
"description": "Parser using tree-sitter-usfm3, to convert usfm to usj format.",
"main": "./dist/cjs/index.cjs",
"module": "./dist/es/index.mjs",
Expand Down
19 changes: 12 additions & 7 deletions node-usfm-parser/src/usfmParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ Only one of USFM, USJ or USX is supported in one object.`)
return this.syntaxTree.toString();
}

toUSJ() {
this.usj = this.convertUSFMToUSJ();
toUSJ(excludeMarkers = null,
includeMarkers = null,
ignoreErrors = false,
combineTexts = true,) {
this.usj = this.convertUSFMToUSJ(excludeMarkers = excludeMarkers,
includeMarkers = includeMarkers,
ignoreErrors = ignoreErrors,
combineTexts = combineTexts,);
return this.usj;
}

Expand Down Expand Up @@ -128,14 +134,13 @@ Only one of USFM, USJ or USX is supported in one object.`)
return outputUSFM;
}

convertUSFMToUSJ({
convertUSFMToUSJ(
excludeMarkers = null,
includeMarkers = null,
ignoreErrors = false,
combineTexts = true,
} = {}) {
combineTexts = true,) {
if (!ignoreErrors && this.errors.length > 0) {
let errorString = this.errors.map((err) => err.join(":")).join("\n\t");
let errorString = this.errors.join("\n\t");
throw new Error(
`Errors present:\n\t${errorString}\nUse ignoreErrors = true to generate output despite errors.`,
);
Expand All @@ -153,7 +158,7 @@ Only one of USFM, USJ or USX is supported in one object.`)
} catch (err) {
let message = "Unable to do the conversion. ";
if (this.errors) {
let errorString = this.errors.map((err) => err.join(":")).join("\n\t");
let errorString = this.errors.join("\n\t");
message += `Could be due to an error in the USFM\n\t${errorString}`;
}
else {
Expand Down
Loading
Loading