[GH-ISSUE #32] Require structure only for certain files / paths #23

Closed
opened 2026-03-03 01:23:06 +03:00 by kerem · 2 comments
Owner

Originally created by @pascalberger on GitHub (Nov 16, 2016).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/32

Is there a way to have MD043 only required for certain files or paths, but not for others?

Or is there a way to exclude this rule for certain files?

I tried with <!-- markdownlint-disable MD043 --> but couldn't get it working.

Originally created by @pascalberger on GitHub (Nov 16, 2016). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/32 Is there a way to have [MD043](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md043---required-header-structure) only required for certain files or paths, but not for others? Or is there a way to exclude this rule for certain files? I tried with `<!-- markdownlint-disable MD043 -->` but couldn't get it working.
kerem 2026-03-03 01:23:06 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@DavidAnson commented on GitHub (Nov 17, 2016):

Customizing the config object for MD043 for each file is one approach. Another is turning MD043 off via a comment as you show above. To verify this, I changed example/good.md to:

# good.md

This file passes all rules.

And example/standalone.js to:

"use strict";

var markdownlint = require("../lib/markdownlint");

var options = {
  "files": [ "good.md" ],
  "config": {
    "MD041": false,
    "MD043": {
      "headers": [
        "# header"
      ]
    }
  },
  "resultVersion": 1
};

var result = markdownlint.sync(options);
console.log(result.toString(true));

At this point, the output is:

good.md: 1: MD043/required-headers Required header structure [Expected: # header; Actual: # good.md]

Updating good.md to disable MD043 with an inline comment looks like:

<!-- markdownlint-disable MD043 -->

# good.md

This file passes all rules.

And, indeed, suppresses the MD043 warning above.

Could you please double-check your configuration? Or tell me how to reproduce the problem?

Thanks!

<!-- gh-comment-id:261159325 --> @DavidAnson commented on GitHub (Nov 17, 2016): Customizing the config object for `MD043` for each file is one approach. Another is turning `MD043` off via a comment as you show above. To verify this, I changed `example/good.md` to: ``` md # good.md This file passes all rules. ``` And `example/standalone.js` to: ``` js "use strict"; var markdownlint = require("../lib/markdownlint"); var options = { "files": [ "good.md" ], "config": { "MD041": false, "MD043": { "headers": [ "# header" ] } }, "resultVersion": 1 }; var result = markdownlint.sync(options); console.log(result.toString(true)); ``` At this point, the output is: ``` good.md: 1: MD043/required-headers Required header structure [Expected: # header; Actual: # good.md] ``` Updating `good.md` to disable `MD043` with an inline comment looks like: ``` md <!-- markdownlint-disable MD043 --> # good.md This file passes all rules. ``` And, indeed, suppresses the `MD043` warning above. Could you please double-check your configuration? Or tell me how to reproduce the problem? Thanks!
Author
Owner

@pascalberger commented on GitHub (Nov 17, 2016):

Thanks, I got it working by suppressing MD043 with a comment (but which needed at the end of the document, otherwise it would raise an MD041 issue).

<!-- gh-comment-id:261178753 --> @pascalberger commented on GitHub (Nov 17, 2016): Thanks, I got it working by suppressing `MD043` with a comment (but which needed at the end of the document, otherwise it would raise an [MD041](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md041---first-line-in-file-should-be-a-top-level-header) issue).
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#23
No description provided.