Skip to content

Commit

Permalink
Extented footnote support (#215)
Browse files Browse the repository at this point in the history
* Implement grammar rules for 'ef'

* Include tests that were missed ealier due to different directory structure
  • Loading branch information
kavitharaju authored Aug 1, 2023
1 parent 9d41c24 commit fd743fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion py-usfm-parser/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ def find_all_markers(usfm_path, keep_id=False, keep_number=True):
all_markers_in_input.remove("esbe")
return all_markers_in_input

all_usfm_files = glob(f"{TEST_DIR}/*/*/origin.usfm")
all_usfm_files = glob(f"{TEST_DIR}/*/*/origin.usfm") +\
glob(f"{TEST_DIR}/*/origin.usfm") +\
glob(f"{TEST_DIR}/*/*/*/origin.usfm")

doubtful_usfms = [
]
Expand Down Expand Up @@ -170,6 +172,7 @@ def find_all_markers(usfm_path, keep_id=False, keep_number=True):
f"{TEST_DIR}/usfmjsTests/acts-1-20.aligned.crammed.oldformat/origin.usfm": "fail",
f"{TEST_DIR}/special-cases/empty-para/origin.usfm": "fail",
f"{TEST_DIR}/special-cases/sp/origin.usfm": "fail",
f"{TEST_DIR}/specExamples/extended/sidebars/origin.usfm":"fail",

# No. of columns in table not validated by usfm-grammar
f"{TEST_DIR}/paratextTests/MissingColumnInTable/origin.usfm": "pass",
Expand Down Expand Up @@ -205,6 +208,8 @@ def find_all_markers(usfm_path, keep_id=False, keep_number=True):
f"{TEST_DIR}/usfmjsTests/45-ACT.ugnt/origin.usfm": "fail", # also has \toc1 without content

f"{TEST_DIR}/biblica/PublishingVersesWithFormatting/origin.usfm": "fail", # \c without number

f"{TEST_DIR}/specExamples/extended/contentCatogories1/origin.usfm": "fail", # cat inside footnote
########### Need to be fixed #######################
f"{TEST_DIR}/paratextTests/NoErrorsShort/origin.usfm": "pass", # \c is mandatory!
f"{TEST_DIR}/usfmjsTests/gn_headers/origin.usfm": "fail", # what is the valid position for mte and imt
Expand Down
5 changes: 3 additions & 2 deletions tree-sitter-usfm3/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,11 @@ module.exports = grammar({
$._nestedCharacterMarker,
))),

footnote: $ => choice($.f, $.fe, $.fm),
footnote: $ => choice($.f, $.fe, $.fm, $.ef),

f: $ => seq("\\f ",$.caller, repeat($._footnoteContents), "\\f*"),
fe: $ => seq("\\fe ",$.caller, $._footnoteContents, "\\fe*"),
fe: $ => seq("\\fe ",$.caller, repeat($._footnoteContents), "\\fe*"),
ef: $ => seq("\\ef ",$.caller, repeat($._footnoteContents), "\\ef*"),
fr: $ => seq("\\fr ", $.noteText, optional("\\fr*")),
fq: $ => seq("\\fq ", $.noteText, optional("\\fq*")),
fqa: $ => seq("\\fqa ", $.noteText, optional("\\fqa*")),
Expand Down

0 comments on commit fd743fd

Please sign in to comment.