@@ -182,7 +182,6 @@ public IEnumerable<ChapterDelta> ToChapterDeltas(XDocument usxDoc)
182182 state . CurRef = GetParagraphRef ( nextIds , style , style ) ;
183183 }
184184 ProcessChildNodes ( elem , chapterDelta , invalidNodes , state ) ;
185- SegmentEnded ( chapterDelta , state . CurRef ) ;
186185 if ( ! canContainVerseText )
187186 state . CurRef = null ;
188187 InsertPara ( elem , chapterDelta , invalidNodes , state ) ;
@@ -321,7 +320,6 @@ private void ProcessChildNode(
321320 {
322321 state . CurRef = $ "cell_{ state . TableIndex } _{ rowIndex } _{ cellIndex } ";
323322 ProcessChildNode ( cell , newDelta , invalidNodes , state ) ;
324- SegmentEnded ( newDelta , state . CurRef ) ;
325323 var attrs = new JObject (
326324 new JProperty ( "table" , tableAttributes ) ,
327325 new JProperty ( "row" , rowAttributes )
@@ -363,7 +361,6 @@ private static void ChapterEnded(List<ChapterDelta> chapterDeltas, Delta chapter
363361 {
364362 if ( state . ImpliedParagraph )
365363 {
366- SegmentEnded ( chapterDelta , state . CurRef ) ;
367364 chapterDelta . Insert ( '\n ' ) ;
368365 state . ImpliedParagraph = false ;
369366 }
@@ -376,7 +373,6 @@ private static void ChapterEnded(List<ChapterDelta> chapterDeltas, Delta chapter
376373 private static void InsertVerse ( XElement elem , Delta newDelta , HashSet < XNode > invalidNodes , ParseState state )
377374 {
378375 var verse = ( string ) elem . Attribute ( "number" ) ;
379- SegmentEnded ( newDelta , state . CurRef ) ;
380376 state . CurRef = $ "verse_{ state . CurChapter } _{ verse } ";
381377 newDelta . InsertEmbed ( "verse" , GetAttributes ( elem ) , attributes : AddInvalidInlineAttribute ( invalidNodes , elem ) ) ;
382378 }
@@ -421,34 +417,6 @@ private static void InsertPara(XElement elem, Delta newDelta, HashSet<XNode> inv
421417 newDelta . Insert ( "\n " , attributes ) ;
422418 }
423419
424- private static void SegmentEnded ( Delta newDelta , string ? segRef )
425- {
426- if ( segRef == null )
427- return ;
428-
429- if ( newDelta . Ops . Count == 0 )
430- {
431- newDelta . InsertBlank ( segRef ) ;
432- }
433- else
434- {
435- JToken lastOp = newDelta . Ops [ ^ 1 ] ;
436- string lastOpText = "" ;
437- if ( lastOp [ Delta . InsertType ] . Type == JTokenType . String )
438- lastOpText = ( string ) lastOp [ Delta . InsertType ] ;
439- var embed = lastOp [ Delta . InsertType ] as JObject ;
440- var attrs = ( JObject ) lastOp [ Delta . Attributes ] ;
441- if (
442- ( embed != null && ( embed [ "verse" ] != null || embed [ "chapter" ] != null ) )
443- || ( attrs != null && ( attrs [ "book" ] != null || attrs [ "para" ] != null || attrs [ "table" ] != null ) )
444- || lastOpText . EndsWith ( '\n ' )
445- )
446- {
447- newDelta . InsertBlank ( segRef ) ;
448- }
449- }
450- }
451-
452420 private static string GetParagraphRef ( Dictionary < string , int > nextIds , string key , string prefix )
453421 {
454422 if ( ! nextIds . ContainsKey ( key ) )
@@ -751,7 +719,9 @@ private static List<XNode> ProcessDelta(Delta delta)
751719 case "para" :
752720 // end of a book or para block
753721 for ( int j = 0 ; j < text . Length ; j ++ )
754- content . Add ( CreateContainerElement ( prop . Name , prop . Value , childNodes . Peek ( ) ) ) ;
722+ content . Add (
723+ CreateContainerElement ( prop . Name , prop . Value , j == 0 ? childNodes . Peek ( ) : null )
724+ ) ;
755725 childNodes . Peek ( ) . Clear ( ) ;
756726 break ;
757727
0 commit comments