-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect handling of descriptive titles in USX
Showing
4 changed files
with
84 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import Optional | ||
|
||
from ..scripture.verse_ref import Versification | ||
from .memory_stream_container import MemoryStreamContainer | ||
from .stream_container import StreamContainer | ||
from .usx_text_base import UsxTextBase | ||
|
||
|
||
class UsxMemoryText(UsxTextBase): | ||
def __init__(self, id: str, usx: str, versification: Optional[Versification] = None) -> None: | ||
super().__init__(id, versification) | ||
self._usx = usx | ||
|
||
def _create_stream_container(self) -> StreamContainer: | ||
return MemoryStreamContainer(self._usx) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from typing import List | ||
|
||
from testutils.corpora_test_helpers import scripture_ref | ||
|
||
from machine.corpora import ScriptureRef, TextRow, UsxMemoryText | ||
|
||
|
||
def test_get_rows_descriptive_title() -> None: | ||
rows = get_rows( | ||
r"""<usx version="3.0"> | ||
<book code="MAT" style="id">- Test</book> | ||
<chapter number="1" style="c" /> | ||
<para style="d"> | ||
<verse number="1" style="v" sid="MAT 1:1" />Descriptive title</para> | ||
<para style="p"> | ||
The rest of verse one.<verse eid="MAT 1:1" /> | ||
<verse number="2" style="v" />This is verse two.</para> | ||
</usx> | ||
""" | ||
) | ||
assert len(rows) == 2 | ||
|
||
assert scripture_ref(rows[0]) == ScriptureRef.parse("MAT 1:1"), str.join(",", [str(tr.ref) for tr in rows]) | ||
assert rows[0].text == "Descriptive title", str.join(",", [tr.text for tr in rows]) | ||
|
||
|
||
def get_rows(usx: str) -> List[TextRow]: | ||
text = UsxMemoryText("MAT", usx) | ||
return list(text.get_rows()) |