All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: KabbAmine <amine.kabb@gmail.com>
2 " Description: This file adds support for checking HTML code with tidy.
4 let g:ale_html_tidy_executable = get(g:, 'ale_html_tidy_executable', 'tidy')
5 let g:ale_html_tidy_options = get(g:, 'ale_html_tidy_options', '-q -e -language en')
7 function! ale_linters#html#tidy#GetCommand(buffer) abort
8 " Specify file encoding in options
9 " (Idea taken from https://github.com/scrooloose/syntastic/blob/master/syntax_checkers/html/tidy.vim)
10 let l:file_encoding = get({
13 \ 'cp1252': '-win1252',
15 \ 'cp932': '-shiftjis',
16 \ 'iso-2022-jp': '-iso-2022',
17 \ 'latin1': '-latin1',
19 \ 'sjis': '-shiftjis',
20 \ 'utf-16le': '-utf16le',
23 \ }, &fileencoding, '-utf8')
25 " On macOS, old tidy (released on 31 Oct 2006) is installed. It does not
26 " consider HTML5 so we should avoid it.
27 let l:executable = ale#Var(a:buffer, 'html_tidy_executable')
29 if has('mac') && l:executable is# 'tidy' && exists('*exepath')
30 \ && exepath(l:executable) is# '/usr/bin/tidy'
34 return printf('%s %s %s -',
36 \ ale#Var(a:buffer, 'html_tidy_options'),
41 function! ale_linters#html#tidy#Handle(buffer, lines) abort
42 " Matches patterns lines like the following:
43 " line 7 column 5 - Warning: missing </title> before </head>
44 let l:pattern = '^line \(\d\+\) column \(\d\+\) - \(Warning\|Error\): \(.\+\)$'
47 for l:match in ale#util#GetMatches(a:lines, l:pattern)
48 let l:line = l:match[1] + 0
49 let l:col = l:match[2] + 0
50 let l:type = l:match[3] is# 'Error' ? 'E' : 'W'
51 let l:text = l:match[4]
64 call ale#linter#Define('html', {
66 \ 'executable': {b -> ale#Var(b, 'html_tidy_executable')},
67 \ 'output_stream': 'stderr',
68 \ 'command': function('ale_linters#html#tidy#GetCommand'),
69 \ 'callback': 'ale_linters#html#tidy#Handle',