[GH-ISSUE #198] MD018 triggered inside HTML pre/code block #2018

Closed
opened 2026-03-07 20:03:44 +03:00 by kerem · 7 comments
Owner

Originally created by @nschonni on GitHub (Jun 14, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/198

Looks like # inside pre/code blocks still get picked up as Markdown headers
EX:

<pre><code>
#Place the cluster in maintenance mode
sudo crm configure property maintenance-mode=true

#Create Pacemaker resources for the Azure agent
sudo crm configure primitive rsc_azure-events ocf:heartbeat:azure-events op monitor interval=10s
sudo crm configure clone cln_azure-events rsc_azure-events

#Take the cluster out of maintenance mode
sudo crm configure property maintenance-mode=false
</code></pre>

From github.com/MicrosoftDocs/azure-docs@ceeac2e6be/articles/virtual-machines/workloads/sap/high-availability-guide-suse-pacemaker.md

Originally created by @nschonni on GitHub (Jun 14, 2019). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/198 Looks like `#` inside pre/code blocks still get picked up as Markdown headers EX: ```md <pre><code> #Place the cluster in maintenance mode sudo crm configure property maintenance-mode=true #Create Pacemaker resources for the Azure agent sudo crm configure primitive rsc_azure-events ocf:heartbeat:azure-events op monitor interval=10s sudo crm configure clone cln_azure-events rsc_azure-events #Take the cluster out of maintenance mode sudo crm configure property maintenance-mode=false </code></pre> ``` From https://github.com/MicrosoftDocs/azure-docs/blob/ceeac2e6be7a281f128a590e978c43415e09070f/articles/virtual-machines/workloads/sap/high-availability-guide-suse-pacemaker.md
kerem 2026-03-07 20:03:44 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Jun 14, 2019):

That’s not a Markdown code block - it’s an HTML code block. Is that deliberate? If so, why? I don’t think there’s precedent for markdownlint to recognize HTML structures.

<!-- gh-comment-id:501988624 --> @DavidAnson commented on GitHub (Jun 14, 2019): That’s not a Markdown code block - it’s an HTML code block. Is that deliberate? If so, why? I don’t think there’s precedent for markdownlint to recognize HTML structures.
Author
Owner

@nschonni commented on GitHub (Jun 14, 2019):

Not sure why they decided to use a manual pre/code block here, but I would have thought it would treat it similarly to a code fence. I know this style can be required inside tables, since code fences don't always work properly there.

<!-- gh-comment-id:502122191 --> @nschonni commented on GitHub (Jun 14, 2019): Not sure why they decided to use a manual pre/code block here, but I would have thought it would treat it similarly to a code fence. I know this style can be required inside tables, since code fences don't always work properly there.
Author
Owner

@DavidAnson commented on GitHub (Jun 14, 2019):

My current thinking is that this is not proper Markdown and represents an anti-pattern. I’m not looking to maintain an HTML parser/linter in addition to this one - which would seem necessary to catch cases like this or to find spaces inside a bold or italics or link tag (all of which are rules today which someone might reasonably be expected to extend to HTML). Unless someone points to widespread use of this pattern that seems justified, my thinking is to close this issue as being outside the scope of the project.

I hope that reasoning makes sense!

<!-- gh-comment-id:502136876 --> @DavidAnson commented on GitHub (Jun 14, 2019): My current thinking is that this is not proper Markdown and represents an anti-pattern. I’m not looking to maintain an HTML parser/linter in addition to this one - which would seem necessary to catch cases like this or to find spaces inside a bold or italics or link tag (all of which are rules today which someone might reasonably be expected to extend to HTML). Unless someone points to widespread use of this pattern that seems justified, my thinking is to close this issue as being outside the scope of the project. I hope that reasoning makes sense!
Author
Owner

@nschonni commented on GitHub (Jun 14, 2019):

Yup, it's a weird edge case. Looking at some of the other blocks, it looks like they're using this style to use <b> tags to add emphasis to text inside the blocks. I don't think that works inside the regular code fences.
I could see treating these as code fences, but I can see that would have problems with other rules (EX: adding language to the code fence)

<!-- gh-comment-id:502146209 --> @nschonni commented on GitHub (Jun 14, 2019): Yup, it's a weird edge case. Looking at some of the other blocks, it looks like they're using this style to use `<b>` tags to add emphasis to text inside the blocks. I don't think that works inside the regular code fences. I could see treating these as code fences, but I can see that would have problems with other rules (EX: adding language to the code fence)
Author
Owner

@DavidAnson commented on GitHub (Jun 14, 2019):

Yep, there is already a rule saying not to include HTML elements in your Markdown; supporting this would be in defiance of that!

<!-- gh-comment-id:502148606 --> @DavidAnson commented on GitHub (Jun 14, 2019): Yep, there is already a rule saying not to include HTML elements in your Markdown; supporting this would be in defiance of that!
Author
Owner

@nschonni commented on GitHub (Jun 14, 2019):

I'll see if I can give some other examples besides the <b> thing here. Markdown tables commonly need HTML for things like code fences, lists, line breaks anyway, so that might be a better test case. That wouldn't apply to the MD018 rule though

<!-- gh-comment-id:502169132 --> @nschonni commented on GitHub (Jun 14, 2019): I'll see if I can give some other examples besides the `<b>` thing here. Markdown tables commonly need HTML for things like code fences, lists, line breaks anyway, so that might be a better test case. That wouldn't apply to the MD018 rule though
Author
Owner

@DavidAnson commented on GitHub (Jul 27, 2019):

Closing for now.

<!-- gh-comment-id:515655775 --> @DavidAnson commented on GitHub (Jul 27, 2019): Closing for now.
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#2018
No description provided.