Skip to content

Commit

Permalink
Update grammar, allowing footnotes in \d. For Bridgeconn#282
Browse files Browse the repository at this point in the history
  • Loading branch information
kavitharaju committed Nov 25, 2024
1 parent f8a3f22 commit bf42b48
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
30 changes: 26 additions & 4 deletions docs/Dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,37 @@ bumpversion --new-version 3.0.0-alpha.28 num
The github action is configured to automatically build and publish to PyPI and NPM upon a github code release. Make sure to use same version number in the python module bump command, and github release.

## Run tests
To check Syntax trees in Grammar module
### To check Syntax trees in Grammar module
```bash
cd tree-sitter-usfm3
export PATH=$PATH:./node_modules/.bin
tree-sitter generate
tree-sitter test
```

In python module alone
Ensure the other modules have this newer grammar.

Python:
```bash
cd py-usfm-parser
pip install ../tree-sitter-usfm3/
```

Node:
```bash
cd node-usfm-parser
npm install ../tree-sitter-usfm3/ --no-save
```

Web:
```bash
cd tree-sitter-usfm3
tree-sitter build --wasm
cp tree-sitter-usfm3.wasm ../web-usfm-parser/tree-sitter-usfm.wasm
```


### In python module alone

```bash
cd py-usfm-parser
Expand All @@ -49,7 +71,7 @@ pytest -k "not compare_usx_with_testsuite_samples and not testsuite_usx_with_rnc

```

In node module:
### In node module:

```bash
cd node-usfm-parser
Expand All @@ -60,7 +82,7 @@ node_modules/mocha/bin/mocha.js --timeout 40000 --grep "Compare" --bail
node_modules/mocha/bin/mocha.js --timeout 40000 test/basic.js
```

In web module:
### In web module:

```bash
cd web-usfm-parser
Expand Down
6 changes: 5 additions & 1 deletion tree-sitter-usfm3/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ module.exports = grammar({
r: $ => seq("\\r ", $.text), // ocurs under c too

sp: $ => seq("\\sp ", $.text),
d: $ => seq("\\d ", $.text),
d: $ => prec.right(0, seq("\\d ", repeat1(choice($.text,
$.footnote, $.crossref,
$._characterMarker,
$.fig,
)))),
sdBlock: $ => prec.right(0, repeat1($.sd)),
sd: $ => seq($.sdTag),
sdTag: $ => seq("\\sd", optional($.numberedLevelMax4), $._spaceOrLine),
Expand Down

0 comments on commit bf42b48

Please sign in to comment.