Skip to content

Commit

Permalink
remove 6 casts in TripleColonBlockParser.TryContinue
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Oct 18, 2024
1 parent 0062a2d commit 0bc0ecf
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ public override BlockState TryOpen(BlockProcessor processor)
public override BlockState TryContinue(BlockProcessor processor, Block block)
{
var slice = processor.Line;
var endingTripleColons = ((TripleColonBlock)block).EndingTripleColons;
var colonBlock = (TripleColonBlock) block;
var endingTripleColons = colonBlock.EndingTripleColons;

if (((TripleColonBlock)block).Extension.GetType() != typeof(ImageExtension) || ((TripleColonBlock)block).Extension.GetType() != typeof(VideoExtension)
|| endingTripleColons)
if (colonBlock.Extension.GetType() != typeof(ImageExtension) ||
colonBlock.Extension.GetType() != typeof(VideoExtension) ||
endingTripleColons)
{
if (processor.IsBlankLine)
{
Expand All @@ -119,14 +121,14 @@ public override BlockState TryContinue(BlockProcessor processor, Block block)
if (!ExtensionsHelper.MatchStart(ref slice, ":::"))
{
// create a block for the image long description
((TripleColonBlock)block).Body = slice.ToString();
colonBlock.Body = slice.ToString();
ExtensionsHelper.ResetLineIndent(processor);
return BlockState.Continue;
}

ExtensionsHelper.SkipSpaces(ref slice);

var extensionName = ((TripleColonBlock)block).Extension.Name;
var extensionName = colonBlock.Extension.Name;

if (!ExtensionsHelper.MatchStart(ref slice, extensionName) || !ExtensionsHelper.MatchStart(ref slice, "-end"))
{
Expand Down Expand Up @@ -155,13 +157,13 @@ public override BlockState TryContinue(BlockProcessor processor, Block block)

block.UpdateSpanEnd(slice.End);
block.IsOpen = false;
(block as TripleColonBlock).Closed = true;
colonBlock.Closed = true;

return BlockState.BreakDiscard;
}

block.IsOpen = false;
(block as TripleColonBlock).Closed = true;
colonBlock.Closed = true;

if (!processor.IsBlankLine)
{
Expand Down

0 comments on commit 0bc0ecf

Please sign in to comment.