[GH-ISSUE #205] MD026 handling of empty/null punctuation parameter is incorrect #2024

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

Originally created by @JoelSantosRico on GitHub (Jul 8, 2019).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/205

Hi,

I'm trying to break MD026 and allow some punctuation on headers. I follow the default values and try to allow .,;:!?", but it still mark the lines. Am I doing something wrong?

Kicad

Originally created by @JoelSantosRico on GitHub (Jul 8, 2019). Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/205 Hi, I'm trying to break MD026 and allow some punctuation on headers. I follow the default values and try to allow `.,;:!?"`, but it still mark the lines. Am I doing something wrong? ![Kicad](https://user-images.githubusercontent.com/46561171/60825783-656f1d00-a1a4-11e9-84a6-c7bc92ca9b8d.gif)
kerem 2026-03-07 20:03:47 +03:00
Author
Owner

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

It looks like you are doing everything correctly. One thing I notice is that you are modifying the user configuration - which is overridden by any project-level configuration. Could you please check your project for a .markdownlint.json file and include the output from the markdownlint tab in the output window at the bottom? That should help us understand where it is getting the configuration for that file. Thanks!

<!-- gh-comment-id:509330796 --> @DavidAnson commented on GitHub (Jul 8, 2019): It looks like you are doing everything correctly. One thing I notice is that you are modifying the user configuration - which is overridden by any project-level configuration. Could you please check your project for a `.markdownlint.json` file and include the output from the markdownlint tab in the output window at the bottom? That should help us understand where it is getting the configuration for that file. Thanks!
Author
Owner

@JoelSantosRico commented on GitHub (Jul 11, 2019):

EDIT: I was replying to you when I did a little test. What if punctuation was acting as items that are NOT allowed, instead of allowed? And that was it! Removing the semicolon from what I thought was the list of allowed punctuation removed the linting error, but other punctuation was still raising it. Leaving an empty string in punctuation doesn't allow all the punctuation, though, but defaults to "none allowed". I suspect there's a logic check somewhere that needs some reviewing.

======

Thanks for your quick reply.

I opened the file in a totally new workspace by left-clicking in the folder containing the MD files (a folder that doesn't have any .vscode folders, so it doesn't have any folder config either). I double-checked that the workspace and folder settings are empty.

This is my only entry in the user settings about markdownlint:

    "markdownlint.config": {
        "default": true,
        "MD007": false,
        "MD013": false,
        "MD024": {
            "siblings_only": true
        },
        "MD026": {
            "punctuation": ".,;:!?。,;:!?"
        },
        "MD033": {
            "allowed_elements": [
                "br",
                "p"
            ]
        },
    },

The output from the console is below:

[14:09:47] INFO: Loading user/workspace configuration for 'c:\Users\Joel\Workspace\production_testing\src\DTM_Complience_Test\doc\DTM_Test.md' (no configuration file in workspace folder).
[14:11:03] INFO: Linting for 'c:\Users\Joel\Workspace\production_testing\src\DTM_Complience_Test\doc\DTM_Test.md' will be run 'onType'.
[14:11:50] INFO: Resetting configuration cache due to '.markdownlint.{json,yaml,yml}' or setting change.

Other rules, like allowing
and

tags, work as expected, by tagging other tags (like ), but not

or

<!-- gh-comment-id:510481709 --> @JoelSantosRico commented on GitHub (Jul 11, 2019): EDIT: I was replying to you when I did a little test. What if punctuation was acting as items that are NOT allowed, instead of allowed? And that was it! Removing the semicolon from what I thought was the list of allowed punctuation removed the linting error, but other punctuation was still raising it. Leaving an empty string in punctuation doesn't allow all the punctuation, though, but defaults to "none allowed". I suspect there's a logic check somewhere that needs some reviewing. ====== Thanks for your quick reply. I opened the file in a totally new workspace by left-clicking in the folder containing the MD files (a folder that doesn't have any .vscode folders, so it doesn't have any folder config either). I double-checked that the workspace and folder settings are empty. This is my only entry in the user settings about markdownlint: ```json "markdownlint.config": { "default": true, "MD007": false, "MD013": false, "MD024": { "siblings_only": true }, "MD026": { "punctuation": ".,;:!?。,;:!?" }, "MD033": { "allowed_elements": [ "br", "p" ] }, }, ``` The output from the console is below: ```text [14:09:47] INFO: Loading user/workspace configuration for 'c:\Users\Joel\Workspace\production_testing\src\DTM_Complience_Test\doc\DTM_Test.md' (no configuration file in workspace folder). [14:11:03] INFO: Linting for 'c:\Users\Joel\Workspace\production_testing\src\DTM_Complience_Test\doc\DTM_Test.md' will be run 'onType'. [14:11:50] INFO: Resetting configuration cache due to '.markdownlint.{json,yaml,yml}' or setting change. ``` Other rules, like allowing <br> and <p> tags, work as expected, by tagging other tags (like <body>), but not <p> or <br>
Author
Owner

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

Sorry, I got confused as well! The behavior of the rule is to report a violation if any of the specified punctuation characters are found at the end of a header. Therefore, to allow a character in the list, it is necessary to remove that character from the list. The documentation for the rule covers this: https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md026---trailing-punctuation-in-heading

Your comment about the handling of an empty string does seem like a problem. I would also expect it to allow everything rather than nothing. Looking at the code, I can see why it behaves that way. I will use this issue as a reminder to correct that and update the documentation.

Sorry for the trouble – and thank you for the help!

<!-- gh-comment-id:510506753 --> @DavidAnson commented on GitHub (Jul 11, 2019): Sorry, I got confused as well! The behavior of the rule is to report a violation if any of the specified punctuation characters are found at the end of a header. Therefore, to _allow_ a character in the list, it is necessary to _remove_ that character from the list. The documentation for the rule covers this: https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md026---trailing-punctuation-in-heading Your comment about the handling of an empty string does seem like a problem. I would also expect it to allow everything rather than nothing. Looking at the code, I can see why it behaves that way. I will use this issue as a reminder to correct that and update the documentation. Sorry for the trouble – and thank you for the help!
Author
Owner

@JoelSantosRico commented on GitHub (Jul 12, 2019):

Ah! I misred it. I didn't "analysed" the example string, and assumed that the ? character was there. Happy that at least we got the "" string thing. Maybe the linter thinks that an empty string is the same as that rule not being there, and thus, defaulting to normal behaviour of "none allowed", instead of all allowed?

<!-- gh-comment-id:510916279 --> @JoelSantosRico commented on GitHub (Jul 12, 2019): Ah! I misred it. I didn't "analysed" the example string, and assumed that the ? character was there. Happy that at least we got the "" string thing. Maybe the linter thinks that an empty string is the same as that rule not being there, and thus, defaulting to normal behaviour of "none allowed", instead of all allowed?
Author
Owner

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

The empty string is falsy here, so the default set of characters is used instead:
github.com/DavidAnson/markdownlint@1ae512be69/lib/md026.js (L13)

<!-- gh-comment-id:510924677 --> @DavidAnson commented on GitHub (Jul 12, 2019): The empty string is falsy here, so the default set of characters is used instead: https://github.com/DavidAnson/markdownlint/blob/1ae512be697e56de7d397e93b8f8e01b949da147/lib/md026.js#L13
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#2024
No description provided.