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

bug: MD012 for whitespace around pyml comments #1208

Closed
9 of 13 tasks
XavierChanth opened this issue Sep 18, 2024 · 8 comments
Closed
9 of 13 tasks

bug: MD012 for whitespace around pyml comments #1208

XavierChanth opened this issue Sep 18, 2024 · 8 comments

Comments

@XavierChanth
Copy link

XavierChanth commented Sep 18, 2024

Prerequisites

  • Are you running the latest version of this application?
  • Have you checked the Frequently Asked Questions document?
  • Have you simplified the bug report to the essential details?
    • Do you have a distinct command line to report?
    • Can you clearly state the configuration for this bug report?
    • Do you have a minimal document that highlights this bug?
    • Are any required files (configuration or Markdown document) attached to the issue?
  • Did you perform a cursory search of other issues to look for related issues?

Bug Report

Please replace any of [these areas] in the paragraphs below with the requested information.

Bug Type

  • Assertion Failure
  • Documentation
  • Scan/Rule not working as expected
  • Fix/Rule not working as expected
  • Other
    Parsing rules

Description

pyml disable-num-lines comments are ignored in the parsing of documents, thus appearing as a double line in scenarios like:

Some markdown here

<!--pyml disable-num-lines 5 md013-->

My 10 lines
...

Both line 2 and 4 of my example are being flagged as a double line (MD012), but they don't appear as a double line if the comment is not marked with pyml.

But this doesn't trigger md012 (no pyml annotation):

Some markdown here

<!--disable-num-lines 5 md013-->

My 10 lines
...

Obviously, this doesn't disable md013 though.

The reason that this is a problem is that most markdown formatters will pad comment blocks like this. I haven't found any markdown formatters that allow you to disable comment formatting, so please point me to one if you are aware of it.

There are two workarounds, that I've found:

  1. Modify the md012 maximum with -s plugins.md012.maximum=$#2
    But this still causes problems around headers due to md022.

  2. Disable md012 outright
    I would prefer not to, and it still has issues with md022.

Potential solutions:

I think it would be a great feature to have a flag that tells the parser to completely ignore any blank lines which follow comments with a pyml in them, this way the following scenario would still work:

Some markdown here

<!--pyml disable-next-line md013-->

My really really long line ...

Specifics

What operating system and version are you running into this behavior on?

Occurring in both macOS (local) and GitHub actions ubuntu-latest runner

What version are you seeing this behavior in? (Run pip list or pipenv run pip list and look for the entry beside pymarkdownlnt.)

0.9.23

Are there any extra steps that need to be taken before executing the application?

N/A

What is the command line you invoke to get this behavior?

cat <file> | pymarkdownlnt scan-stdin

Are you using a configuration file? Either on the command line or one of the implicit configuration files? If so, attach that file to this issue.

N/A

What Markdown document causes this behavior to manifest? Attach that file to this issue.

README.md

Actual Behavior

MD012 warning for whitespace around comments annotated with pyml

Expected Behavior

No MD012 warning

@XavierChanth XavierChanth changed the title Ignore bug: MD012 for whitespace around pyml comments Sep 18, 2024
@jackdewinter
Copy link
Owner

Cool insights... will look into this in the coming week.

@jackdewinter
Copy link
Owner

This has been fixed, will make it into the next release.

@XavierChanth
Copy link
Author

This has been fixed, will make it into the next release.

Yay! Thanks so much!

@jackdewinter
Copy link
Owner

my mistake, this made it into the last release.

@XavierChanth
Copy link
Author

my mistake, this made it into the last release.

Ah good to know, thanks for making this change!

@cpswan
Copy link

cpswan commented Nov 21, 2024

Hi @jackdewinter thanks for making progress on this, and thanks also for creating and maintaining pymarkdown.

I'm one of @XavierChanth's colleagues, and we've been working together on dealing with this (as I'm the one who introduced pymarkdown to some of our repos).

I just did a quick test, and whilst the original problem with md012 seems to be resolved in 0.9.25 there now seems to be a similar issue with md022. So when I scan a markdown file that contains something like:

## My header

<!-- pyml disable-num-lines 3 md011,md013-->

Some long lines

I get: MD022: Headings should be surrounded by blank lines. [Expected: 1; Actual: 2; Below] (blanks-around-headings,blanks-around-headers)

@jackdewinter
Copy link
Owner

yup... I thought about that too, but was hoping that you would not find it until I had a chance to work on it. If you do not mind, could you file a separate issue, linking this issue to it? And for that one, just state this as an example and to double check any "multiple line" rules. If not, I will probably get to it in early december, and will create one then.

@jackdewinter
Copy link
Owner

Thanks... appreciate it.

jackdewinter added a commit that referenced this issue Dec 9, 2024
jackdewinter added a commit that referenced this issue Dec 9, 2024
* - [Issue 1208](#1208)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants