[GH-ISSUE #703] Rule MD013 fails with long blocks comments in v0.27.0 #2364

Closed
opened 2026-03-07 20:07:04 +03:00 by kerem · 5 comments
Owner

Originally created by @svg153 on GitHub (Jan 18, 2023).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/703

Problem Description

What is actually happening

With new markdownlint v0.27.0 the MD013 rule fails with long block comments more than line length configured.

What is the expected behavior

Work as previous version markdownlint v0.26.2: MD013 rule does not fail with comment blocks longer than the maximum configured line.

Context

We are using pre-commit in our CI, and we have a workflow to detect new pre-commit hooks versions. This workflow detects the new markdownlint-cli v0.33.0, and creates a PR.
image
In this PR, pre-commit runs with the new markdownlint-cli hook version v0.33.0 and fails checking the MD013:
image
But in this file there is a comment:
image

I investigate a little bit...

Questions

  • Is it a feature or is it a bug?
  • What could we do to ignore this case? For now, we are not going to update the version.
Originally created by @svg153 on GitHub (Jan 18, 2023). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/703 # Problem Description ## What is actually happening With new [markdownlint v0.27.0][markdownlint-0.27.0] the `MD013` rule fails with long block comments more than line length configured. ## What is the expected behavior Work as previous version [markdownlint v0.26.2][markdownlint-0.26.2]: `MD013` rule does not fail with comment blocks longer than the maximum configured line. ## Context We are using pre-commit in our CI, and we have a workflow to detect new pre-commit hooks versions. This workflow detects the new [markdownlint-cli v0.33.0](https://github.com/igorshubovych/markdownlint-cli/releases/tag/v0.33.0), and creates a PR. ![image](https://user-images.githubusercontent.com/9192031/213154589-6afac58d-0ce6-4f9f-97fb-afd8affbda37.png) In this PR, pre-commit runs with the new [markdownlint-cli hook version v0.33.0](https://github.com/igorshubovych/markdownlint-cli/releases/tag/v0.33.0) and fails checking the `MD013`: ![image](https://user-images.githubusercontent.com/9192031/213156340-a2238699-3151-420d-9682-a86fe3d5d909.png) But in this file there is a comment: ![image](https://user-images.githubusercontent.com/9192031/213156705-9328d5c7-0765-4547-8cc0-8ed7ddd3a3a7.png) I investigate a little bit... - markdownlint-cli pre-commit hook use the same version of markdownlint-cli. - markdownlint-cli updated from [v0.32.2](https://github.com/igorshubovych/markdownlint-cli/releases/tag/v0.32.2) to [v0.33.0](https://github.com/igorshubovych/markdownlint-cli/releases/tag/v0.33.0) ([changelog diff](https://github.com/igorshubovych/markdownlint-cli/compare/v0.32.2...v0.33.0)) - According to the changelog of [v0.33.0](https://github.com/igorshubovych/markdownlint-cli/releases/tag/v0.33.0) the markdownlint js dependency was updated by Dependabot in this [PR](https://github.com/igorshubovych/markdownlint-cli/pull/348) to the [markdownlint v0.27.0][markdownlint-0.27.0] where the `MD013` rule was updated too.([changelog diff](https://github.com/DavidAnson/markdownlint/compare/v0.26.2...v0.27.0) - Tested in pre-commit with [DavidAnson/markdownlint-cli2 v0.6.0](https://github.com/DavidAnson/markdownlint-cli2) ![image](https://user-images.githubusercontent.com/9192031/213172302-7a4fbeff-6c7e-41b4-b95f-97c410243aa3.png) ![image](https://user-images.githubusercontent.com/9192031/213172656-216653ae-a297-4f01-bf9f-27f655520ee4.png) - I have tried to find another case like tables to ignore block comments, as described in [doc/MD013.md describe](https://github.com/DavidAnson/markdownlint/blob/2e63bf7dd81bdde4c36f6dcc91f7aec91eb4450e/doc/md013.md#md013---line-length). But I can't find anything, related to the `MD013.md` rule or other global configuration. - I do not found similar case to mine (long block comment) in the [`test/MD011-MD021.md` file](https://github.com/DavidAnson/markdownlint/blob/56f379b0fc341f2aaba97ab3da9a1191b373c872/test/MD011-MD021.md) ## Questions - Is it a feature or is it a bug? - What could we do to ignore this case? For now, we are not going to update the version. [markdownlint-0.26.2]: https://github.com/DavidAnson/markdownlint/releases/tag/v0.26.2 [markdownlint-0.27.0]: https://github.com/DavidAnson/markdownlint/releases/tag/v0.27.0
kerem 2026-03-07 20:07:04 +03:00
Author
Owner

@DavidAnson commented on GitHub (Jan 18, 2023):

This doesn't seem to have been an intended change looking at the history of that release on my phone, but I'm also not sure it's wrong. That comment line exceeds the configured line length, so the warning you see is appropriate. You ask about a way to suppress checking comments, but why not Wrap your comment line to the configured length? I'd rather not add another parameter if it's not needed. Another option would be to use the inline comments to disable/restore the rule just around your comment, but that will be annoying if you have many of these.

I will have a look to see when/why this started, but I'm not sure I will change the behavior.

<!-- gh-comment-id:1387448587 --> @DavidAnson commented on GitHub (Jan 18, 2023): This doesn't seem to have been an intended change looking at the history of that release on my phone, but I'm also not sure it's wrong. That comment line exceeds the configured line length, so the warning you see is appropriate. You ask about a way to suppress checking comments, but why not Wrap your comment line to the configured length? I'd rather not add another parameter if it's not needed. Another option would be to use the inline comments to disable/restore the rule just around your comment, but that will be annoying if you have many of these. I will have a look to see when/why this started, but I'm not sure I will change the behavior.
Author
Owner

@svg153 commented on GitHub (Jan 23, 2023):

Thank you very much.
Our problem was that we had many files with that error. With your answer, we have proceeded to change all the files.
It might be interesting to write a test case for this case to define its behavior ? If not, we could close this issue.

<!-- gh-comment-id:1400058618 --> @svg153 commented on GitHub (Jan 23, 2023): Thank you very much. Our problem was that we had many files with that error. With your answer, we have proceeded to change all the files. It might be interesting to write a test case for this case to define its behavior ? If not, we could close this issue.
Author
Owner

@DavidAnson commented on GitHub (Jan 23, 2023):

Yes, I will add a test when I investigate this.

<!-- gh-comment-id:1400635618 --> @DavidAnson commented on GitHub (Jan 23, 2023): Yes, I will add a test when I investigate this.
Author
Owner

@DavidAnson commented on GitHub (Feb 26, 2023):

Note to self: f0bb4c639b introduces the regression according to git bisect. Very brief visual review suggests notSpaceCrLfRe is the cause.

<!-- gh-comment-id:1445275675 --> @DavidAnson commented on GitHub (Feb 26, 2023): Note to self: f0bb4c639b95468181d4ad37d448694f9297b35a introduces the regression according to `git bisect`. Very brief visual review suggests `notSpaceCrLfRe` is the cause.
Author
Owner

@DavidAnson commented on GitHub (Feb 27, 2023):

After some thought, I am going to leave the new behavior alone. Someone who enables the line-length rule wants to know when their lines are too long. There are some constructs today that can get an exception (code, headings, tables), but they are all things that can be difficult to reduce the line length for. Most comment scenarios should be pretty amenable to shortening (as you seem to have done in your project), so I am NOT going to add an exclusion at this time. I WILL add a test case for this like you suggest and will use that to close the issue. Thank you for bringing this up!

<!-- gh-comment-id:1445608053 --> @DavidAnson commented on GitHub (Feb 27, 2023): After some thought, I am going to leave the new behavior alone. Someone who enables the line-length rule wants to know when their lines are too long. There are some constructs today that can get an exception (code, headings, tables), but they are all things that can be difficult to reduce the line length for. Most comment scenarios should be pretty amenable to shortening (as you seem to have done in your project), so I am NOT going to add an exclusion at this time. I WILL add a test case for this like you suggest and will use that to close the issue. Thank you for bringing this up!
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#2364
No description provided.