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

correctly parse table in duplicate verse #222

Merged
merged 1 commit into from
Jul 11, 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
1 change: 1 addition & 0 deletions .ignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
!tests/SIL.Machine.Tests/Corpora/TestData/usfm/source/*
!tests/SIL.Machine.Tests/Corpora/TestData/usfm/target/*
!tests/SIL.Machine.Tests/Corpora/TestData/project/*
2 changes: 2 additions & 0 deletions src/SIL.Machine/Corpora/UsfmTextBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public override void StartCell(UsfmParserState state, string marker, string alig
}
else if (CurrentTextType == ScriptureTextType.Verse)
{
if (_rowTexts.Count == 0)
return;
StringBuilder verseText = _rowTexts.Peek();
if (verseText.Length > 0 && !char.IsWhiteSpace(verseText[verseText.Length - 1]))
verseText.Append(" ");
Expand Down
21 changes: 21 additions & 0 deletions tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ public void GetRows_LastSegment()
});
}

[Test]
public void GetRows_DuplicateVerseWithTable()
{
TextRow[] rows = GetRows(
@"\id MAT - Test
\c 1
\v 1 First verse
\periph Table of Contents Abbreviation
\rem non verse content 1
\v 1 duplicate first verse
\rem non verse content 2
\mt1 Table
\tr \tc1 row 1 cell 1 \tc2 row 1 cell 2
\tr \tc1 row 2 cell 1 \tc2 row 2 cell 2
",
includeAllText: true
);

Assert.That(rows, Has.Length.EqualTo(5));
}

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