Skip to content

MD046: enable parsing/linting of over-indented blocks when set to fenced style #1915

@nbanyan

Description

@nbanyan

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 }.

## Heading

Paragraph text before an over indented fenced code block.

    ```py
    # Broken code indent and failed fenced code as well...
        ```

??? note "MkDocs Material admonition"
    These have been discussed before, but I'm just looking to allow their content to be linted without explicitly supporting non-standard syntax.
    Examples of errors I've seen in these that I'd like linting warnings for:

    Paragraph text before an indented code block that needs the linting warning. (I'm still finding these in my project...)

        cp /path/to/file /path/to/new/file

    ##### Badly Incremented Heading

    * Mixed list styles
        - And other inconsistencies

--8<-- "snippet_list.md"

        * Appending to a list started in a snippet.
            - Snippets should also not be fully disected to be parsed/linted, but linting over indented text would be very useful in these instances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions