[GH-ISSUE #468] Counter-intuitive behavior after enable/disable + bug with ignore next line. #2233

Closed
opened 2026-03-07 20:05:50 +03:00 by kerem · 6 comments
Owner

Originally created by @adithyabsk on GitHub (Dec 19, 2021).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/468

So I just ran into two separate issues. I was trying to disable an error for a really long iframe embed that I am including in my markdown but was running into all sorts of trouble. I think I was dealing with two separate bugs which is what made it all the more confusing

It seems that if you do the following, it re-enables all the previous ignored rules including deprecated rules such as MD002.

<!-- markdownlint-disable -->
<iframe>Some really long iframe snippet</iframe>
<!-- markdownlint-enable -->

If you instead try to use disable next line in the presence of front-matter, the line does not actually get disabled since it is not offset in the code by the length of the front matter. (I put together a pull request for this issue https://github.com/DavidAnson/markdownlint/pull/469)

<!-- markdownlint-disable-next-line -->
<iframe>Some really long iframe snippet</iframe>
Originally created by @adithyabsk on GitHub (Dec 19, 2021). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/468 So I just ran into two separate issues. I was trying to disable an error for a really long iframe embed that I am including in my markdown but was running into all sorts of trouble. I think I was dealing with two separate bugs which is what made it all the more confusing It seems that if you do the following, it re-enables all the previous ignored rules including deprecated rules such as MD002. ```md <!-- markdownlint-disable --> <iframe>Some really long iframe snippet</iframe> <!-- markdownlint-enable --> ``` If you instead try to use disable next line in the presence of front-matter, the line does not actually get disabled since it is not offset in the code by the length of the front matter. (I put together a pull request for this issue https://github.com/DavidAnson/markdownlint/pull/469) ```md <!-- markdownlint-disable-next-line --> <iframe>Some really long iframe snippet</iframe> ```
kerem 2026-03-07 20:05:50 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@nschonni commented on GitHub (Dec 19, 2021):

https://github.com/DavidAnson/markdownlint#configuration explains that you need to capture first if you want to restore the same ruleset

<!-- gh-comment-id:997333962 --> @nschonni commented on GitHub (Dec 19, 2021): https://github.com/DavidAnson/markdownlint#configuration explains that you need to `capture` first if you want to restore the same ruleset
Author
Owner

@adithyabsk commented on GitHub (Dec 19, 2021):

explains that you need to capture first if you want to restore the same ruleset

Ah, you know what. Now that I've spent some time running through the code base re-reading that section makes a lot more sense. Don't think the wording could be made any clearer--I just missed the capture example.

And, yep. The capture/restore pattern seems to work. I promise I did run through the issues before creating this one, and I hope this issue helps someone else who missed that part of the docs.

<!-- markdownlint-capture -->
<!-- markdownlint-disable -->
<iframe>long snippet</iframe>
<!-- markdownlint-restore -->

Thought, it still would be nice to be able to use the one-liner which I was able to reproduce as an error.

<!-- gh-comment-id:997334177 --> @adithyabsk commented on GitHub (Dec 19, 2021): > explains that you need to capture first if you want to restore the same ruleset Ah, you know what. Now that I've spent some time running through the code base re-reading that section makes a lot more sense. Don't think the wording could be made any clearer--I just missed the capture example. And, yep. The capture/restore pattern seems to work. I promise I did run through the issues before creating this one, and I hope this issue helps someone else who missed that part of the docs. ```md <!-- markdownlint-capture --> <!-- markdownlint-disable --> <iframe>long snippet</iframe> <!-- markdownlint-restore --> ``` Thought, it still would be nice to be able to use the one-liner which I was able to reproduce as an error.
Author
Owner

@DavidAnson commented on GitHub (Dec 19, 2021):

Glad you got this sorted out! If there's an example of something not working, please show it and I'll have a look.

<!-- gh-comment-id:997335557 --> @DavidAnson commented on GitHub (Dec 19, 2021): Glad you got this sorted out! If there's an example of something not working, please show it and I'll have a look.
Author
Owner

@DavidAnson commented on GitHub (Dec 19, 2021):

I think that's what you did with #469?

<!-- gh-comment-id:997335718 --> @DavidAnson commented on GitHub (Dec 19, 2021): I think that's what you did with #469?
Author
Owner

@adithyabsk commented on GitHub (Dec 19, 2021):

I think that's what you did with #469?

Yep, I was just typing out a message, I think there might be a bug with the way that disable line is handled with front matter. The example is in the PR.

<!-- gh-comment-id:997335742 --> @adithyabsk commented on GitHub (Dec 19, 2021): > I think that's what you did with #469? Yep, I was just typing out a message, I think there might be a bug with the way that disable line is handled with front matter. The example is in the PR.
Author
Owner

@DavidAnson commented on GitHub (Dec 23, 2021):

Closing this, applying the PR in #469.

<!-- gh-comment-id:1000017515 --> @DavidAnson commented on GitHub (Dec 23, 2021): Closing this, applying the PR in #469.
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#2233
No description provided.