Heading variations #75

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

Originally created by @mhomde on GitHub (Dec 6, 2016).

I've come across some heading variations that are not picked up by the parser

  • Any header where there's no space between # and the heading, for ex: #Heading

  • When headers are combined with markdown, ex: ###**HEADING**

Not sure if this goes against the spec but would be great if they could be covered somehow

Keep up the good work!

Originally created by @mhomde on GitHub (Dec 6, 2016). I've come across some heading variations that are not picked up by the parser * Any header where there's no space between # and the heading, for ex: `#Heading` * When headers are combined with markdown, ex:` ###**HEADING**` Not sure if this goes against the spec but would be great if they could be covered somehow Keep up the good work!
claunia added the questioninvalid labels 2026-01-29 14:25:13 +00:00
Author
Owner

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

Yes, it is part of the CommonMark specs: ATX headings: The opening sequence of # characters must be followed by a space or by the end of line.

@xoofx commented on GitHub (Dec 6, 2016): Yes, it is part of the [CommonMark specs: ATX headings](http://spec.commonmark.org/0.27/#atx-headings): _The opening sequence of # characters must be followed by a space or by the end of line._
Author
Owner

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

Note that as github is transitioning to Commonmark, they now follow the same rule:

#Heading is a plain text

@xoofx commented on GitHub (Dec 6, 2016): Note that as github is transitioning to Commonmark, they now follow the same rule: > #Heading is a plain text
Author
Owner

@mhomde commented on GitHub (Dec 6, 2016):

Can I write an extension or something to get around this? Reddit markdown is notoriously sloppy ... :/

@mhomde commented on GitHub (Dec 6, 2016): Can I write an extension or something to get around this? Reddit markdown is notoriously sloppy ... :/
Author
Owner

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

Yes, you can. You will have to modify the HeadingBlockParser to add a bool property in order to support this switch (some extensions like SoftlineBreakAsHardlineExtension are done like this)

@xoofx commented on GitHub (Dec 7, 2016): Yes, you can. You will have to modify the [HeadingBlockParser](https://github.com/lunet-io/markdig/blob/2c10ac59d3efb9a7821565100e35956767faf0a3/src/Markdig/Parsers/HeadingBlockParser.cs#L65) to add a bool property in order to support this switch (some extensions like [SoftlineBreakAsHardlineExtension](https://github.com/lunet-io/markdig/blob/2c10ac59d3efb9a7821565100e35956767faf0a3/src/Markdig/Extensions/Hardlines/SoftlineBreakAsHardlineExtension.cs) are done like this)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#75