Skip to content

Commit

Permalink
Fix exception when parsing USFM with an empty verse paragraph
Browse files Browse the repository at this point in the history
- fixes #388
  • Loading branch information
ddaspit committed May 21, 2024
1 parent f4b27e5 commit 618b016
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/SIL.Machine/Corpora/ScriptureRefUsfmParserHandlerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace SIL.Machine.Corpora
{
public enum ScriptureTextType
{
None,
NonVerse,
Verse,
Note
Expand All @@ -25,7 +26,7 @@ protected ScriptureRefUsfmParserHandlerBase()
}

protected ScriptureTextType CurrentTextType =>
_curTextType.Count == 0 ? ScriptureTextType.NonVerse : _curTextType.Peek();
_curTextType.Count == 0 ? ScriptureTextType.None : _curTextType.Peek();

public override void EndUsfm(UsfmParserState state)
{
Expand Down Expand Up @@ -101,19 +102,19 @@ public override void EndPara(UsfmParserState state, string marker)

public override void StartRow(UsfmParserState state, string marker)
{
if (CurrentTextType == ScriptureTextType.NonVerse)
if (CurrentTextType == ScriptureTextType.NonVerse || CurrentTextType == ScriptureTextType.None)
StartParentElement(marker);
}

public override void EndRow(UsfmParserState state, string marker)
{
if (CurrentTextType == ScriptureTextType.NonVerse)
if (CurrentTextType == ScriptureTextType.NonVerse || CurrentTextType == ScriptureTextType.None)
EndParentElement();
}

public override void StartCell(UsfmParserState state, string marker, string align, int colspan)
{
if (CurrentTextType == ScriptureTextType.NonVerse)
if (CurrentTextType == ScriptureTextType.NonVerse || CurrentTextType == ScriptureTextType.None)
{
StartParentElement(marker);
StartNonVerseText(state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
\tr \tc1 Row two, column one. \tc2 Row two, column two.
\s1 Chapter \it Two \it*
\p
\p
\v 1 Chapter \add two\add*, verse \f + \fr 2:1: \ft This is a footnote.\f*one.
\v 2-3 Chapter two, // verse \fm ∆\fm*two.
\esb
Expand Down

0 comments on commit 618b016

Please sign in to comment.