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

Usj to usfm #224

Merged
merged 9 commits into from
Oct 18, 2023
Merged

Usj to usfm #224

merged 9 commits into from
Oct 18, 2023

Conversation

kavitharaju
Copy link
Collaborator

This PR

⚠️ The failing test cases are due to one testsuite file which needs a fix (\b should be \p)

How-To round trip

from usfm_grammar import USFMParser, Filter
from usfm_grammar import USFMParser, USFMGenerator

my_parser = USFMParser(input_usfm_str)
usj_obj = my_parser.to_usj()

my_generator = USFMGenerator()
my_generator.usj_to_usfm(usj_obj)
print(my_generator.usfm_string)

⚠️ There will be differences between first USFM and the generated one in 1. Spaces and lines 2. Default attributes will be given their names 3. Closing markers may be newly added

How-To remove unwanted markers from USFM

from usfm_grammar import USFMParser, Filter, USFMGenerator

my_parser = USFMParser(input_usfm_str)
usj_obj = my_parser.to_usj(include_markers=Filter.BCV+Filter.TEXT)

my_generator = USFMGenerator()
my_generator.usj_to_usfm(usj_obj)
print(my_generator.usfm_string)

@kavitharaju kavitharaju marked this pull request as draft October 10, 2023 15:32
@kavitharaju
Copy link
Collaborator Author

Changed the API as per the suggestion. This is how it is now

from usfm_grammar import USFMParser, Filter

my_parser = USFMParser(input_usfm_str)
usj_obj = my_parser.to_usj()

my_parser2 = USFMParser(from_usj=usj_obj)
print(my_parser2.usfm)

@kavitharaju kavitharaju marked this pull request as ready for review October 17, 2023 10:55
@joelthe1 joelthe1 merged commit bf8b42d into Bridgeconn:version-3 Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants