Skip to content

Commit

Permalink
port commit a15d24e, fixes sillsdev/serval#449
Browse files Browse the repository at this point in the history
  • Loading branch information
mshannon-sil committed Aug 28, 2024
1 parent 2f2de08 commit bfb44d8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 0 additions & 1 deletion machine/corpora/paratext_project_text_updater_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from abc import ABC, abstractmethod
from pathlib import Path
from typing import BinaryIO, List, Optional, Tuple, Union

from machine.corpora.paratext_project_settings import ParatextProjectSettings
Expand Down
3 changes: 3 additions & 0 deletions machine/corpora/scripture_ref_usfm_parser_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def text(self, state: UsfmParserState, text: str) -> None:
if text.strip():
self._check_convert_verse_para_to_non_verse(state)

def opt_break(self, state: UsfmParserState) -> None:
self._check_convert_verse_para_to_non_verse(state)

def start_char(
self, state: UsfmParserState, marker: str, unknown: bool, attributes: Optional[Sequence[UsfmAttribute]]
) -> None:
Expand Down
15 changes: 15 additions & 0 deletions tests/corpora/test_usfm_memory_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ def test_get_rows_triplicate_verse() -> None:
assert rows[4].text == "Second verse"


def test_get_rows_opt_break_middle_include_markers() -> None:
rows: List[TextRow] = get_rows(
r"""\id MAT - Test
\c 1
\v 1 First verse in line // More text
\c 2
\v 1
""",
include_all_text=True,
include_markers=True,
)
assert len(rows) == 2, str.join(",", [tr.text for tr in rows])
assert rows[0].text == "First verse in line // More text"


def test_get_rows_verse_para_beginning_non_verse_segment() -> None:
# a verse paragraph that begins with a non-verse segment followed by a verse segment
rows: List[TextRow] = get_rows(
Expand Down

0 comments on commit bfb44d8

Please sign in to comment.