diff --git a/src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs b/src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs index 5fea1947..047e3664 100644 --- a/src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs +++ b/src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs @@ -182,10 +182,10 @@ public void StartEmbed(UsfmParserState state, string marker) NextElement(marker); } - StartEmbed(state, CreateVerseRefs()); + StartEmbed(state, CreateNonVerseRef()); } - public virtual void StartEmbed(UsfmParserState state, IReadOnlyList scriptureRefs) { } + public virtual void StartEmbed(UsfmParserState state, ScriptureRef scriptureRef) { } public virtual void EndEmbed( UsfmParserState state, diff --git a/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs b/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs index f51e00ab..a9327306 100644 --- a/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs +++ b/src/SIL.Machine/Corpora/UpdateUsfmParserHandler.cs @@ -200,9 +200,9 @@ bool closed base.EndChar(state, marker, attributes, closed); } - public override void StartEmbed(UsfmParserState state, IReadOnlyList scriptureRefs) + public override void StartEmbed(UsfmParserState state, ScriptureRef scriptureRef) { - _embedRowTexts = AdvanceRows(scriptureRefs).ToList(); + _embedRowTexts = AdvanceRows(new[] { scriptureRef }).ToList(); _embedUpdated = _embedRowTexts.Count > 0; // strip out notes in verses that are being replaced @@ -407,8 +407,8 @@ private bool ReplaceWithNewTokens(UsfmParserState state, bool closed = true) ClearNewTokens(); // figure out when to skip the existing text - bool embedInNewVerseText = _replace.Any(r => r); - if (embedInNewVerseText && _embedUpdated) + bool embedInNewVerseText = _replace.Any(r => r) && inEmbed; + if (embedInNewVerseText || _embedUpdated) { if (_embedBehavior == UpdateUsfmIntraVerseMarkerBehavior.Strip) { diff --git a/tests/SIL.Machine.Tests/Corpora/UpdateUsfmParserHandlerTests.cs b/tests/SIL.Machine.Tests/Corpora/UpdateUsfmParserHandlerTests.cs index 40641fe8..1cb1f070 100644 --- a/tests/SIL.Machine.Tests/Corpora/UpdateUsfmParserHandlerTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/UpdateUsfmParserHandlerTests.cs @@ -45,8 +45,8 @@ public void GetUsfm_PreferExisting() { var rows = new List<(IReadOnlyList, string)> { - (ScrRef("MAT 1:6"), "Update 1"), - (ScrRef("MAT 1:7"), "Update 2"), + (ScrRef("MAT 1:1"), "Update 1"), + (ScrRef("MAT 1:2"), "Update 2"), }; var usfm = @"\id MAT - Test diff --git a/tests/SIL.Machine.Tests/Corpora/UsfmFileTextTests.cs b/tests/SIL.Machine.Tests/Corpora/UsfmFileTextTests.cs index 40391b66..c00888e2 100644 --- a/tests/SIL.Machine.Tests/Corpora/UsfmFileTextTests.cs +++ b/tests/SIL.Machine.Tests/Corpora/UsfmFileTextTests.cs @@ -82,7 +82,7 @@ public void GetRows_NonEmptyText_AllText() Assert.That(rows[1].Text, Is.EqualTo("Matthew")); Assert.That(rows[2].Ref, Is.EqualTo(ScriptureRef.Parse("MAT 1:0/3:ip", corpus.Versification))); - Assert.That(rows[2].Text, Is.EqualTo("An introduction to Matthew with an empty comment")); + Assert.That(rows[2].Text, Is.EqualTo("An introduction to Matthew")); Assert.That(rows[3].Ref, Is.EqualTo(ScriptureRef.Parse("MAT 1:0/3:ip/1:fe", corpus.Versification))); Assert.That(rows[3].Text, Is.EqualTo("This is an endnote.")); @@ -256,7 +256,7 @@ public void GetRows_IncludeMarkers_AllText() IText text = corpus["MAT"]; TextRow[] rows = text.GetRows().ToArray(); - Assert.That(rows, Has.Length.EqualTo(47)); + Assert.That(rows, Has.Length.EqualTo(46)); Assert.That(rows[2].Ref, Is.EqualTo(ScriptureRef.Parse("MAT 1:0/3:ip", corpus.Versification))); Assert.That(rows[2].Text, Is.EqualTo("An introduction to Matthew\\fe + \\ft This is an endnote.\\fe*"));