diff --git a/.ignore b/.ignore index 4fa382dd..28b6245a 100644 --- a/.ignore +++ b/.ignore @@ -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/* \ No newline at end of file diff --git a/src/SIL.Machine/Corpora/UsfmTextBase.cs b/src/SIL.Machine/Corpora/UsfmTextBase.cs index 7b0c016f..030580b7 100644 --- a/src/SIL.Machine/Corpora/UsfmTextBase.cs +++ b/src/SIL.Machine/Corpora/UsfmTextBase.cs @@ -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(" "); diff --git a/tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs b/tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs index db67e9a6..e1b25c76 100644 --- a/tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/UsfmMemoryTextTests.cs @@ -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 =