@@ -57,10 +57,13 @@ private LineNode ParseLine(LineNode lastLine)
5757 ParseStart ( @"\n" , false ) ; // We want to set a terminator, so we need to call ParseStart
5858 // LIST_ITEM / HEADING automatically closes the previous PARAGRAPH
5959 var node = ParseListItem ( ) ?? ParseHeading ( ) ?? ParseCompactParagraph ( lastLine ) ;
60- if ( lastLine ? . Inlines . LastNode is PlainText pt && pt . Content . Length == 0 )
60+ if ( lastLine is IInlineContainer lastLineContainer )
6161 {
62- // This can happen because we appended a PlainText("") at (A) in ParseLineEnd
63- pt . Remove ( ) ;
62+ if ( lastLineContainer . Inlines . LastNode is PlainText pt && pt . Content . Length == 0 )
63+ {
64+ // This can happen because we appended a PlainText("") at (A) in ParseLineEnd
65+ pt . Remove ( ) ;
66+ }
6467 }
6568 if ( node != null )
6669 Accept ( ) ;
@@ -197,7 +200,7 @@ private ListItem ParseListItem()
197200 ParseStart ( ) ;
198201 var prefix = ConsumeToken ( "[*#:;]+|-{4,}| " ) ;
199202 if ( prefix == null ) return ParseFailed < ListItem > ( ) ;
200- var node = new ListItem { Prefix = prefix } ;
203+ var node = new ListItem { Prefix = prefix } ;
201204 ParseRun ( RunParsingMode . Run , node , false ) ; // optional
202205 return ParseSuccessful ( node ) ;
203206 }
@@ -234,7 +237,7 @@ private Heading ParseHeading()
234237 var temp = ConsumeToken ( barExpr ) ;
235238 Debug . Assert ( temp != null ) ;
236239 var node = new Heading ( ) ;
237- var parsedSegments = new List < InlineContainer > ( ) ;
240+ var parsedSegments = new List < IInlineContainer > ( ) ;
238241 while ( true )
239242 {
240243 ParseStart ( ) ; // <-- B
@@ -273,7 +276,7 @@ private Heading ParseHeading()
273276 node . Inlines . AddFrom ( parsedSegments [ i ] . Inlines ) ;
274277 if ( i < parsedSegments . Count - 1 )
275278 {
276- IWikitextLineInfo si = parsedSegments [ i + 1 ] ;
279+ var si = ( IWikitextLineInfo ) parsedSegments [ i + 1 ] ;
277280 var bar = new PlainText ( new string ( '=' , level ) ) ;
278281 bar . SetLineInfo ( si . StartLineNumber , si . StartLinePosition - level ,
279282 si . StartLineNumber , si . StartLinePosition ) ;
@@ -311,10 +314,10 @@ private LineNode ParseCompactParagraph(LineNode lastNode)
311314 if ( mergeTo != null )
312315 {
313316 // This won't throw exception. See (A) in ParseLineEnd.
314- var paraTail = ( PlainText ) mergeTo . Inlines . LastNode ;
317+ var paraTail = ( PlainText ) mergeTo . Inlines . LastNode ;
315318 paraTail . Content += "\n " ;
316319 IWikitextLineInfo paraTailSpan = paraTail ;
317- Debug . Assert ( ( ( IWikitextLineInfo ) mergeTo ) . EndLinePosition == paraTailSpan . EndLinePosition ) ;
320+ Debug . Assert ( ( ( IWikitextLineInfo ) mergeTo ) . EndLinePosition == paraTailSpan . EndLinePosition ) ;
318321 paraTail . ExtendLineInfo ( paraTailSpan . EndLineNumber + 1 , 0 ) ;
319322 mergeTo . ExtendLineInfo ( paraTailSpan . EndLineNumber + 1 , 0 ) ;
320323 }
@@ -334,7 +337,7 @@ private LineNode ParseCompactParagraph(LineNode lastNode)
334337 /// RUN
335338 /// </summary>
336339 /// <returns><c>true</c> if one or more nodes has been parsed.</returns>
337- private bool ParseRun ( RunParsingMode mode , InlineContainer container , bool setLineNumber )
340+ private bool ParseRun ( RunParsingMode mode , IInlineContainer container , bool setLineNumber )
338341 {
339342 ParseStart ( ) ;
340343 var parsedAny = false ;
@@ -376,7 +379,7 @@ private bool ParseRun(RunParsingMode mode, InlineContainer container, bool setLi
376379 // Note that the content of RUN should not be empty.
377380 if ( parsedAny )
378381 {
379- ParseSuccessful ( container , setLineNumber ) ;
382+ ParseSuccessful ( ( Node ) container , setLineNumber ) ;
380383 return true ;
381384 }
382385 else
@@ -392,7 +395,7 @@ private InlineNode ParseInline()
392395 ?? ParseWikiLink ( )
393396 ?? ParseExternalLink ( )
394397 ?? ParseFormatSwitch ( )
395- ?? ( InlineNode ) ParsePartialPlainText ( ) ;
398+ ?? ( InlineNode ) ParsePartialPlainText ( ) ;
396399 }
397400
398401 private InlineNode ParseExpandable ( )
@@ -413,7 +416,7 @@ private WikiLink ParseWikiLink()
413416 else
414417 return ParseFailed < WikiLink > ( ) ;
415418 }
416- var node = new WikiLink { Target = target } ;
419+ var node = new WikiLink { Target = target } ;
417420 if ( ConsumeToken ( @"\|" ) != null )
418421 {
419422 var text = new Run ( ) ;
@@ -460,7 +463,7 @@ private ExternalLink ParseExternalLink()
460463 return ParseFailed < ExternalLink > ( ) ;
461464 }
462465 }
463- var node = new ExternalLink { Target = target , Brackets = brackets } ;
466+ var node = new ExternalLink { Target = target , Brackets = brackets } ;
464467 if ( brackets )
465468 {
466469 // Parse text
0 commit comments