Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Enhancement - MD005 - Inconsistent indentation for list items at the same level - Needs to list the indentation levels #1514

Open
HariSekhon opened this issue Feb 24, 2025 · 1 comment
Labels

Comments

@HariSekhon
Copy link

HariSekhon commented Feb 24, 2025

When getting hit with this on a markdown file, having a long list of lines to check is tedious, eg:

github-actions.md:44: MD005 Inconsistent indentation for list items at the same level
github-actions.md:46: MD005 Inconsistent indentation for list items at the same level
github-actions.md:47: MD005 Inconsistent indentation for list items at the same level
github-actions.md:49: MD005 Inconsistent indentation for list items at the same level
github-actions.md:50: MD005 Inconsistent indentation for list items at the same level
github-actions.md:51: MD005 Inconsistent indentation for list items at the same level
github-actions.md:369: MD005 Inconsistent indentation for list items at the same level
github-actions.md:373: MD005 Inconsistent indentation for list items at the same level
github-actions.md:382: MD005 Inconsistent indentation for list items at the same level

This results in having to check across hundreds of lines making it hard to find the culprit lines.

Requested Feature

Print the list indentation count of spaces of each line referenced in the output.

Workaround

I've just rustled up a couple Bash scripts to allow me to find the offending lists.

This script prefixed the indentation levels of the list lines reported by MDL:

https://github.com/HariSekhon/DevOps-Bash-tools/blob/master/markdown/mdl_list_indentations.sh

But they all showed a multiple of 2 indentations as expected, so I quickly wrote this:

https://github.com/HariSekhon/DevOps-Bash-tools/blob/master/markdown/markdown_list_indentations.sh

which shows the count of spaces on every list line, which showed that the lines causing this error weren't the ones listed by mdl but rather further up the page in the index section which was generated using another script:

https://github.com/HariSekhon/DevOps-Bash-tools/blob/master/markdown/markdown_generate_index.sh

which had been overridden to generate the index with 3 space indentation instead of 2 space indexation like the rest of the page was using.

@DavidAnson
Copy link
Owner

This library already does what you want as you can see in the demo here: https://dlaa.me/markdownlint/#%25m%23%20Issue%201514%0A%0A1.%20Item%0A%20%20%201.%20Item%0A%20%20%20%201.%20Item%0A

What's more, violations of this rule can typically be fixed automatically by the CLI tools or VS Code extension.

From your comments, it seems you may be using the "mdl" tool which is based on Ruby and lives over here: https://github.com/markdownlint/markdownlint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants