@@ -28,8 +28,8 @@ public class UpdateUsfmParserHandler : ScriptureRefUsfmParserHandlerBase
2828 private readonly List < UsfmToken > _newTokens ;
2929 private readonly string _idText ;
3030 private readonly UpdateUsfmTextBehavior _textBehavior ;
31- private readonly UpdateUsfmIntraVerseMarkerBehavior _subComponentBehavior ;
32- private readonly UpdateUsfmIntraVerseMarkerBehavior _formattingBehavior ;
31+ private readonly UpdateUsfmIntraVerseMarkerBehavior _embeddedBehavior ;
32+ private readonly UpdateUsfmIntraVerseMarkerBehavior _styleBehavior ;
3333 private readonly Stack < bool > _replace ;
3434 private int _rowIndex ;
3535 private int _tokenIndex ;
@@ -38,8 +38,8 @@ public UpdateUsfmParserHandler(
3838 IReadOnlyList < ( IReadOnlyList < ScriptureRef > , string ) > rows = null ,
3939 string idText = null ,
4040 UpdateUsfmTextBehavior textBehavior = UpdateUsfmTextBehavior . PreferExisting ,
41- UpdateUsfmIntraVerseMarkerBehavior subComponentBehavior = UpdateUsfmIntraVerseMarkerBehavior . Preserve ,
42- UpdateUsfmIntraVerseMarkerBehavior formattingBehavior = UpdateUsfmIntraVerseMarkerBehavior . Strip
41+ UpdateUsfmIntraVerseMarkerBehavior embeddedBehavior = UpdateUsfmIntraVerseMarkerBehavior . Preserve ,
42+ UpdateUsfmIntraVerseMarkerBehavior styleBehavior = UpdateUsfmIntraVerseMarkerBehavior . Strip
4343 )
4444 {
4545 _rows = rows ?? Array . Empty < ( IReadOnlyList < ScriptureRef > , string ) > ( ) ;
@@ -48,8 +48,8 @@ public UpdateUsfmParserHandler(
4848 _idText = idText ;
4949 _replace = new Stack < bool > ( ) ;
5050 _textBehavior = textBehavior ;
51- _subComponentBehavior = subComponentBehavior ;
52- _formattingBehavior = formattingBehavior ;
51+ _embeddedBehavior = embeddedBehavior ;
52+ _styleBehavior = styleBehavior ;
5353 }
5454
5555 public IReadOnlyList < UsfmToken > Tokens => _tokens ;
@@ -196,31 +196,31 @@ bool closed
196196 base . EndChar ( state , marker , attributes , closed ) ;
197197 }
198198
199- public override void StartSubComponent ( UsfmParserState state , string marker , string caller , string category )
199+ public override void StartEmbedded ( UsfmParserState state , string marker , string caller , string category )
200200 {
201201 // strip out notes in verses that are being replaced
202202 if ( ReplaceWithNewTokens ( state ) )
203203 SkipTokens ( state ) ;
204204 else
205205 CollectTokens ( state ) ;
206206
207- base . StartSubComponent ( state , marker , caller , category ) ;
207+ base . StartEmbedded ( state , marker , caller , category ) ;
208208 }
209209
210- public override void EndSubComponent (
210+ public override void EndEmbedded (
211211 UsfmParserState state ,
212212 string marker ,
213213 IReadOnlyList < UsfmAttribute > attributes ,
214214 bool closed
215215 )
216216 {
217217 // strip out notes in verses that are being replaced
218- if ( ReplaceWithNewTokens ( state , closed : closed , endSubComponent : true ) )
218+ if ( ReplaceWithNewTokens ( state , closed : closed , endEmbedded : true ) )
219219 SkipTokens ( state ) ;
220220 else
221221 CollectTokens ( state ) ;
222222
223- base . EndSubComponent ( state , marker , attributes , closed ) ;
223+ base . EndEmbedded ( state , marker , attributes , closed ) ;
224224 }
225225
226226 public override void Ref ( UsfmParserState state , string marker , string display , string target )
@@ -289,13 +289,13 @@ protected override void EndNonVerseText(UsfmParserState state, ScriptureRef scri
289289 PopNewTokens ( ) ;
290290 }
291291
292- protected override void StartSubComponentText ( UsfmParserState state , ScriptureRef scriptureRef )
292+ protected override void StartEmbeddedText ( UsfmParserState state , ScriptureRef scriptureRef )
293293 {
294294 IReadOnlyList < string > rowTexts = AdvanceRows ( new [ ] { scriptureRef } ) ;
295295 PushNewTokens ( rowTexts . Select ( t => new UsfmToken ( t + " " ) ) ) ;
296296 }
297297
298- protected override void EndSubComponentText ( UsfmParserState state , ScriptureRef scriptureRef )
298+ protected override void EndEmbeddedText ( UsfmParserState state , ScriptureRef scriptureRef )
299299 {
300300 PopNewTokens ( ) ;
301301 }
@@ -365,7 +365,7 @@ private void SkipTokens(UsfmParserState state)
365365 _tokenIndex = state . Index + 1 + state . SpecialTokenCount ;
366366 }
367367
368- private bool ReplaceWithNewTokens ( UsfmParserState state , bool closed = true , bool endSubComponent = false )
368+ private bool ReplaceWithNewTokens ( UsfmParserState state , bool closed = true , bool endEmbedded = false )
369369 {
370370 bool untranslatableParagraph =
371371 state . ParaTag ? . Marker != null && UsfmStylesheet . IsUntranslatedParagraph ( state . ParaTag . Marker ) ;
@@ -379,11 +379,10 @@ private bool ReplaceWithNewTokens(UsfmParserState state, bool closed = true, boo
379379 }
380380
381381 bool newText = _replace . Count > 0 && _replace . Peek ( ) ;
382- bool inSubComponent = state . SubComponentTag != null || endSubComponent ;
383- bool inSubComponentText =
384- CurrentTextType == ScriptureTextType . SubComponentText
385- && ! UsfmStylesheet . IsSubComponentText ( state . Token . Marker ) ;
386- bool isFormattingTag = state . Token . Marker != null && ! UsfmStylesheet . IsSubComponentPart ( state . Token . Marker ) ;
382+ bool inEmbedded = state . EmbeddedTag != null || endEmbedded ;
383+ bool inEmbeddedText =
384+ CurrentTextType == ScriptureTextType . EmbeddedText && ! UsfmStylesheet . IsEmbeddedText ( state . Token . Marker ) ;
385+ bool isStyleTag = state . Token . Marker != null && ! UsfmStylesheet . IsEmbeddedPart ( state . Token . Marker ) ;
387386
388387 bool existingText = state
389388 . Tokens . Skip ( _tokenIndex )
@@ -394,7 +393,7 @@ private bool ReplaceWithNewTokens(UsfmParserState state, bool closed = true, boo
394393 ! untranslatableParagraph
395394 && newText
396395 && ( ! existingText || _textBehavior == UpdateUsfmTextBehavior . PreferNew )
397- && ( ! inSubComponent || inSubComponentText ) ;
396+ && ( ! inEmbedded || inEmbeddedText ) ;
398397
399398 if ( useNewTokens )
400399 AddNewTokens ( ) ;
@@ -404,20 +403,20 @@ private bool ReplaceWithNewTokens(UsfmParserState state, bool closed = true, boo
404403
405404 // figure out when to skip the existing text
406405 bool withinNewText = _replace . Any ( r => r ) ;
407- if ( withinNewText && inSubComponent )
406+ if ( withinNewText && inEmbedded )
408407 {
409- if ( _subComponentBehavior == UpdateUsfmIntraVerseMarkerBehavior . Strip )
408+ if ( _embeddedBehavior == UpdateUsfmIntraVerseMarkerBehavior . Strip )
410409 return true ;
411410
412- if ( ! inSubComponentText )
411+ if ( ! inEmbeddedText )
413412 return false ;
414413 }
415414
416415 bool skipTokens = useNewTokens && closed ;
417416
418- if ( newText && isFormattingTag )
417+ if ( newText && isStyleTag )
419418 {
420- skipTokens = _formattingBehavior == UpdateUsfmIntraVerseMarkerBehavior . Strip ;
419+ skipTokens = _styleBehavior == UpdateUsfmIntraVerseMarkerBehavior . Strip ;
421420 }
422421 return skipTokens ;
423422 }
0 commit comments