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

Ignore opt break that occurs outside of a segment #243

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading