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

MD018 false positive inside code blocks using hl_lines #176

Open
jacobrosenthal opened this issue Jul 21, 2017 · 3 comments
Open

MD018 false positive inside code blocks using hl_lines #176

jacobrosenthal opened this issue Jul 21, 2017 · 3 comments
Labels
bug Something isn't working

Comments

@jacobrosenthal
Copy link

Dont quite understand this yet, but this example false positives

https://gist.github.com/jacobrosenthal/e49f7d225b40b2bcc59a4f5d029776bc

test.md:5: MD018 No space after hash on atx style header
test.md:5: MD025 Multiple top level headers in the same document
@markeganfuller
Copy link

Also seeing this with pymdown-extensions Tabbed Fences:

```c tab="C"
#include <stdio.h>

int main (int argc, char *argv[])
{
    int i;
    for (i=0; i <6; i+=1) {
        printf("%d\n", i);
    }

    return 0;
}
```

Which gives:

test.md:2: MD022 Headers should be surrounded by blank lines
test.md:2: MD033 Inline HTML

At a guess the way code blocks are detected doesn't handle extra stuff on the end of the line.

@markeganfuller
Copy link

This seems to be an issue with the underlying parser Kramdown, specifically this regex

Which will match:

```example
one
```

but not

```example fail
two
```

@NaomiReeves NaomiReeves added the bug Something isn't working label Dec 2, 2019
@HariSekhon
Copy link

HariSekhon commented Mar 3, 2024

I'm hitting this issue in hash comments inside any code blocks for shell and python like this:

# comment
somecommand
# comment
somecode

Where the comments are at the top like this I've moved them out of the code blocks so there is no precedeing # but where code blocks contain useful comments mid way through this is not practical:

command1 &&
command2
# this one is really necessary to work around github issue xxx...
command3 ||
command4

eg:

celery.md:153: MD022 Headers should be surrounded by blank lines
celery.md:158: MD022 Headers should be surrounded by blank lines
celery.md:153: MD025 Multiple top level headers in the same document
celery.md:158: MD025 Multiple top level headers in the same document

I don't want to disable MD022 and MD025 entirely in .mdlrc because I'm already excluding more and more and these are two useful checks that find out when I've ported my private KB in conf format to md format but left single hash comments which are not the right level of heading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants