Skip to content

fix: handle Markdown indented code blocks in rule 17#178

Open
LarytheLord wants to merge 2 commits intocanonical:mainfrom
LarytheLord:fix/rule-17-md-indented-codeblocks
Open

fix: handle Markdown indented code blocks in rule 17#178
LarytheLord wants to merge 2 commits intocanonical:mainfrom
LarytheLord:fix/rule-17-md-indented-codeblocks

Conversation

@LarytheLord
Copy link

@LarytheLord LarytheLord commented Feb 25, 2026

Summary

Fix Rule 17 to also detect long Markdown indented code blocks (4-space style), not just fenced/directive variants.

Changes

  • Add an indented-Markdown pattern to:
    • 017a-Suggest-code-over-25-lines
    • 017b-Warn-code-over-35-lines
  • Add dedicated regression cases in tests/data/manifest.yml:
    • long-code-suggestion-md-indented
    • long-code-warning-md-indented
  • Follow-up fixture fix for trailing newline handling in these new cases.

Validation

  • cd tests && make run
  • Result: 51 passed

Partially addresses #176 (BlockCode coverage); fenced code blocks that are indented in Markdown are still out of scope for this PR.

@LarytheLord
Copy link
Author

Pushed follow-up commit f23dd45 to fix the failing Pytest (Vale rules) job.

Root cause was fixture/expectation mismatch for Markdown indented code blocks after the parser change: actual Vale match includes a trailing newline, while the two md-indented expected triggers were using stripped multiline blocks.

Fix:

  • updated only these two fixture trigger blocks in tests/data/manifest.yml to preserve the trailing newline:
    • long-code-suggestion-md-indented
    • long-code-warning-md-indented

Local validation:

  • cd tests && make run
  • result: 51 passed

@SecondSkoll
Copy link
Contributor

Thanks for the PR! I don't have a lot of time to look at this in detail today. One thing is that this won't actually fully close #176 - mostly because I wasn't specific enough in the description - but indenting a ``` delimited codeblock would not be solved by this.

However, this does look like a solid solution for BlockCode syntax at a glance.

@LarytheLord
Copy link
Author

Thanks for the review and totally agreed.

You’re right this does not fully close #176 as currently written; I’ve updated the PR description to mark this as a partial fix scoped to BlockCode (indented code block syntax), and explicitly called out the remaining fenced+indented Markdown case as out of scope here.

If you want, I can open a focused follow-up PR for that remaining case after this one.

@SecondSkoll
Copy link
Contributor

If you are interested that would be fantastic, but I don't think it would be a common use case - so I view it as relatively low priority at the moment :)

@LarytheLord
Copy link
Author

That makes sense, thanks. I’ll keep this PR scoped as-is and won’t open the follow-up unless priorities change.

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

Successfully merging this pull request may close these issues.

2 participants