Skip to content

bug: MD012 for whitespace around pyml comments #1208

@XavierChanth

Description

@XavierChanth

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions