Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions autoload/ale/handlers/markdownlint.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions test/handler/test_markdownlint_handler.vader
Original file line number Diff line number Diff line change
Expand Up @@ -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)"]'
\ ])