Using a subset of the markdown syntax #133

Closed
opened 2026-01-29 14:28:19 +00:00 by claunia · 4 comments
Owner

Originally created by @xt0rted on GitHub (Aug 20, 2017).

I want to use a subset of the markdown syntax (bold, italic, underline, strike, lists, paragraphs) and would like the rest of the syntax to render as plain text (# Text would render as-is instead of <h1>Text</h1>). Is there a way to adjust the settings so I can achieve this type of setup?

Originally created by @xt0rted on GitHub (Aug 20, 2017). I want to use a subset of the markdown syntax (bold, italic, underline, strike, lists, paragraphs) and would like the rest of the syntax to render as plain text (`# Text` would render as-is instead of `<h1>Text</h1>`). Is there a way to adjust the settings so I can achieve this type of setup?
claunia added the question label 2026-01-29 14:28:19 +00:00
Author
Owner

@xoofx commented on GitHub (Aug 21, 2017):

You should be able to remove the relevant parsers from the MarkdownPipelineBuilder (by modifying the registered parsers in InlineParsers and BlockParsers through the builder)

c761fa2243/src/Markdig/MarkdownPipelineBuilder.cs (L27-L49)

You might run into some trouble to disable some constructions that are hardcoded in some parsers (like the settext heading in the ParagraphBlockParser) as they would require a few changes in the code to make it possible. But nothing impossible...

@xoofx commented on GitHub (Aug 21, 2017): You should be able to remove the relevant parsers from the `MarkdownPipelineBuilder` (by modifying the registered parsers in `InlineParsers` and `BlockParsers` through the builder) https://github.com/lunet-io/markdig/blob/c761fa22438e036f4b17fe64cab95ba1efd6122b/src/Markdig/MarkdownPipelineBuilder.cs#L27-L49 You might run into some trouble to disable some constructions that are hardcoded in some parsers (like the settext heading in the `ParagraphBlockParser`) as they would require a few changes in the code to make it possible. But nothing impossible...
Author
Owner

@xt0rted commented on GitHub (May 7, 2018):

@xoofx I finally got around to playing with this and was wondering if what I'm seeing is expected behavior since you said some things are hardcoded.

My parsers are setup like so:

pipeline.BlockParsers.Clear();
pipeline.BlockParsers.Add(new Markdig.Parsers.ListBlockParser());
pipeline.BlockParsers.Add(new Markdig.Parsers.ParagraphBlockParser());

pipeline.InlineParsers.Clear();
pipeline.InlineParsers.Add(new Markdig.Parsers.Inlines.EmphasisInlineParser());

If my markdown is ---, ___, or *** then it's rendered as <hr /> even though the ThematicBreakParser isn't included. If I comment out the ListBlockParser then these aren't converted to html. Is this correct? Why would the ListBlockParser be creating <hr /> elements when there's a parser for this which isn't even setup?

@xt0rted commented on GitHub (May 7, 2018): @xoofx I finally got around to playing with this and was wondering if what I'm seeing is expected behavior since you said some things are hardcoded. My parsers are setup like so: ```csharp pipeline.BlockParsers.Clear(); pipeline.BlockParsers.Add(new Markdig.Parsers.ListBlockParser()); pipeline.BlockParsers.Add(new Markdig.Parsers.ParagraphBlockParser()); pipeline.InlineParsers.Clear(); pipeline.InlineParsers.Add(new Markdig.Parsers.Inlines.EmphasisInlineParser()); ``` If my markdown is `---`, `___`, or `***` then it's rendered as `<hr />` even though the `ThematicBreakParser` isn't included. If I comment out the `ListBlockParser` then these aren't converted to html. Is this correct? Why would the `ListBlockParser` be creating `<hr />` elements when there's a parser for this which isn't even setup?
Author
Owner

@xoofx commented on GitHub (May 7, 2018):

If my markdown is ---, ___, or *** then it's rendered as


even though the ThematicBreakParser isn't included. If I comment out the ListBlockParser then these aren't converted to html. Is this correct? Why would the ListBlockParser be creating
elements when there's a parser for this which isn't even setup?

Han, unfortunately, you are hitting a workaround in the code... that would require a bit modification to work. Currently, the ListBlockParser is accessing a singleton ThematicBreakParser.Default while it should instead query for the ThematicBreakParser in its initialize method, and use it if it is present. It is not a big change, so PR welcome.

@xoofx commented on GitHub (May 7, 2018): > If my markdown is ---, ___, or *** then it's rendered as <hr /> even though the ThematicBreakParser isn't included. If I comment out the ListBlockParser then these aren't converted to html. Is this correct? Why would the ListBlockParser be creating <hr /> elements when there's a parser for this which isn't even setup? Han, unfortunately, you are hitting a workaround in the code... that would require a bit modification to work. Currently, the `ListBlockParser` is accessing a singleton `ThematicBreakParser.Default` while it should instead query for the ThematicBreakParser in its initialize method, and use it if it is present. It is not a big change, so PR welcome.
Author
Owner

@xt0rted commented on GitHub (May 18, 2018):

I'll be taking a look at this in the coming weeks hopefully.

@xt0rted commented on GitHub (May 18, 2018): I'll be taking a look at this in the coming weeks hopefully.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#133