aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorHolger Detering2026-01-25 08:37:20 +0100
committerGitHub2026-01-25 16:37:20 +0900
commit9b51f6696046ee352dfd6ba6bcb9e803b149d5be (patch)
tree6e0a0c71f12da1c3540841e4842aad8df000b40a
parente3c152861999f851d237c10ef7ee48c1f9b7fdd1 (diff)
downloadale-9b51f6696046ee352dfd6ba6bcb9e803b149d5be.tar.gz

Fix markdownlint output format (#5085)

  • test: Add failing tests for markdownlint 0.47.0 output format

Add two new test cases to verify the markdownlint handler’s ability to parse output from version 0.47.0, which includes severity keywords (“error” or “warning”). These tests will fail with the current implementation, demonstrating the need for a fix to handle the new output format.

The tests specifically verify: - Parsing of error severity keyword - Parsing of warning severity keyword - Correct mapping of severity to ALE type (E/W)

Backward compatibility with version 0.46.0 is already verified by the existing ests.

  • fix: Update markdownlint handler for version 0.47.0 output format

Update the markdownlint handler to support the new output format introduced in version 0.47.0, which includes severity keywords (“error” and “warning”) after the column number.

Changes: - Updated regex pattern to capture optional severity keyword - Added type mapping logic (error → ‘E’, warning → ‘W’) - Adjusted match indices for rule ID and description text - Maintained backward compatibility with version 0.46.0

All tests now pass, including the new tests for 0.47.0 format.

  • style: Fix vint linting errors in markdownlint handler

  • Add blank line before if statement for better readability

  • Replace ==# with is# for case-sensitive comparison

-rw-r--r--autoload/ale/handlers/markdownlint.vim14
-rw-r--r--test/handler/test_markdownlint_handler.vader30
2 files changed, 40 insertions, 4 deletions
diff --git a/autoload/ale/handlers/markdownlint.vim b/autoload/ale/handlers/markdownlint.vim
index 6c273bd0f..4ede259b8 100644
--- a/autoload/ale/handlers/markdownlint.vim
+++ b/autoload/ale/handlers/markdownlint.vim
@@ -2,15 +2,21 @@
" Description: Adds support for markdownlint
function! ale#handlers#markdownlint#Handle(buffer, lines) abort
- let l:pattern=': \?\(\d\+\)\(:\(\d\+\)\?\)\? \(MD\d\{3}/[A-Za-z0-9-/]\+\) \(.*\)$'
+ let l:pattern=': \?\(\d\+\)\(:\(\d\+\)\?\)\? \(error\|warning\)\? \?\(MD\d\{3}/[A-Za-z0-9-/]\+\) \(.*\)$'
let l:output=[]
for l:match in ale#util#GetMatches(a:lines, l:pattern)
+ let l:type = 'W'
+
+ if l:match[4] is# 'error'
+ let l:type = 'E'
+ endif
+
let l:result = ({
\ 'lnum': l:match[1] + 0,
- \ 'code': l:match[4],
- \ 'text': l:match[5],
- \ 'type': 'W',
+ \ 'code': l:match[5],
+ \ 'text': l:match[6],
+ \ 'type': l:type,
\})
if len(l:match[3]) > 0
diff --git a/test/handler/test_markdownlint_handler.vader b/test/handler/test_markdownlint_handler.vader
index f49dba975..d9bf46186 100644
--- a/test/handler/test_markdownlint_handler.vader
+++ b/test/handler/test_markdownlint_handler.vader
@@ -32,3 +32,33 @@ Execute(The Markdownlint handler should parse output with multiple slashes in ru
\ ale#handlers#markdownlint#Handle(0, [
\ 'README.md:10 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Above] [Context: "### something"]'
\ ])
+
+Execute(The Markdownlint handler should parse output with error severity (0.47.0+)):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 1,
+ \ 'code': 'MD051/link-fragments',
+ \ 'text': 'Link fragments should be valid [Context: "[Installation](#installation)"]',
+ \ 'type': 'E'
+ \ }
+ \ ],
+ \ ale#handlers#markdownlint#Handle(0, [
+ \ 'test.md:3:1 error MD051/link-fragments Link fragments should be valid [Context: "[Installation](#installation)"]'
+ \ ])
+
+Execute(The Markdownlint handler should parse output with warning severity (0.47.0+)):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 1,
+ \ 'code': 'MD051/link-fragments',
+ \ 'text': 'Link fragments should be valid [Context: "[Installation](#installation)"]',
+ \ 'type': 'W'
+ \ }
+ \ ],
+ \ ale#handlers#markdownlint#Handle(0, [
+ \ 'test.md:3:1 warning MD051/link-fragments Link fragments should be valid [Context: "[Installation](#installation)"]'
+ \ ])