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

Create a relax mode for parsing #52

Closed
kavitharaju opened this issue Apr 9, 2020 · 1 comment
Closed

Create a relax mode for parsing #52

kavitharaju opened this issue Apr 9, 2020 · 1 comment
Assignees
Milestone

Comments

@kavitharaju
Copy link
Collaborator

Write a simpler grammar, with more generalized rules to model USFM
It should be able to handle USFM 1.x, 2.x and 3.x
And should successfully parse for minor error which the regular mode would reject

@kavitharaju kavitharaju self-assigned this Apr 9, 2020
@kavitharaju kavitharaju added this to the 2.0 version milestone May 21, 2020
@kavitharaju
Copy link
Collaborator Author

const grammar = require(usfm-grammar);

var input = '\****usfm-string****\';

const myUsfmParser = new grammar.USFMParser(input, grammar.LEVEL.RELAXED);
var jsonOutput = myUsfmParser.toJSON();

This relaxed mode provides relaxation of sereval rules in the USFM spec and give you a JSON output for a file that can be considered a workable USFM file. Only the most important markers are checked for, like the \id at the start, presence of \c and \v markers. Though all the given markers are parsered and provided in JSON output, their syntax or the position in the file is not verified. Even a miss-spelled makers would be accepted. So as a word of caution, mistakes may go unnoticed that might even lead to loss of information. For example if the file has mistakenly not given a space between verse marker and verse number, and has \v3 the parser may accept it as a different marker v3 and fail to recognise that it is a verse.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant