mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-04-25 01:05:55 +03:00
[GH-ISSUE #1915] MD046: enable parsing/linting of over-indented blocks when set to fenced style #780
Labels
No labels
bug
enhancement
enhancement
enhancement
fixed in next
fixed in next
fixed in next
new rule
new rule
new rule
pull-request
question
refactoring
refactoring
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/markdownlint#780
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @nbanyan on GitHub (Jan 16, 2026).
Original GitHub issue: https://github.com/DavidAnson/markdownlint/issues/1915
In my project we try to enforce use of the fenced code style instead of the indented style because it is more declarative and the indented style mostly happens due to improper indentation. We also use Material, so things like admonitions and snippets can make some indented text look like code blocks when they are not.
Still having the warning for the wrong code style is critical for finding and standardizing actual or accidental indented code blocks, but it would be very helpful to have this rule enable parsing and linting of those indented blocks rather than skipping them - perhaps as a second boolean option for this rule like
{ "style": "fenced", "parse_indented": true }.@DavidAnson commented on GitHub (Jan 16, 2026):
As I understand, your project already bans the use of indented code blocks, so scenarios that might cause the problem you show are already flagged for attention. Fixing those problems will immediately reveal all the others, but instead it sounds like you want to reparse the document after making guesses about how to reformat it so those violations can be flagged in parallel? I don't understand the motivation - why not fix the reported indenting which will fix the structure of the document? Which it seems you want to do anyway?
@nbanyan commented on GitHub (Jan 16, 2026):
Because correct and intentional indentation such as for admonition content or after snippets are not errors, but since those constructs are not supported those indentations are assumed to be code blocks and therefore not parsed. I'm not looking for direct support for Material Markdown, just better compatibility for detecting errors in the blocks of text indented by these structures.
In the example:
@DavidAnson commented on GitHub (Jan 16, 2026):
If a document's structure is wildly off, I don't see a straightforward way to accomplish what you suggest without reparsing and reevaluating the relevant sections. But that requires knowing exactly what the structural problem is and how to fix it - and being able to do so reliably. Or else it requires understanding the specific Markdown flavor you're using, but that goes against the philosophy of using CommonMark plus GFM which covers the vast majority of scenarios out there.
@nbanyan commented on GitHub (Jan 16, 2026):
My assumption was that it'd just be a matter of not having it skip indented code text while evaluating.
Would doing precheck for indented code blocks (to get the warnings) then stripping the excess indentation in memory before a normal check work for this (although this would require recursion to catch nested instances...)? It might be easier than recursively evaluating each indented code block afterwards, although that might work also.
If any of those could work, it'd allow catching the example errors without requiring specific knowledge of the non-common syntax.