1010use League \CommonMark \Block \Element \ListItem ;
1111use League \CommonMark \Inline \Element \Code ;
1212use League \CommonMark \Inline \Element \Emphasis ;
13+ use League \CommonMark \Inline \Element \HtmlInline ;
1314use League \CommonMark \Inline \Element \Image ;
1415use League \CommonMark \Inline \Element \Link ;
1516use League \CommonMark \Inline \Element \Newline ;
2021use Markdom \Common \ContentType ;
2122use Markdom \Common \EmphasisLevel ;
2223use Markdom \Dispatcher \Exception \DispatcherException ;
24+ use Markdom \Dispatcher \HtmlProcessor \HtmlProcessorInterface ;
2325use Markdom \HandlerInterface \HandlerInterface ;
2426
2527/**
@@ -35,6 +37,11 @@ final class MarkdomEventBridge
3537 */
3638 private $ markdomHandler ;
3739
40+ /**
41+ * @var HtmlProcessorInterface
42+ */
43+ private $ htmlProcessor ;
44+
3845 /**
3946 * @var Node
4047 */
@@ -44,10 +51,12 @@ final class MarkdomEventBridge
4451 * MarkdomHandlerEventDispatcher constructor.
4552 *
4653 * @param HandlerInterface $commonmarkHandler
54+ * @param HtmlProcessorInterface $htmlProcessor
4755 */
48- public function __construct (HandlerInterface $ commonmarkHandler )
56+ public function __construct (HandlerInterface $ commonmarkHandler, HtmlProcessorInterface $ htmlProcessor )
4957 {
5058 $ this ->markdomHandler = $ commonmarkHandler ;
59+ $ this ->htmlProcessor = $ htmlProcessor ;
5160 }
5261
5362 /**
@@ -203,7 +212,7 @@ private function transmitContainerBeginEvent(Node $node)
203212 $ comment = trim ($ comment );
204213 $ this ->markdomHandler ->onCommentBlock ($ comment );
205214 } else {
206- // TODO: Handle HTML block
215+ $ this -> htmlProcessor -> handleHtmlBlock ( $ node , $ this -> markdomHandler );
207216 }
208217 break ;
209218 case DocumentProcessor::BLOCK_NODE_IMAGE :
@@ -303,8 +312,6 @@ private function transmitContainerEndEvent(Node $node)
303312 /** @var HtmlBlock $node */
304313 if ($ node ->getType () == $ node ::TYPE_2_COMMENT ) {
305314 $ this ->dispatchBlockEndEvents ($ node , BlockType::TYPE_COMMENT );
306- } else {
307- // TODO: Handle HTML block
308315 }
309316 break ;
310317 case DocumentProcessor::BLOCK_NODE_IMAGE :
@@ -375,7 +382,8 @@ private function transmitInlineBeginEvent(Node $node)
375382 $ this ->markdomHandler ->onCodeContent ($ node ->getContent ());
376383 break ;
377384 case DocumentProcessor::INLINE_NODE_HTML_INLINE :
378- // TODO: Handle inline HTML
385+ /** @var HtmlInline $node */
386+ $ this ->htmlProcessor ->handleInlineHtml ($ node , $ this ->markdomHandler );
379387 break ;
380388 case DocumentProcessor::INLINE_NODE_NEWLINE :
381389 $ this ->dispatchContentBeginEvents (ContentType::TYPE_LINE_BREAK );
@@ -408,7 +416,6 @@ private function transmitInlineEndEvent()
408416 $ this ->dispatchContentEndEvents ($ this ->recentInlineNode , ContentType::TYPE_CODE );
409417 break ;
410418 case DocumentProcessor::INLINE_NODE_HTML_INLINE :
411- // TODO: Handle inline HTML
412419 break ;
413420 case DocumentProcessor::INLINE_NODE_NEWLINE :
414421 $ this ->dispatchContentEndEvents ($ this ->recentInlineNode , ContentType::TYPE_LINE_BREAK );
0 commit comments