mirror of
https://github.com/dense-analysis/ale.git
synced 2026-01-27 05:12:16 +08:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user