Removing of HeadingBlockParser from pipeline.BlockParsers is not affect setext headings #77

Closed
opened 2026-01-29 14:25:20 +00:00 by claunia · 1 comment
Owner

Originally created by @magicxor on GitHub (Dec 20, 2016).

I'm trying to make stop markdig from parsing headers (h1-h6).

        public static MarkdownPipelineBuilder DisableHeadings(this MarkdownPipelineBuilder pipeline)
        {
            var headingBlockParser = pipeline.BlockParsers.Find<HeadingBlockParser>();
            if (headingBlockParser != null)
            {
                pipeline.BlockParsers.Remove(headingBlockParser);
            }
            return pipeline;
        }

But this code doesn't affect setext headings.
Is it normal behavior? How can I solve this problem?
Thanks.

Originally created by @magicxor on GitHub (Dec 20, 2016). I'm trying to make stop markdig from parsing headers (h1-h6). ``` public static MarkdownPipelineBuilder DisableHeadings(this MarkdownPipelineBuilder pipeline) { var headingBlockParser = pipeline.BlockParsers.Find<HeadingBlockParser>(); if (headingBlockParser != null) { pipeline.BlockParsers.Remove(headingBlockParser); } return pipeline; } ``` But this code doesn't affect [setext headings](https://github.com/lunet-io/markdig/blob/4f52e893eef8401ad7e50f7442c3dc01996f3e91/src/Markdig.Benchmarks/spec.md#setext-headings). Is it normal behavior? How can I solve this problem? Thanks.
claunia added the enhancementPR Welcome! labels 2026-01-29 14:25:20 +00:00
Author
Owner

@xoofx commented on GitHub (Dec 21, 2016):

Unfortunately, disabling setext headings requires an internal change because the parsing is performed inside the ParagraphBlockParser. It is perfectly possible to do it by adding a boolean property on this parser, and provide an extension for it (PR welcome!)

@xoofx commented on GitHub (Dec 21, 2016): Unfortunately, disabling setext headings requires an internal change because the parsing is performed inside the [ParagraphBlockParser](https://github.com/lunet-io/markdig/blob/master/src/Markdig/Parsers/ParagraphBlockParser.cs#L74). It is perfectly possible to do it by adding a boolean property on this parser, and provide an extension for it (PR welcome!)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#77