Merge #139 - Add Markdown linting support

This commit is contained in:
w0rp 2016-10-24 20:40:24 +01:00
parent 95373ddab5
commit b9428b7db0
3 changed files with 37 additions and 0 deletions

View File

@ -45,6 +45,7 @@ name. That seems to be the fairest way to arrange this table.
| JavaScript | [eslint](http://eslint.org/), [jscs](http://jscs.info/), [jshint](http://jshint.com/) |
| JSON | [jsonlint](http://zaa.ch/jsonlint/) |
| Lua | [luacheck](https://github.com/mpeterv/luacheck) |
| Markdown | [mdl](https://github.com/mivok/markdownlint) |
| MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) |
| Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) |
| PHP | [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer) |

View File

@ -0,0 +1,35 @@
" Author: Steve Dignam <steve@dignam.xyz>
" Description: Support for mdl, a markdown linter
function! ale_linters#markdown#mdl#Handle(buffer, lines) abort
" matches: '(stdin):173: MD004 Unordered list style'
let l:pattern = ':\(\d*\): \(.*\)$'
let l:output = []
for l:line in a:lines
let l:match = matchlist(l:line, l:pattern)
if len(l:match) == 0
continue
endif
call add(l:output, {
\ 'bufnr': a:buffer,
\ 'lnum': l:match[1] + 0,
\ 'vcol': 0,
\ 'col': 0,
\ 'text': l:match[2],
\ 'type': 'W',
\ 'nr': -1,
\})
endfor
return l:output
endfunction
call ale#linter#Define('markdown', {
\ 'name': 'mdl',
\ 'executable': 'mdl',
\ 'command': 'mdl',
\ 'callback': 'ale_linters#markdown#mdl#Handle'
\})

View File

@ -67,6 +67,7 @@ The following languages and tools are supported.
* JavaScript: 'eslint', 'jscs', 'jshint'
* JSON: 'jsonlint'
* Lua: 'luacheck'
* Markdown: 'mdl'
* MATLAB: 'mlint'
* Perl: 'perl' (-c flag), 'perlcritic'
* PHP: 'php' (-l flag), 'phpcs'