[GH-ISSUE #404] Text ending in a hash-character incorrectly detected as closed heading #334

Closed
opened 2026-03-03 01:25:49 +03:00 by kerem · 3 comments
Owner

Originally created by @mtausig on GitHub (Jun 7, 2021).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/404

I have a document with some code snippets, one of them being C#:

# Main

## Samples

### Java

foo

### C#

bar

The problem is, that this triggers rules MD003 and MD020 because the validator believes that I am trying to use a closed heading style in the last heading.

Demo sample: https://dlaa.me/markdownlint/#%25m%23%20Main%0A%0A%23%23%20Samples%0A%0A%23%23%23%20Java%0A%0Afoo%0A%0A%23%23%23%20C%23%0A%0Abar%0A

Originally created by @mtausig on GitHub (Jun 7, 2021). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/404 I have a document with some code snippets, one of them being `C#`: ``` # Main ## Samples ### Java foo ### C# bar ``` The problem is, that this triggers rules MD003 and MD020 because the validator believes that I am trying to use a closed heading style in the last heading. Demo sample: https://dlaa.me/markdownlint/#%25m%23%20Main%0A%0A%23%23%20Samples%0A%0A%23%23%23%20Java%0A%0Afoo%0A%0A%23%23%23%20C%23%0A%0Abar%0A
kerem 2026-03-03 01:25:49 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@nschonni commented on GitHub (Jun 7, 2021):

Yes, you need to escape the trailing # as ### C\#

<!-- gh-comment-id:855986057 --> @nschonni commented on GitHub (Jun 7, 2021): Yes, you need to escape the trailing `#` as `### C\#`
Author
Owner

@DavidAnson commented on GitHub (Jun 7, 2021):

Agreed. Here's your sample with that change: https://dlaa.me/markdownlint/#%25m%23%20Main%0A%0A%23%23%20Samples%0A%0A%23%23%23%20Java%0A%0Afoo%0A%0A%23%23%23%20C%5C%23%0A%0Abar%0A

<!-- gh-comment-id:856029846 --> @DavidAnson commented on GitHub (Jun 7, 2021): Agreed. Here's your sample with that change: https://dlaa.me/markdownlint/#%25m%23%20Main%0A%0A%23%23%20Samples%0A%0A%23%23%23%20Java%0A%0Afoo%0A%0A%23%23%23%20C%5C%23%0A%0Abar%0A
Author
Owner

@mtausig commented on GitHub (Jun 7, 2021):

Thank you. Didn't know that.

<!-- gh-comment-id:856037643 --> @mtausig commented on GitHub (Jun 7, 2021): Thank you. Didn't know that.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/markdownlint#334
No description provided.