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

Rule MD010 does not exclude code blocks. #737

Closed
jackdewinter opened this issue Aug 12, 2023 · 13 comments
Closed

Rule MD010 does not exclude code blocks. #737

jackdewinter opened this issue Aug 12, 2023 · 13 comments

Comments

@jackdewinter
Copy link
Owner

There is configuration for handling these, but nothing to act on.

@officel
Copy link

officel commented Aug 18, 2023

I hit this problem today. Do you have a plan to fix it?

I record the commands and their execution results in a markdown.
Today I am experimenting with options for the dig command and I don't want to replace the recording of the results with spaces.

It would be nice if code_blocks: false would work.

Thank you.

@jackdewinter
Copy link
Owner Author

Its on my list of things to fix prior to the next release. Probably within the next week or so.

jackdewinter added a commit that referenced this issue Aug 27, 2023
* #737 - adding fix to rule md010, and changes required to make that happen
* updating to latest dev packages
@jackdewinter
Copy link
Owner Author

Have the detection logic in for fenced code blocks, not indented code block. That will come next.
Also, current implementation will take:

1.  xx
    ```code
\thas\ttab
    ```

and allow both tabs, not just the tab in the code block. That fix is more involved, and looking into it for a future fix.

@jackdewinter
Copy link
Owner Author

This should be addressed with the v0.9.13 release. Please let me know if those changes work for you!

@officel

This comment was marked as resolved.

@officel

This comment was marked as resolved.

@jackdewinter
Copy link
Owner Author

Try.. https://github.com/jackdewinter/pymarkdown/releases/tag/v0.9.13.3

the release verification pipeline did not trigger as expected... and forgot to do a manual check.

@officel
Copy link

officel commented Sep 5, 2023

Thank you!
I have tried but I still can't seem to ignore the inside of the code block.

$ git diff --cached
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 7165851..58faaec 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -23,7 +23,7 @@ repos:
       - id: end-of-file-fixer
       - id: trailing-whitespace
   - repo: https://github.com/jackdewinter/pymarkdown
-    rev: v0.9.12
+    rev: v0.9.13.3
     hooks:
       - id: pymarkdown
         exclude: |
diff --git a/.pymarkdown.json b/.pymarkdown.json
index 462caff..8057cc5 100644
--- a/.pymarkdown.json
+++ b/.pymarkdown.json
@@ -1,7 +1,7 @@
 {
     "plugins" : {
         "no-hard-tabs": {
-            "enabled": false,
+            "enabled": true,
             "code_blocks": false
         },
         "no-multiple-blanks": {
diff --git a/notes/dig.md b/notes/dig.md
index 67a7968..8184889 100644
--- a/notes/dig.md
+++ b/notes/dig.md
@@ -6,8 +6,9 @@
 # oisix.com

 ```bash
+       # test tab
 $ dig @8.8.8.8 SOA +noall +ans oisix.com
-oisix.com.             300     IN      SOA     ns-172.awsdns-21.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400
+oisix.com.    300      IN      SOA     ns-172.awsdns-21.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400

 $ dig @8.8.8.8 MX +noall +ans oisix.com
 oisix.com.             300     IN      MX      10 mail01.oisix.com.

run

$ pre-commit run pymarkdown
PyMarkdown...............................................................Failed
- hook id: pymarkdown
- exit code: 1

notes/dig.md:9:1: MD010: Hard tabs [Column: 1] (no-hard-tabs)
notes/dig.md:11:18: MD010: Hard tabs [Column: 18] (no-hard-tabs)
notes/dig.md:11:23: MD010: Hard tabs [Column: 23] (no-hard-tabs)
notes/dig.md:11:28: MD010: Hard tabs [Column: 28] (no-hard-tabs)
notes/dig.md:14:11: MD010: Hard tabs [Column: 11] (no-hard-tabs)
<omit>

@jackdewinter
Copy link
Owner Author

are you trying to use .pymarkdown but adding .json to the end of it? the default JSON configuration is .pymarkdown in the current directory. if you want to use .pymarkdown.json, try --config .pymarkdown.json on the command line.

thoughts?

@officel
Copy link

officel commented Sep 5, 2023

yes, my .pre-commit-config.yaml is

  - repo: https://github.com/jackdewinter/pymarkdown
    rev: v0.9.13.3
    hooks:
      - id: pymarkdown
        exclude: |
          (?x)^(
            aws/panel.md|
            jq/[\d|\w|_]+\/(.*?)\.md|
            path/to/file3.py
          )$
        args:
          - --config=.pymarkdown.json
          - scan

and

cat .pymarkdown.json
{
    "plugins" : {
        "no-hard-tabs": {
            "enabled": true,
            "code_blocks": false
        },
        "no-multiple-blanks": {
            "maximum": 2
        },
        "blanks-around-headers": {
            "lines_above": 1,
            "lines_below": 1
        },
        "line-length": {
            "enabled": true,
            "line_length": 160,
            "heading_line_length": 160,
            "code_blocks": false
        },
        "no-inline-html": {
            "enabled": false
        },
        "single-title": {
            "enabled": false
        },
        "ul-style": {
            "enabled": false
        }
    },
    "extensions" : {
        "front-matter": {
            "enabled": true
        }
    }
}

Works fine except for no-hard-tabs

jackdewinter added a commit that referenced this issue Sep 8, 2023
jackdewinter added a commit that referenced this issue Sep 8, 2023
@jackdewinter
Copy link
Owner Author

Check now against 39770f261aaae32f56409129a76801fe7edd44e9... it should fix the problem. The verbiage for the documentation says "check" and the internal variable was "allow". Fixed to reflect this properly.

@officel
Copy link

officel commented Sep 9, 2023

@jackdewinter

I was able to do it! It seems to be ok.
Great job. Thank you!

$ git diff --cached
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c377226..4f86012 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -23,7 +23,7 @@ repos:
       - id: end-of-file-fixer
       - id: trailing-whitespace
   - repo: https://github.com/jackdewinter/pymarkdown
-    rev: v0.9.13.3
+    rev: 39770f261aaae32f56409129a76801fe7edd44e9
     hooks:
       - id: pymarkdown
         exclude: |
diff --git a/.pymarkdown.json b/.pymarkdown.json
index 462caff..8057cc5 100644
--- a/.pymarkdown.json
+++ b/.pymarkdown.json
@@ -1,7 +1,7 @@
 {
     "plugins" : {
         "no-hard-tabs": {
-            "enabled": false,
+            "enabled": true,
             "code_blocks": false
         },
         "no-multiple-blanks": {
diff --git a/notes/dig.md b/notes/dig.md
index 67a7968..706e609 100644
--- a/notes/dig.md
+++ b/notes/dig.md
@@ -7,7 +7,7 @@

 ```bash
 $ dig @8.8.8.8 SOA +noall +ans oisix.com
-oisix.com.             300     IN      SOA     ns-172.awsdns-21.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400
+oisix.com.    300      IN      SOA     ns-172.awsdns-21.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400

 $ dig @8.8.8.8 MX +noall +ans oisix.com
 oisix.com.             300     IN      MX      10 mail01.oisix.com.


$ pre-commit run pymarkdown
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/raki/.cache/pre-commit/patch1694265465-477971.
PyMarkdown...............................................................Passed
[INFO] Restored changes from /home/raki/.cache/pre-commit/patch1694265465-477971.

@jackdewinter
Copy link
Owner Author

closing after verification

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

No branches or pull requests

2 participants