Description
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:
- Report excess lines at the top of the block
- 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)
- 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.