@@ -39,6 +39,10 @@ protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor)
3939 _admonitionData = new Dictionary < string , string > ( ) ;
4040 var info = processor . Line . AsSpan ( ) ;
4141
42+ if ( processor . Context is not ParserContext context )
43+ throw new Exception ( "Expected parser context to be of type ParserContext" ) ;
44+
45+
4246 if ( info . EndsWith ( "{toctree}" ) )
4347 return new TocTreeBlock ( this , _admonitionData ) ;
4448
@@ -67,30 +71,22 @@ protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor)
6771 return new DropdownBlock ( this , _admonitionData ) ;
6872
6973 if ( info . IndexOf ( "{image}" ) > 0 )
70- return new ImageBlock ( this , _admonitionData ) ;
74+ return new ImageBlock ( this , _admonitionData , context ) ;
7175
7276 if ( info . IndexOf ( "{figure}" ) > 0 )
73- return new FigureBlock ( this , _admonitionData ) ;
77+ return new FigureBlock ( this , _admonitionData , context ) ;
7478
7579 if ( info . IndexOf ( "{figure-md}" ) > 0 )
76- return new FigureBlock ( this , _admonitionData ) ;
80+ return new FigureBlock ( this , _admonitionData , context ) ;
7781
7882 if ( info . IndexOf ( "{mermaid}" ) > 0 )
7983 return new MermaidBlock ( this , _admonitionData ) ;
8084
8185 if ( info . IndexOf ( "{include}" ) > 0 )
82- {
83- if ( processor . Context is MystMarkdownParserContext context )
84- return new IncludeBlock ( this , _admonitionData , context ) ;
85- //todo emit error
86- }
86+ return new IncludeBlock ( this , _admonitionData , context ) ;
8787
8888 if ( info . IndexOf ( "{literalinclude}" ) > 0 )
89- {
90- if ( processor . Context is MystMarkdownParserContext context )
91- return new LiteralIncludeBlock ( this , _admonitionData , context ) ;
92- //todo emit error
93- }
89+ return new LiteralIncludeBlock ( this , _admonitionData , context ) ;
9490
9591 foreach ( var admonition in _admonitions )
9692 {
0 commit comments