Skip to content

Commit

Permalink
Ignore opt break that occurs outside of a segment
Browse files Browse the repository at this point in the history
- fixes #242
  • Loading branch information
ddaspit committed Sep 12, 2024
1 parent 34c3a94 commit e78d200
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/SIL.Machine/Corpora/UsfmTextBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ public override void OptBreak(UsfmParserState state)
{
base.OptBreak(state);

if (_rowTexts.Count == 0)
return;

if (_text._includeMarkers)
{
_rowTexts.Peek().Append("//");
Expand Down
20 changes: 20 additions & 0 deletions tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,26 @@ public void GetRows_OptBreak_BeginningIncludeMarkers()
});
}

[Test]
public void GetRows_OptBreak_OutsideOfSegment()
{
TextRow[] rows = GetRows(
@"\id MAT - Test
\c 1
//
\p
\v 1 This is the first verse.
",
includeAllText: true,
includeMarkers: true
);
Assert.Multiple(() =>
{
Assert.That(rows, Has.Length.EqualTo(1), string.Join(",", rows.Select(tr => tr.Text)));
Assert.That(rows[0].Text, Is.EqualTo("This is the first verse."));
});
}

private static TextRow[] GetRows(string usfm, bool includeMarkers = false, bool includeAllText = false)
{
UsfmMemoryText text =
Expand Down

0 comments on commit e78d200

Please sign in to comment.