Fix markdownlint output format #5085
Open
+40
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes markdownlint handler to support version 0.47.0 output format changes.
Problem
Markdownlint version 0.47.0 changed its output format by adding severity
keywords (
errorandwarning) after the column number. This broke ALE'sparser which expected a fixed format.
Analysis
I'm using vim 9.1 and ALE 4.0.0.
I discovered this bug when installing markdownlint-cli via
npmand noticingthat ALE was not parsing the linter output. After comparing the output between
versions 0.46.0 and 0.47.0, I identified that the format change (addition of
severity keywords) was causing the regex pattern in the ALE handler to fail to
match the new output format.
Minimal test case
To reproduce the issue, create a file
test.mdthat should produce lintererror:
Configure ALE to use just markdownlint for markdown files:
Install markdownlint version 0.46.0:
Check, if version 0.46.0 is installed:
Lint
test.md:$ markdownlint test.md test.md:3:1 MD051/link-fragments Link fragments should be valid [Context: "[LinkText](#link)"]Opening test.md with vim shows a warning for line 3, column 1.
Next, install markdownlint version 0.47.0:
Check, if version 0.47.0 is installed:
Lint
test.md:$ markdownlint test.md test.md:3:1 error MD051/link-fragments Link fragments should be valid [Context: "[LinkText](#link)"]Notice the
errorafter the column number.Opening test.md with vim shows no error or warning for line 3.
To produce
warninginstead oferror, create a markdownlint config file thatmarks 'MD051' as
warning, e.g..markdownlint.yml:$ markdownlint test.md test.md:3:1 warning MD051/link-fragments Link fragments should be valid [Context: "[LinkText](#link)"]Solution
Updated the markdownlint handler regex pattern to handle the optional severity
keyword while maintaining backward compatibility with version 0.46.0.
Changes:
error→ 'E',warning→ 'W')Testing
errorandwarningseverity keywords (0.47.0+)Commits