@@ -42,6 +42,11 @@ final class MarkdomEventBridge
4242 */
4343 private $ htmlProcessor ;
4444
45+ /**
46+ * @var bool
47+ */
48+ private $ dispatchCommentBlocks ;
49+
4550 /**
4651 * @var Node
4752 */
@@ -51,12 +56,17 @@ final class MarkdomEventBridge
5156 * MarkdomHandlerEventDispatcher constructor.
5257 *
5358 * @param HandlerInterface $commonmarkHandler
59+ * @param bool $dispatchCommentBlocks
5460 * @param HtmlProcessorInterface $htmlProcessor
5561 */
56- public function __construct (HandlerInterface $ commonmarkHandler , HtmlProcessorInterface $ htmlProcessor )
57- {
62+ public function __construct (
63+ HandlerInterface $ commonmarkHandler ,
64+ $ dispatchCommentBlocks ,
65+ HtmlProcessorInterface $ htmlProcessor
66+ ) {
5867 $ this ->markdomHandler = $ commonmarkHandler ;
5968 $ this ->htmlProcessor = $ htmlProcessor ;
69+ $ this ->dispatchCommentBlocks = $ dispatchCommentBlocks ;
6070 }
6171
6272 /**
@@ -200,7 +210,7 @@ private function transmitContainerBeginEvent(Node $node)
200210 break ;
201211 case DocumentProcessor::BLOCK_NODE_HTML_BLOCK :
202212 /** @var HtmlBlock $node */
203- if ($ node ->getType () == $ node ::TYPE_2_COMMENT ) {
213+ if ($ node ->getType () == $ node ::TYPE_2_COMMENT && $ this -> dispatchCommentBlocks ) {
204214 $ this ->dispatchBlockBeginEvents (BlockType::TYPE_COMMENT );
205215 $ comment = $ node ->getStringContent ();
206216 if (mb_strpos ($ comment , '<!-- ' ) === 0 ) {
@@ -213,7 +223,7 @@ private function transmitContainerBeginEvent(Node $node)
213223 $ this ->markdomHandler ->onCommentBlock ($ comment );
214224 } else {
215225 $ this ->htmlProcessor ->handleHtmlBlock ($ node , $ this ->markdomHandler );
216- if (!is_null ($ node ->next ())){
226+ if (!is_null ($ node ->next ())) {
217227 $ this ->markdomHandler ->onNextBlock ();
218228 }
219229 }
0 commit comments