Skip to content

[CI] Refactor/rework custom trim-code-block-and-unindent markdownlint rule #3183

Open
@chalin

Description

@chalin

The trim-code-block-and-unindent custom markdownlint (mdl) rule was introduced by

As was mentioned in the opening comment of #3177, the custom rule reports errors over a line range. I've since learned that mdl (especially it's issuing-fixing approach) is strictly line based. So, trim-code-block-and-unindent would need to be reworked so that it is line based -- that is, it should report an issue for each problematic line, along with the fix for that line only. With this mode of processing, it might be beneficial to split the rule into three:

  1. Report excess lines at the top of the block
  2. Report excess indentation inside of a block (to avoid a flood of reported issues, when not fixing, the custom rule might consider reporting only the first of many lines that need to be unindented)
  3. Report excess lines at the bottom of a block

Consider refactoring this rule so that it could, in principle, be used with mdl invoked from the command line. This is to ensure that it is properly packaged, and would be reusable in the context of other projects.

Reminder that our custom Gulp task actually strips out Hugo/Go-template directives ({{...}}) so it might not make sense to try to implement use of mld's --fix (from the CLI) or generally for all rules in our Gulp task (currently --fix only fixes code-block issues). It might be that mdl's helpers have generic functions that implement fixing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions