igorshubovych / markdownlint-cli

MarkdownLint Command Line Interface
MIT License
855 stars 86 forks source link

Allow for inline disabling/enabling of rules #326

Closed harleypig closed 2 years ago

harleypig commented 2 years ago

I've looked through the code, tests and docs so if I've missed this I apologize.

Allow for inline disabling or enabling of rules for a specific line. My specific use case is I want to limit line length to 80 characters, but I have some lines with an embedded url (e.g., (text)[reallylongurl]) that won't line break because there are no spaces in it.

So, something like

<!-- markdownlint-disable: MD0013 -->
blah blah see (this)[reallylongurl]
harleypig commented 2 years ago

I think I've found what should work for my specific use case, but it doesn't seem to work with markdownlint-cli.

This rule for line length (MD013) has the following text:

This rule has an exception when there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle. To disable this exception, set the strict parameter to true to report an issue when any line is too long. To warn for lines that are too long and could be fixed but allow lines without spaces, set the stern parameter to true.

If I set the following in my .markdownlint.yaml file, the long lines with no whitespace past the length limit are still reported.

MD013:
  strict: true
  stern: true
DavidAnson commented 2 years ago

Info on inline configuration here: https://github.com/DavidAnson/markdownlint#configuration

I think the default behavior of MD013 corresponds to the behavior you want; enabling stern and strict is probably not something you should do.

harleypig commented 2 years ago

After looking at my mardown more carefully, I realized my editor (vim+conceal) was showing me text on the next line even though it was on the same line.

This is a non-issue. Thank you for your kind response.